Edit File by line
/home/barbar84/www/wp-admin/includes
File: class-theme-upgrader.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Upgrade API: Theme_Upgrader class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Upgrader
[5] Fix | Delete
* @since 4.6.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Core class used for upgrading/installing themes.
[10] Fix | Delete
*
[11] Fix | Delete
* It is designed to upgrade/install themes from a local zip, remote zip URL,
[12] Fix | Delete
* or uploaded zip file.
[13] Fix | Delete
*
[14] Fix | Delete
* @since 2.8.0
[15] Fix | Delete
* @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader.php.
[16] Fix | Delete
*
[17] Fix | Delete
* @see WP_Upgrader
[18] Fix | Delete
*/
[19] Fix | Delete
class Theme_Upgrader extends WP_Upgrader {
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Result of the theme upgrade offer.
[23] Fix | Delete
*
[24] Fix | Delete
* @since 2.8.0
[25] Fix | Delete
* @var array|WP_Error $result
[26] Fix | Delete
* @see WP_Upgrader::$result
[27] Fix | Delete
*/
[28] Fix | Delete
public $result;
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Whether multiple themes are being upgraded/installed in bulk.
[32] Fix | Delete
*
[33] Fix | Delete
* @since 2.9.0
[34] Fix | Delete
* @var bool $bulk
[35] Fix | Delete
*/
[36] Fix | Delete
public $bulk = false;
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* New theme info.
[40] Fix | Delete
*
[41] Fix | Delete
* @since 5.5.0
[42] Fix | Delete
* @var array $new_theme_data
[43] Fix | Delete
*
[44] Fix | Delete
* @see check_package()
[45] Fix | Delete
*/
[46] Fix | Delete
public $new_theme_data = array();
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Initialize the upgrade strings.
[50] Fix | Delete
*
[51] Fix | Delete
* @since 2.8.0
[52] Fix | Delete
*/
[53] Fix | Delete
public function upgrade_strings() {
[54] Fix | Delete
$this->strings['up_to_date'] = __( 'The theme is at the latest version.' );
[55] Fix | Delete
$this->strings['no_package'] = __( 'Update package not available.' );
[56] Fix | Delete
/* translators: %s: Package URL. */
[57] Fix | Delete
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s&#8230;' ), '<span class="code">%s</span>' );
[58] Fix | Delete
$this->strings['unpack_package'] = __( 'Unpacking the update&#8230;' );
[59] Fix | Delete
$this->strings['remove_old'] = __( 'Removing the old version of the theme&#8230;' );
[60] Fix | Delete
$this->strings['remove_old_failed'] = __( 'Could not remove the old theme.' );
[61] Fix | Delete
$this->strings['process_failed'] = __( 'Theme update failed.' );
[62] Fix | Delete
$this->strings['process_success'] = __( 'Theme updated successfully.' );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Initialize the installation strings.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 2.8.0
[69] Fix | Delete
*/
[70] Fix | Delete
public function install_strings() {
[71] Fix | Delete
$this->strings['no_package'] = __( 'Installation package not available.' );
[72] Fix | Delete
/* translators: %s: Package URL. */
[73] Fix | Delete
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s&#8230;' ), '<span class="code">%s</span>' );
[74] Fix | Delete
$this->strings['unpack_package'] = __( 'Unpacking the package&#8230;' );
[75] Fix | Delete
$this->strings['installing_package'] = __( 'Installing the theme&#8230;' );
[76] Fix | Delete
$this->strings['remove_old'] = __( 'Removing the old version of the theme&#8230;' );
[77] Fix | Delete
$this->strings['remove_old_failed'] = __( 'Could not remove the old theme.' );
[78] Fix | Delete
$this->strings['no_files'] = __( 'The theme contains no files.' );
[79] Fix | Delete
$this->strings['process_failed'] = __( 'Theme installation failed.' );
[80] Fix | Delete
$this->strings['process_success'] = __( 'Theme installed successfully.' );
[81] Fix | Delete
/* translators: 1: Theme name, 2: Theme version. */
[82] Fix | Delete
$this->strings['process_success_specific'] = __( 'Successfully installed the theme <strong>%1$s %2$s</strong>.' );
[83] Fix | Delete
$this->strings['parent_theme_search'] = __( 'This theme requires a parent theme. Checking if it is installed&#8230;' );
[84] Fix | Delete
/* translators: 1: Theme name, 2: Theme version. */
[85] Fix | Delete
$this->strings['parent_theme_prepare_install'] = __( 'Preparing to install <strong>%1$s %2$s</strong>&#8230;' );
[86] Fix | Delete
/* translators: 1: Theme name, 2: Theme version. */
[87] Fix | Delete
$this->strings['parent_theme_currently_installed'] = __( 'The parent theme, <strong>%1$s %2$s</strong>, is currently installed.' );
[88] Fix | Delete
/* translators: 1: Theme name, 2: Theme version. */
[89] Fix | Delete
$this->strings['parent_theme_install_success'] = __( 'Successfully installed the parent theme, <strong>%1$s %2$s</strong>.' );
[90] Fix | Delete
/* translators: %s: Theme name. */
[91] Fix | Delete
$this->strings['parent_theme_not_found'] = sprintf( __( '<strong>The parent theme could not be found.</strong> You will need to install the parent theme, %s, before you can use this child theme.' ), '<strong>%s</strong>' );
[92] Fix | Delete
/* translators: %s: Theme error. */
[93] Fix | Delete
$this->strings['current_theme_has_errors'] = __( 'The current theme has the following error: "%s".' );
[94] Fix | Delete
[95] Fix | Delete
if ( ! empty( $this->skin->overwrite ) ) {
[96] Fix | Delete
if ( 'update-theme' === $this->skin->overwrite ) {
[97] Fix | Delete
$this->strings['installing_package'] = __( 'Updating the theme&#8230;' );
[98] Fix | Delete
$this->strings['process_failed'] = __( 'Theme update failed.' );
[99] Fix | Delete
$this->strings['process_success'] = __( 'Theme updated successfully.' );
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
if ( 'downgrade-theme' === $this->skin->overwrite ) {
[103] Fix | Delete
$this->strings['installing_package'] = __( 'Downgrading the theme&#8230;' );
[104] Fix | Delete
$this->strings['process_failed'] = __( 'Theme downgrade failed.' );
[105] Fix | Delete
$this->strings['process_success'] = __( 'Theme downgraded successfully.' );
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* Check if a child theme is being installed and we need to install its parent.
[112] Fix | Delete
*
[113] Fix | Delete
* Hooked to the {@see 'upgrader_post_install'} filter by Theme_Upgrader::install().
[114] Fix | Delete
*
[115] Fix | Delete
* @since 3.4.0
[116] Fix | Delete
*
[117] Fix | Delete
* @param bool $install_result
[118] Fix | Delete
* @param array $hook_extra
[119] Fix | Delete
* @param array $child_result
[120] Fix | Delete
* @return bool
[121] Fix | Delete
*/
[122] Fix | Delete
public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) {
[123] Fix | Delete
// Check to see if we need to install a parent theme.
[124] Fix | Delete
$theme_info = $this->theme_info();
[125] Fix | Delete
[126] Fix | Delete
if ( ! $theme_info->parent() ) {
[127] Fix | Delete
return $install_result;
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
$this->skin->feedback( 'parent_theme_search' );
[131] Fix | Delete
[132] Fix | Delete
if ( ! $theme_info->parent()->errors() ) {
[133] Fix | Delete
$this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display( 'Name' ), $theme_info->parent()->display( 'Version' ) );
[134] Fix | Delete
// We already have the theme, fall through.
[135] Fix | Delete
return $install_result;
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
// We don't have the parent theme, let's install it.
[139] Fix | Delete
$api = themes_api(
[140] Fix | Delete
'theme_information',
[141] Fix | Delete
array(
[142] Fix | Delete
'slug' => $theme_info->get( 'Template' ),
[143] Fix | Delete
'fields' => array(
[144] Fix | Delete
'sections' => false,
[145] Fix | Delete
'tags' => false,
[146] Fix | Delete
),
[147] Fix | Delete
)
[148] Fix | Delete
); // Save on a bit of bandwidth.
[149] Fix | Delete
[150] Fix | Delete
if ( ! $api || is_wp_error( $api ) ) {
[151] Fix | Delete
$this->skin->feedback( 'parent_theme_not_found', $theme_info->get( 'Template' ) );
[152] Fix | Delete
// Don't show activate or preview actions after installation.
[153] Fix | Delete
add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) );
[154] Fix | Delete
return $install_result;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
// Backup required data we're going to override:
[158] Fix | Delete
$child_api = $this->skin->api;
[159] Fix | Delete
$child_success_message = $this->strings['process_success'];
[160] Fix | Delete
[161] Fix | Delete
// Override them.
[162] Fix | Delete
$this->skin->api = $api;
[163] Fix | Delete
[164] Fix | Delete
$this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];
[165] Fix | Delete
[166] Fix | Delete
$this->skin->feedback( 'parent_theme_prepare_install', $api->name, $api->version );
[167] Fix | Delete
[168] Fix | Delete
add_filter( 'install_theme_complete_actions', '__return_false', 999 ); // Don't show any actions after installing the theme.
[169] Fix | Delete
[170] Fix | Delete
// Install the parent theme.
[171] Fix | Delete
$parent_result = $this->run(
[172] Fix | Delete
array(
[173] Fix | Delete
'package' => $api->download_link,
[174] Fix | Delete
'destination' => get_theme_root(),
[175] Fix | Delete
'clear_destination' => false, // Do not overwrite files.
[176] Fix | Delete
'clear_working' => true,
[177] Fix | Delete
)
[178] Fix | Delete
);
[179] Fix | Delete
[180] Fix | Delete
if ( is_wp_error( $parent_result ) ) {
[181] Fix | Delete
add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) );
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
// Start cleaning up after the parent's installation.
[185] Fix | Delete
remove_filter( 'install_theme_complete_actions', '__return_false', 999 );
[186] Fix | Delete
[187] Fix | Delete
// Reset child's result and data.
[188] Fix | Delete
$this->result = $child_result;
[189] Fix | Delete
$this->skin->api = $child_api;
[190] Fix | Delete
$this->strings['process_success'] = $child_success_message;
[191] Fix | Delete
[192] Fix | Delete
return $install_result;
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Don't display the activate and preview actions to the user.
[197] Fix | Delete
*
[198] Fix | Delete
* Hooked to the {@see 'install_theme_complete_actions'} filter by
[199] Fix | Delete
* Theme_Upgrader::check_parent_theme_filter() when installing
[200] Fix | Delete
* a child theme and installing the parent theme fails.
[201] Fix | Delete
*
[202] Fix | Delete
* @since 3.4.0
[203] Fix | Delete
*
[204] Fix | Delete
* @param array $actions Preview actions.
[205] Fix | Delete
* @return array
[206] Fix | Delete
*/
[207] Fix | Delete
public function hide_activate_preview_actions( $actions ) {
[208] Fix | Delete
unset( $actions['activate'], $actions['preview'] );
[209] Fix | Delete
return $actions;
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
/**
[213] Fix | Delete
* Install a theme package.
[214] Fix | Delete
*
[215] Fix | Delete
* @since 2.8.0
[216] Fix | Delete
* @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional.
[217] Fix | Delete
*
[218] Fix | Delete
* @param string $package The full local path or URI of the package.
[219] Fix | Delete
* @param array $args {
[220] Fix | Delete
* Optional. Other arguments for installing a theme package. Default empty array.
[221] Fix | Delete
*
[222] Fix | Delete
* @type bool $clear_update_cache Whether to clear the updates cache if successful.
[223] Fix | Delete
* Default true.
[224] Fix | Delete
* }
[225] Fix | Delete
*
[226] Fix | Delete
* @return bool|WP_Error True if the installation was successful, false or a WP_Error object otherwise.
[227] Fix | Delete
*/
[228] Fix | Delete
public function install( $package, $args = array() ) {
[229] Fix | Delete
$defaults = array(
[230] Fix | Delete
'clear_update_cache' => true,
[231] Fix | Delete
'overwrite_package' => false, // Do not overwrite files.
[232] Fix | Delete
);
[233] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[234] Fix | Delete
[235] Fix | Delete
$this->init();
[236] Fix | Delete
$this->install_strings();
[237] Fix | Delete
[238] Fix | Delete
add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
[239] Fix | Delete
add_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ), 10, 3 );
[240] Fix | Delete
[241] Fix | Delete
if ( $parsed_args['clear_update_cache'] ) {
[242] Fix | Delete
// Clear cache so wp_update_themes() knows about the new theme.
[243] Fix | Delete
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
$this->run(
[247] Fix | Delete
array(
[248] Fix | Delete
'package' => $package,
[249] Fix | Delete
'destination' => get_theme_root(),
[250] Fix | Delete
'clear_destination' => $parsed_args['overwrite_package'],
[251] Fix | Delete
'clear_working' => true,
[252] Fix | Delete
'hook_extra' => array(
[253] Fix | Delete
'type' => 'theme',
[254] Fix | Delete
'action' => 'install',
[255] Fix | Delete
),
[256] Fix | Delete
)
[257] Fix | Delete
);
[258] Fix | Delete
[259] Fix | Delete
remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
[260] Fix | Delete
remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
[261] Fix | Delete
remove_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ) );
[262] Fix | Delete
[263] Fix | Delete
if ( ! $this->result || is_wp_error( $this->result ) ) {
[264] Fix | Delete
return $this->result;
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
// Refresh the Theme Update information.
[268] Fix | Delete
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
[269] Fix | Delete
[270] Fix | Delete
if ( $parsed_args['overwrite_package'] ) {
[271] Fix | Delete
/** This action is documented in wp-admin/includes/class-plugin-upgrader.php */
[272] Fix | Delete
do_action( 'upgrader_overwrote_package', $package, $this->new_theme_data, 'theme' );
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
return true;
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
/**
[279] Fix | Delete
* Upgrade a theme.
[280] Fix | Delete
*
[281] Fix | Delete
* @since 2.8.0
[282] Fix | Delete
* @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional.
[283] Fix | Delete
*
[284] Fix | Delete
* @param string $theme The theme slug.
[285] Fix | Delete
* @param array $args {
[286] Fix | Delete
* Optional. Other arguments for upgrading a theme. Default empty array.
[287] Fix | Delete
*
[288] Fix | Delete
* @type bool $clear_update_cache Whether to clear the update cache if successful.
[289] Fix | Delete
* Default true.
[290] Fix | Delete
* }
[291] Fix | Delete
* @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise.
[292] Fix | Delete
*/
[293] Fix | Delete
public function upgrade( $theme, $args = array() ) {
[294] Fix | Delete
$defaults = array(
[295] Fix | Delete
'clear_update_cache' => true,
[296] Fix | Delete
);
[297] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[298] Fix | Delete
[299] Fix | Delete
$this->init();
[300] Fix | Delete
$this->upgrade_strings();
[301] Fix | Delete
[302] Fix | Delete
// Is an update available?
[303] Fix | Delete
$current = get_site_transient( 'update_themes' );
[304] Fix | Delete
if ( ! isset( $current->response[ $theme ] ) ) {
[305] Fix | Delete
$this->skin->before();
[306] Fix | Delete
$this->skin->set_result( false );
[307] Fix | Delete
$this->skin->error( 'up_to_date' );
[308] Fix | Delete
$this->skin->after();
[309] Fix | Delete
return false;
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
$r = $current->response[ $theme ];
[313] Fix | Delete
[314] Fix | Delete
add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
[315] Fix | Delete
add_filter( 'upgrader_post_install', array( $this, 'current_after' ), 10, 2 );
[316] Fix | Delete
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ), 10, 4 );
[317] Fix | Delete
if ( $parsed_args['clear_update_cache'] ) {
[318] Fix | Delete
// Clear cache so wp_update_themes() knows about the new theme.
[319] Fix | Delete
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
$this->run(
[323] Fix | Delete
array(
[324] Fix | Delete
'package' => $r['package'],
[325] Fix | Delete
'destination' => get_theme_root( $theme ),
[326] Fix | Delete
'clear_destination' => true,
[327] Fix | Delete
'clear_working' => true,
[328] Fix | Delete
'hook_extra' => array(
[329] Fix | Delete
'theme' => $theme,
[330] Fix | Delete
'type' => 'theme',
[331] Fix | Delete
'action' => 'update',
[332] Fix | Delete
),
[333] Fix | Delete
)
[334] Fix | Delete
);
[335] Fix | Delete
[336] Fix | Delete
remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
[337] Fix | Delete
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
[338] Fix | Delete
remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) );
[339] Fix | Delete
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) );
[340] Fix | Delete
[341] Fix | Delete
if ( ! $this->result || is_wp_error( $this->result ) ) {
[342] Fix | Delete
return $this->result;
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
[346] Fix | Delete
[347] Fix | Delete
// Ensure any future auto-update failures trigger a failure email by removing
[348] Fix | Delete
// the last failure notification from the list when themes update successfully.
[349] Fix | Delete
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
[350] Fix | Delete
[351] Fix | Delete
if ( isset( $past_failure_emails[ $theme ] ) ) {
[352] Fix | Delete
unset( $past_failure_emails[ $theme ] );
[353] Fix | Delete
update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
return true;
[357] Fix | Delete
}
[358] Fix | Delete
[359] Fix | Delete
/**
[360] Fix | Delete
* Upgrade several themes at once.
[361] Fix | Delete
*
[362] Fix | Delete
* @since 3.0.0
[363] Fix | Delete
* @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional.
[364] Fix | Delete
*
[365] Fix | Delete
* @param string[] $themes Array of the theme slugs.
[366] Fix | Delete
* @param array $args {
[367] Fix | Delete
* Optional. Other arguments for upgrading several themes at once. Default empty array.
[368] Fix | Delete
*
[369] Fix | Delete
* @type bool $clear_update_cache Whether to clear the update cache if successful.
[370] Fix | Delete
* Default true.
[371] Fix | Delete
* }
[372] Fix | Delete
* @return array[]|false An array of results, or false if unable to connect to the filesystem.
[373] Fix | Delete
*/
[374] Fix | Delete
public function bulk_upgrade( $themes, $args = array() ) {
[375] Fix | Delete
$defaults = array(
[376] Fix | Delete
'clear_update_cache' => true,
[377] Fix | Delete
);
[378] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[379] Fix | Delete
[380] Fix | Delete
$this->init();
[381] Fix | Delete
$this->bulk = true;
[382] Fix | Delete
$this->upgrade_strings();
[383] Fix | Delete
[384] Fix | Delete
$current = get_site_transient( 'update_themes' );
[385] Fix | Delete
[386] Fix | Delete
add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
[387] Fix | Delete
add_filter( 'upgrader_post_install', array( $this, 'current_after' ), 10, 2 );
[388] Fix | Delete
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ), 10, 4 );
[389] Fix | Delete
[390] Fix | Delete
$this->skin->header();
[391] Fix | Delete
[392] Fix | Delete
// Connect to the filesystem first.
[393] Fix | Delete
$res = $this->fs_connect( array( WP_CONTENT_DIR ) );
[394] Fix | Delete
if ( ! $res ) {
[395] Fix | Delete
$this->skin->footer();
[396] Fix | Delete
return false;
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
$this->skin->bulk_header();
[400] Fix | Delete
[401] Fix | Delete
/*
[402] Fix | Delete
* Only start maintenance mode if:
[403] Fix | Delete
* - running Multisite and there are one or more themes specified, OR
[404] Fix | Delete
* - a theme with an update available is currently in use.
[405] Fix | Delete
* @todo For multisite, maintenance mode should only kick in for individual sites if at all possible.
[406] Fix | Delete
*/
[407] Fix | Delete
$maintenance = ( is_multisite() && ! empty( $themes ) );
[408] Fix | Delete
foreach ( $themes as $theme ) {
[409] Fix | Delete
$maintenance = $maintenance || get_stylesheet() === $theme || get_template() === $theme;
[410] Fix | Delete
}
[411] Fix | Delete
if ( $maintenance ) {
[412] Fix | Delete
$this->maintenance_mode( true );
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
$results = array();
[416] Fix | Delete
[417] Fix | Delete
$this->update_count = count( $themes );
[418] Fix | Delete
$this->update_current = 0;
[419] Fix | Delete
foreach ( $themes as $theme ) {
[420] Fix | Delete
$this->update_current++;
[421] Fix | Delete
[422] Fix | Delete
$this->skin->theme_info = $this->theme_info( $theme );
[423] Fix | Delete
[424] Fix | Delete
if ( ! isset( $current->response[ $theme ] ) ) {
[425] Fix | Delete
$this->skin->set_result( true );
[426] Fix | Delete
$this->skin->before();
[427] Fix | Delete
$this->skin->feedback( 'up_to_date' );
[428] Fix | Delete
$this->skin->after();
[429] Fix | Delete
$results[ $theme ] = true;
[430] Fix | Delete
continue;
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
// Get the URL to the zip file.
[434] Fix | Delete
$r = $current->response[ $theme ];
[435] Fix | Delete
[436] Fix | Delete
$result = $this->run(
[437] Fix | Delete
array(
[438] Fix | Delete
'package' => $r['package'],
[439] Fix | Delete
'destination' => get_theme_root( $theme ),
[440] Fix | Delete
'clear_destination' => true,
[441] Fix | Delete
'clear_working' => true,
[442] Fix | Delete
'is_multi' => true,
[443] Fix | Delete
'hook_extra' => array(
[444] Fix | Delete
'theme' => $theme,
[445] Fix | Delete
),
[446] Fix | Delete
)
[447] Fix | Delete
);
[448] Fix | Delete
[449] Fix | Delete
$results[ $theme ] = $this->result;
[450] Fix | Delete
[451] Fix | Delete
// Prevent credentials auth screen from displaying multiple times.
[452] Fix | Delete
if ( false === $result ) {
[453] Fix | Delete
break;
[454] Fix | Delete
}
[455] Fix | Delete
} // End foreach $themes.
[456] Fix | Delete
[457] Fix | Delete
$this->maintenance_mode( false );
[458] Fix | Delete
[459] Fix | Delete
// Refresh the Theme Update information.
[460] Fix | Delete
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
[461] Fix | Delete
[462] Fix | Delete
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
[463] Fix | Delete
do_action(
[464] Fix | Delete
'upgrader_process_complete',
[465] Fix | Delete
$this,
[466] Fix | Delete
array(
[467] Fix | Delete
'action' => 'update',
[468] Fix | Delete
'type' => 'theme',
[469] Fix | Delete
'bulk' => true,
[470] Fix | Delete
'themes' => $themes,
[471] Fix | Delete
)
[472] Fix | Delete
);
[473] Fix | Delete
[474] Fix | Delete
$this->skin->bulk_footer();
[475] Fix | Delete
[476] Fix | Delete
$this->skin->footer();
[477] Fix | Delete
[478] Fix | Delete
// Cleanup our hooks, in case something else does a upgrade on this connection.
[479] Fix | Delete
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
[480] Fix | Delete
remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) );
[481] Fix | Delete
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) );
[482] Fix | Delete
[483] Fix | Delete
// Ensure any future auto-update failures trigger a failure email by removing
[484] Fix | Delete
// the last failure notification from the list when themes update successfully.
[485] Fix | Delete
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
[486] Fix | Delete
[487] Fix | Delete
foreach ( $results as $theme => $result ) {
[488] Fix | Delete
// Maintain last failure notification when themes failed to update manually.
[489] Fix | Delete
if ( ! $result || is_wp_error( $result ) || ! isset( $past_failure_emails[ $theme ] ) ) {
[490] Fix | Delete
continue;
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
unset( $past_failure_emails[ $theme ] );
[494] Fix | Delete
}
[495] Fix | Delete
[496] Fix | Delete
update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );
[497] Fix | Delete
[498] Fix | Delete
return $results;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function