Background Updates: Record plugin & theme update statistics like we do for core updates.
Pass plugin/theme update objects into the Background updater for consistency with core & translations. Merges [27905] to the 3.7 branch. props dd32. fixes #27633. Built from https://develop.svn.wordpress.org/branches/3.7@27924 git-svn-id: http://core.svn.wordpress.org/branches/3.7@27754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3ec57fa3e0
commit
d5744d72dc
|
@ -1872,18 +1872,21 @@ class WP_Automatic_Updater {
|
||||||
if ( ! $this->should_update( $type, $item, $context ) )
|
if ( ! $this->should_update( $type, $item, $context ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
$upgrader_item = $item;
|
||||||
switch ( $type ) {
|
switch ( $type ) {
|
||||||
case 'core':
|
case 'core':
|
||||||
$skin->feedback( __( 'Updating to WordPress %s' ), $item->version );
|
$skin->feedback( __( 'Updating to WordPress %s' ), $item->version );
|
||||||
$item_name = sprintf( __( 'WordPress %s' ), $item->version );
|
$item_name = sprintf( __( 'WordPress %s' ), $item->version );
|
||||||
break;
|
break;
|
||||||
case 'theme':
|
case 'theme':
|
||||||
$theme = wp_get_theme( $item );
|
$upgrader_item = $item->theme;
|
||||||
|
$theme = wp_get_theme( $upgrader_item );
|
||||||
$item_name = $theme->Get( 'Name' );
|
$item_name = $theme->Get( 'Name' );
|
||||||
$skin->feedback( __( 'Updating theme: %s' ), $item_name );
|
$skin->feedback( __( 'Updating theme: %s' ), $item_name );
|
||||||
break;
|
break;
|
||||||
case 'plugin':
|
case 'plugin':
|
||||||
$plugin_data = get_plugin_data( $context . '/' . $item );
|
$upgrader_item = $item->plugin;
|
||||||
|
$plugin_data = get_plugin_data( $context . '/' . $upgrader_item );
|
||||||
$item_name = $plugin_data['Name'];
|
$item_name = $plugin_data['Name'];
|
||||||
$skin->feedback( __( 'Updating plugin: %s' ), $item_name );
|
$skin->feedback( __( 'Updating plugin: %s' ), $item_name );
|
||||||
break;
|
break;
|
||||||
|
@ -1895,7 +1898,7 @@ class WP_Automatic_Updater {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boom, This sites about to get a whole new splash of paint!
|
// Boom, This sites about to get a whole new splash of paint!
|
||||||
$upgrade_result = $upgrader->upgrade( $item, array(
|
$upgrade_result = $upgrader->upgrade( $upgrader_item, array(
|
||||||
'clear_update_cache' => false,
|
'clear_update_cache' => false,
|
||||||
'pre_check_md5' => false, /* always use partial builds if possible for core updates */
|
'pre_check_md5' => false, /* always use partial builds if possible for core updates */
|
||||||
'attempt_rollback' => true, /* only available for core updates */
|
'attempt_rollback' => true, /* only available for core updates */
|
||||||
|
@ -1969,7 +1972,7 @@ class WP_Automatic_Updater {
|
||||||
wp_update_plugins(); // Check for Plugin updates
|
wp_update_plugins(); // Check for Plugin updates
|
||||||
$plugin_updates = get_site_transient( 'update_plugins' );
|
$plugin_updates = get_site_transient( 'update_plugins' );
|
||||||
if ( $plugin_updates && !empty( $plugin_updates->response ) ) {
|
if ( $plugin_updates && !empty( $plugin_updates->response ) ) {
|
||||||
foreach ( array_keys( $plugin_updates->response ) as $plugin ) {
|
foreach ( $plugin_updates->response as $plugin ) {
|
||||||
$this->update( 'plugin', $plugin );
|
$this->update( 'plugin', $plugin );
|
||||||
}
|
}
|
||||||
// Force refresh of plugin update information
|
// Force refresh of plugin update information
|
||||||
|
@ -1980,8 +1983,8 @@ class WP_Automatic_Updater {
|
||||||
wp_update_themes(); // Check for Theme updates
|
wp_update_themes(); // Check for Theme updates
|
||||||
$theme_updates = get_site_transient( 'update_themes' );
|
$theme_updates = get_site_transient( 'update_themes' );
|
||||||
if ( $theme_updates && !empty( $theme_updates->response ) ) {
|
if ( $theme_updates && !empty( $theme_updates->response ) ) {
|
||||||
foreach ( array_keys( $theme_updates->response ) as $theme ) {
|
foreach ( $theme_updates->response as $theme ) {
|
||||||
$this->update( 'theme', $theme );
|
$this->update( 'theme', (object) $theme );
|
||||||
}
|
}
|
||||||
// Force refresh of theme update information
|
// Force refresh of theme update information
|
||||||
wp_clean_themes_cache();
|
wp_clean_themes_cache();
|
||||||
|
@ -1996,8 +1999,21 @@ class WP_Automatic_Updater {
|
||||||
|
|
||||||
// Clean up, and check for any pending translations
|
// Clean up, and check for any pending translations
|
||||||
// (Core_Upgrader checks for core updates)
|
// (Core_Upgrader checks for core updates)
|
||||||
wp_update_themes(); // Check for Theme updates
|
$theme_stats = array();
|
||||||
wp_update_plugins(); // Check for Plugin updates
|
if ( isset( $this->update_results['theme'] ) ) {
|
||||||
|
foreach ( $this->update_results['theme'] as $upgrade ) {
|
||||||
|
$theme_stats[ $upgrade->item->theme ] = ( true === $upgrade->result );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wp_update_themes( $theme_stats ); // Check for Theme updates
|
||||||
|
|
||||||
|
$plugin_stats = array();
|
||||||
|
if ( isset( $this->update_results['plugin'] ) ) {
|
||||||
|
foreach ( $this->update_results['plugin'] as $upgrade ) {
|
||||||
|
$plugin_stats[ $upgrade->item->plugin ] = ( true === $upgrade->result );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wp_update_plugins( $plugin_stats ); // Check for Plugin updates
|
||||||
|
|
||||||
// Finally, Process any new translations
|
// Finally, Process any new translations
|
||||||
$language_updates = wp_get_translation_updates();
|
$language_updates = wp_get_translation_updates();
|
||||||
|
|
|
@ -160,9 +160,10 @@ function wp_version_check( $extra_stats = array() ) {
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
* @uses $wp_version Used to notify the WordPress version.
|
* @uses $wp_version Used to notify the WordPress version.
|
||||||
*
|
*
|
||||||
|
* @param array $extra_stats Extra statistics to report to the WordPress.org API.
|
||||||
* @return mixed Returns null if update is unsupported. Returns false if check is too soon.
|
* @return mixed Returns null if update is unsupported. Returns false if check is too soon.
|
||||||
*/
|
*/
|
||||||
function wp_update_plugins() {
|
function wp_update_plugins( $extra_stats = array() ) {
|
||||||
include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
|
include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
|
||||||
|
|
||||||
if ( defined('WP_INSTALLING') )
|
if ( defined('WP_INSTALLING') )
|
||||||
|
@ -201,7 +202,7 @@ function wp_update_plugins() {
|
||||||
|
|
||||||
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
|
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
|
||||||
|
|
||||||
if ( $time_not_changed ) {
|
if ( $time_not_changed && ! $extra_stats ) {
|
||||||
$plugin_changed = false;
|
$plugin_changed = false;
|
||||||
foreach ( $plugins as $file => $p ) {
|
foreach ( $plugins as $file => $p ) {
|
||||||
$new_option->checked[ $file ] = $p['Version'];
|
$new_option->checked[ $file ] = $p['Version'];
|
||||||
|
@ -250,6 +251,10 @@ function wp_update_plugins() {
|
||||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
|
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( $plugin_update_stats ) {
|
||||||
|
$options['body']['update_stats'] = json_encode( $extra_stats );
|
||||||
|
}
|
||||||
|
|
||||||
$url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/';
|
$url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/';
|
||||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
|
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
|
||||||
$url = set_url_scheme( $url, 'https' );
|
$url = set_url_scheme( $url, 'https' );
|
||||||
|
@ -291,9 +296,10 @@ function wp_update_plugins() {
|
||||||
* @since 2.7.0
|
* @since 2.7.0
|
||||||
* @uses $wp_version Used to notify the WordPress version.
|
* @uses $wp_version Used to notify the WordPress version.
|
||||||
*
|
*
|
||||||
|
* @param array $extra_stats Extra statistics to report to the WordPress.org API.
|
||||||
* @return mixed Returns null if update is unsupported. Returns false if check is too soon.
|
* @return mixed Returns null if update is unsupported. Returns false if check is too soon.
|
||||||
*/
|
*/
|
||||||
function wp_update_themes() {
|
function wp_update_themes( $extra_stats = array() ) {
|
||||||
include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
|
include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
|
||||||
|
|
||||||
if ( defined( 'WP_INSTALLING' ) )
|
if ( defined( 'WP_INSTALLING' ) )
|
||||||
|
@ -343,7 +349,7 @@ function wp_update_themes() {
|
||||||
|
|
||||||
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
|
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
|
||||||
|
|
||||||
if ( $time_not_changed ) {
|
if ( $time_not_changed && ! $extra_stats ) {
|
||||||
$theme_changed = false;
|
$theme_changed = false;
|
||||||
foreach ( $checked as $slug => $v ) {
|
foreach ( $checked as $slug => $v ) {
|
||||||
if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) )
|
if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) )
|
||||||
|
@ -390,6 +396,10 @@ function wp_update_themes() {
|
||||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
|
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( $theme_update_stats ) {
|
||||||
|
$options['body']['update_stats'] = json_encode( $extra_stats );
|
||||||
|
}
|
||||||
|
|
||||||
$url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
|
$url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
|
||||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
|
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
|
||||||
$url = set_url_scheme( $url, 'https' );
|
$url = set_url_scheme( $url, 'https' );
|
||||||
|
|
Loading…
Reference in New Issue