Edit File by line
/home/zeestwma/redstone.../wp-admin/includes
File: class-wp-automatic-updater.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Upgrade API: WP_Automatic_Updater 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 handling automatic background updates.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 3.7.0
[12] Fix | Delete
* @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader.php.
[13] Fix | Delete
*/
[14] Fix | Delete
#[AllowDynamicProperties]
[15] Fix | Delete
class WP_Automatic_Updater {
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Tracks update results during processing.
[19] Fix | Delete
*
[20] Fix | Delete
* @var array
[21] Fix | Delete
*/
[22] Fix | Delete
protected $update_results = array();
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Determines whether the entire automatic updater is disabled.
[26] Fix | Delete
*
[27] Fix | Delete
* @since 3.7.0
[28] Fix | Delete
*
[29] Fix | Delete
* @return bool True if the automatic updater is disabled, false otherwise.
[30] Fix | Delete
*/
[31] Fix | Delete
public function is_disabled() {
[32] Fix | Delete
// Background updates are disabled if you don't want file changes.
[33] Fix | Delete
if ( ! wp_is_file_mod_allowed( 'automatic_updater' ) ) {
[34] Fix | Delete
return true;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
if ( wp_installing() ) {
[38] Fix | Delete
return true;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
// More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters.
[42] Fix | Delete
$disabled = defined( 'AUTOMATIC_UPDATER_DISABLED' ) && AUTOMATIC_UPDATER_DISABLED;
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Filters whether to entirely disable background updates.
[46] Fix | Delete
*
[47] Fix | Delete
* There are more fine-grained filters and controls for selective disabling.
[48] Fix | Delete
* This filter parallels the AUTOMATIC_UPDATER_DISABLED constant in name.
[49] Fix | Delete
*
[50] Fix | Delete
* This also disables update notification emails. That may change in the future.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 3.7.0
[53] Fix | Delete
*
[54] Fix | Delete
* @param bool $disabled Whether the updater should be disabled.
[55] Fix | Delete
*/
[56] Fix | Delete
return apply_filters( 'automatic_updater_disabled', $disabled );
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Checks whether access to a given directory is allowed.
[61] Fix | Delete
*
[62] Fix | Delete
* This is used when detecting version control checkouts. Takes into account
[63] Fix | Delete
* the PHP `open_basedir` restrictions, so that WordPress does not try to access
[64] Fix | Delete
* directories it is not allowed to.
[65] Fix | Delete
*
[66] Fix | Delete
* @since 6.2.0
[67] Fix | Delete
*
[68] Fix | Delete
* @param string $dir The directory to check.
[69] Fix | Delete
* @return bool True if access to the directory is allowed, false otherwise.
[70] Fix | Delete
*/
[71] Fix | Delete
public function is_allowed_dir( $dir ) {
[72] Fix | Delete
if ( is_string( $dir ) ) {
[73] Fix | Delete
$dir = trim( $dir );
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
if ( ! is_string( $dir ) || '' === $dir ) {
[77] Fix | Delete
_doing_it_wrong(
[78] Fix | Delete
__METHOD__,
[79] Fix | Delete
sprintf(
[80] Fix | Delete
/* translators: %s: The "$dir" argument. */
[81] Fix | Delete
__( 'The "%s" argument must be a non-empty string.' ),
[82] Fix | Delete
'$dir'
[83] Fix | Delete
),
[84] Fix | Delete
'6.2.0'
[85] Fix | Delete
);
[86] Fix | Delete
[87] Fix | Delete
return false;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
$open_basedir = ini_get( 'open_basedir' );
[91] Fix | Delete
[92] Fix | Delete
if ( empty( $open_basedir ) ) {
[93] Fix | Delete
return true;
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
$open_basedir_list = explode( PATH_SEPARATOR, $open_basedir );
[97] Fix | Delete
[98] Fix | Delete
foreach ( $open_basedir_list as $basedir ) {
[99] Fix | Delete
if ( '' !== trim( $basedir ) && str_starts_with( $dir, $basedir ) ) {
[100] Fix | Delete
return true;
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
return false;
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Checks for version control checkouts.
[109] Fix | Delete
*
[110] Fix | Delete
* Checks for Subversion, Git, Mercurial, and Bazaar. It recursively looks up the
[111] Fix | Delete
* filesystem to the top of the drive, erring on the side of detecting a VCS
[112] Fix | Delete
* checkout somewhere.
[113] Fix | Delete
*
[114] Fix | Delete
* ABSPATH is always checked in addition to whatever `$context` is (which may be the
[115] Fix | Delete
* wp-content directory, for example). The underlying assumption is that if you are
[116] Fix | Delete
* using version control *anywhere*, then you should be making decisions for
[117] Fix | Delete
* how things get updated.
[118] Fix | Delete
*
[119] Fix | Delete
* @since 3.7.0
[120] Fix | Delete
*
[121] Fix | Delete
* @param string $context The filesystem path to check, in addition to ABSPATH.
[122] Fix | Delete
* @return bool True if a VCS checkout was discovered at `$context` or ABSPATH,
[123] Fix | Delete
* or anywhere higher. False otherwise.
[124] Fix | Delete
*/
[125] Fix | Delete
public function is_vcs_checkout( $context ) {
[126] Fix | Delete
$context_dirs = array( untrailingslashit( $context ) );
[127] Fix | Delete
if ( ABSPATH !== $context ) {
[128] Fix | Delete
$context_dirs[] = untrailingslashit( ABSPATH );
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
$vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
[132] Fix | Delete
$check_dirs = array();
[133] Fix | Delete
[134] Fix | Delete
foreach ( $context_dirs as $context_dir ) {
[135] Fix | Delete
// Walk up from $context_dir to the root.
[136] Fix | Delete
do {
[137] Fix | Delete
$check_dirs[] = $context_dir;
[138] Fix | Delete
[139] Fix | Delete
// Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
[140] Fix | Delete
if ( dirname( $context_dir ) === $context_dir ) {
[141] Fix | Delete
break;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
// Continue one level at a time.
[145] Fix | Delete
} while ( $context_dir = dirname( $context_dir ) );
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
$check_dirs = array_unique( $check_dirs );
[149] Fix | Delete
$checkout = false;
[150] Fix | Delete
[151] Fix | Delete
// Search all directories we've found for evidence of version control.
[152] Fix | Delete
foreach ( $vcs_dirs as $vcs_dir ) {
[153] Fix | Delete
foreach ( $check_dirs as $check_dir ) {
[154] Fix | Delete
if ( ! $this->is_allowed_dir( $check_dir ) ) {
[155] Fix | Delete
continue;
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
$checkout = is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
[159] Fix | Delete
if ( $checkout ) {
[160] Fix | Delete
break 2;
[161] Fix | Delete
}
[162] Fix | Delete
}
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
* Filters whether the automatic updater should consider a filesystem
[167] Fix | Delete
* location to be potentially managed by a version control system.
[168] Fix | Delete
*
[169] Fix | Delete
* @since 3.7.0
[170] Fix | Delete
*
[171] Fix | Delete
* @param bool $checkout Whether a VCS checkout was discovered at `$context`
[172] Fix | Delete
* or ABSPATH, or anywhere higher.
[173] Fix | Delete
* @param string $context The filesystem context (a path) against which
[174] Fix | Delete
* filesystem status should be checked.
[175] Fix | Delete
*/
[176] Fix | Delete
return apply_filters( 'automatic_updates_is_vcs_checkout', $checkout, $context );
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Tests to see if we can and should update a specific item.
[181] Fix | Delete
*
[182] Fix | Delete
* @since 3.7.0
[183] Fix | Delete
*
[184] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[185] Fix | Delete
*
[186] Fix | Delete
* @param string $type The type of update being checked: 'core', 'theme',
[187] Fix | Delete
* 'plugin', 'translation'.
[188] Fix | Delete
* @param object $item The update offer.
[189] Fix | Delete
* @param string $context The filesystem context (a path) against which filesystem
[190] Fix | Delete
* access and status should be checked.
[191] Fix | Delete
* @return bool True if the item should be updated, false otherwise.
[192] Fix | Delete
*/
[193] Fix | Delete
public function should_update( $type, $item, $context ) {
[194] Fix | Delete
// Used to see if WP_Filesystem is set up to allow unattended updates.
[195] Fix | Delete
$skin = new Automatic_Upgrader_Skin();
[196] Fix | Delete
[197] Fix | Delete
if ( $this->is_disabled() ) {
[198] Fix | Delete
return false;
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
// Only relax the filesystem checks when the update doesn't include new files.
[202] Fix | Delete
$allow_relaxed_file_ownership = false;
[203] Fix | Delete
if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
[204] Fix | Delete
$allow_relaxed_file_ownership = true;
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
// If we can't do an auto core update, we may still be able to email the user.
[208] Fix | Delete
if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership )
[209] Fix | Delete
|| $this->is_vcs_checkout( $context )
[210] Fix | Delete
) {
[211] Fix | Delete
if ( 'core' === $type ) {
[212] Fix | Delete
$this->send_core_update_notification_email( $item );
[213] Fix | Delete
}
[214] Fix | Delete
return false;
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
// Next up, is this an item we can update?
[218] Fix | Delete
if ( 'core' === $type ) {
[219] Fix | Delete
$update = Core_Upgrader::should_update_to_version( $item->current );
[220] Fix | Delete
} elseif ( 'plugin' === $type || 'theme' === $type ) {
[221] Fix | Delete
$update = ! empty( $item->autoupdate );
[222] Fix | Delete
[223] Fix | Delete
if ( ! $update && wp_is_auto_update_enabled_for_type( $type ) ) {
[224] Fix | Delete
// Check if the site admin has enabled auto-updates by default for the specific item.
[225] Fix | Delete
$auto_updates = (array) get_site_option( "auto_update_{$type}s", array() );
[226] Fix | Delete
$update = in_array( $item->{$type}, $auto_updates, true );
[227] Fix | Delete
}
[228] Fix | Delete
} else {
[229] Fix | Delete
$update = ! empty( $item->autoupdate );
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
// If the `disable_autoupdate` flag is set, override any user-choice, but allow filters.
[233] Fix | Delete
if ( ! empty( $item->disable_autoupdate ) ) {
[234] Fix | Delete
$update = false;
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
/**
[238] Fix | Delete
* Filters whether to automatically update core, a plugin, a theme, or a language.
[239] Fix | Delete
*
[240] Fix | Delete
* The dynamic portion of the hook name, `$type`, refers to the type of update
[241] Fix | Delete
* being checked.
[242] Fix | Delete
*
[243] Fix | Delete
* Possible hook names include:
[244] Fix | Delete
*
[245] Fix | Delete
* - `auto_update_core`
[246] Fix | Delete
* - `auto_update_plugin`
[247] Fix | Delete
* - `auto_update_theme`
[248] Fix | Delete
* - `auto_update_translation`
[249] Fix | Delete
*
[250] Fix | Delete
* Since WordPress 3.7, minor and development versions of core, and translations have
[251] Fix | Delete
* been auto-updated by default. New installs on WordPress 5.6 or higher will also
[252] Fix | Delete
* auto-update major versions by default. Starting in 5.6, older sites can opt-in to
[253] Fix | Delete
* major version auto-updates, and auto-updates for plugins and themes.
[254] Fix | Delete
*
[255] Fix | Delete
* See the {@see 'allow_dev_auto_core_updates'}, {@see 'allow_minor_auto_core_updates'},
[256] Fix | Delete
* and {@see 'allow_major_auto_core_updates'} filters for a more straightforward way to
[257] Fix | Delete
* adjust core updates.
[258] Fix | Delete
*
[259] Fix | Delete
* @since 3.7.0
[260] Fix | Delete
* @since 5.5.0 The `$update` parameter accepts the value of null.
[261] Fix | Delete
*
[262] Fix | Delete
* @param bool|null $update Whether to update. The value of null is internally used
[263] Fix | Delete
* to detect whether nothing has hooked into this filter.
[264] Fix | Delete
* @param object $item The update offer.
[265] Fix | Delete
*/
[266] Fix | Delete
$update = apply_filters( "auto_update_{$type}", $update, $item );
[267] Fix | Delete
[268] Fix | Delete
if ( ! $update ) {
[269] Fix | Delete
if ( 'core' === $type ) {
[270] Fix | Delete
$this->send_core_update_notification_email( $item );
[271] Fix | Delete
}
[272] Fix | Delete
return false;
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
// If it's a core update, are we actually compatible with its requirements?
[276] Fix | Delete
if ( 'core' === $type ) {
[277] Fix | Delete
global $wpdb;
[278] Fix | Delete
[279] Fix | Delete
$php_compat = version_compare( PHP_VERSION, $item->php_version, '>=' );
[280] Fix | Delete
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
[281] Fix | Delete
$mysql_compat = true;
[282] Fix | Delete
} else {
[283] Fix | Delete
$mysql_compat = version_compare( $wpdb->db_version(), $item->mysql_version, '>=' );
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
if ( ! $php_compat || ! $mysql_compat ) {
[287] Fix | Delete
return false;
[288] Fix | Delete
}
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
// If updating a plugin or theme, ensure the minimum PHP version requirements are satisfied.
[292] Fix | Delete
if ( in_array( $type, array( 'plugin', 'theme' ), true ) ) {
[293] Fix | Delete
if ( ! empty( $item->requires_php ) && version_compare( PHP_VERSION, $item->requires_php, '<' ) ) {
[294] Fix | Delete
return false;
[295] Fix | Delete
}
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
return true;
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
/**
[302] Fix | Delete
* Notifies an administrator of a core update.
[303] Fix | Delete
*
[304] Fix | Delete
* @since 3.7.0
[305] Fix | Delete
*
[306] Fix | Delete
* @param object $item The update offer.
[307] Fix | Delete
* @return bool True if the site administrator is notified of a core update,
[308] Fix | Delete
* false otherwise.
[309] Fix | Delete
*/
[310] Fix | Delete
protected function send_core_update_notification_email( $item ) {
[311] Fix | Delete
$notified = get_site_option( 'auto_core_update_notified' );
[312] Fix | Delete
[313] Fix | Delete
// Don't notify if we've already notified the same email address of the same version.
[314] Fix | Delete
if ( $notified
[315] Fix | Delete
&& get_site_option( 'admin_email' ) === $notified['email']
[316] Fix | Delete
&& $notified['version'] === $item->current
[317] Fix | Delete
) {
[318] Fix | Delete
return false;
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
// See if we need to notify users of a core update.
[322] Fix | Delete
$notify = ! empty( $item->notify_email );
[323] Fix | Delete
[324] Fix | Delete
/**
[325] Fix | Delete
* Filters whether to notify the site administrator of a new core update.
[326] Fix | Delete
*
[327] Fix | Delete
* By default, administrators are notified when the update offer received
[328] Fix | Delete
* from WordPress.org sets a particular flag. This allows some discretion
[329] Fix | Delete
* in if and when to notify.
[330] Fix | Delete
*
[331] Fix | Delete
* This filter is only evaluated once per release. If the same email address
[332] Fix | Delete
* was already notified of the same new version, WordPress won't repeatedly
[333] Fix | Delete
* email the administrator.
[334] Fix | Delete
*
[335] Fix | Delete
* This filter is also used on about.php to check if a plugin has disabled
[336] Fix | Delete
* these notifications.
[337] Fix | Delete
*
[338] Fix | Delete
* @since 3.7.0
[339] Fix | Delete
*
[340] Fix | Delete
* @param bool $notify Whether the site administrator is notified.
[341] Fix | Delete
* @param object $item The update offer.
[342] Fix | Delete
*/
[343] Fix | Delete
if ( ! apply_filters( 'send_core_update_notification_email', $notify, $item ) ) {
[344] Fix | Delete
return false;
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
$this->send_email( 'manual', $item );
[348] Fix | Delete
return true;
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
/**
[352] Fix | Delete
* Updates an item, if appropriate.
[353] Fix | Delete
*
[354] Fix | Delete
* @since 3.7.0
[355] Fix | Delete
*
[356] Fix | Delete
* @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'.
[357] Fix | Delete
* @param object $item The update offer.
[358] Fix | Delete
* @return null|WP_Error
[359] Fix | Delete
*/
[360] Fix | Delete
public function update( $type, $item ) {
[361] Fix | Delete
$skin = new Automatic_Upgrader_Skin();
[362] Fix | Delete
[363] Fix | Delete
switch ( $type ) {
[364] Fix | Delete
case 'core':
[365] Fix | Delete
// The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter.
[366] Fix | Delete
add_filter( 'update_feedback', array( $skin, 'feedback' ) );
[367] Fix | Delete
$upgrader = new Core_Upgrader( $skin );
[368] Fix | Delete
$context = ABSPATH;
[369] Fix | Delete
break;
[370] Fix | Delete
case 'plugin':
[371] Fix | Delete
$upgrader = new Plugin_Upgrader( $skin );
[372] Fix | Delete
$context = WP_PLUGIN_DIR; // We don't support custom Plugin directories, or updates for WPMU_PLUGIN_DIR.
[373] Fix | Delete
break;
[374] Fix | Delete
case 'theme':
[375] Fix | Delete
$upgrader = new Theme_Upgrader( $skin );
[376] Fix | Delete
$context = get_theme_root( $item->theme );
[377] Fix | Delete
break;
[378] Fix | Delete
case 'translation':
[379] Fix | Delete
$upgrader = new Language_Pack_Upgrader( $skin );
[380] Fix | Delete
$context = WP_CONTENT_DIR; // WP_LANG_DIR;
[381] Fix | Delete
break;
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
// Determine whether we can and should perform this update.
[385] Fix | Delete
if ( ! $this->should_update( $type, $item, $context ) ) {
[386] Fix | Delete
return false;
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
/**
[390] Fix | Delete
* Fires immediately prior to an auto-update.
[391] Fix | Delete
*
[392] Fix | Delete
* @since 4.4.0
[393] Fix | Delete
*
[394] Fix | Delete
* @param string $type The type of update being checked: 'core', 'theme', 'plugin', or 'translation'.
[395] Fix | Delete
* @param object $item The update offer.
[396] Fix | Delete
* @param string $context The filesystem context (a path) against which filesystem access and status
[397] Fix | Delete
* should be checked.
[398] Fix | Delete
*/
[399] Fix | Delete
do_action( 'pre_auto_update', $type, $item, $context );
[400] Fix | Delete
[401] Fix | Delete
$upgrader_item = $item;
[402] Fix | Delete
switch ( $type ) {
[403] Fix | Delete
case 'core':
[404] Fix | Delete
/* translators: %s: WordPress version. */
[405] Fix | Delete
$skin->feedback( __( 'Updating to WordPress %s' ), $item->version );
[406] Fix | Delete
/* translators: %s: WordPress version. */
[407] Fix | Delete
$item_name = sprintf( __( 'WordPress %s' ), $item->version );
[408] Fix | Delete
break;
[409] Fix | Delete
case 'theme':
[410] Fix | Delete
$upgrader_item = $item->theme;
[411] Fix | Delete
$theme = wp_get_theme( $upgrader_item );
[412] Fix | Delete
$item_name = $theme->get( 'Name' );
[413] Fix | Delete
// Add the current version so that it can be reported in the notification email.
[414] Fix | Delete
$item->current_version = $theme->get( 'Version' );
[415] Fix | Delete
if ( empty( $item->current_version ) ) {
[416] Fix | Delete
$item->current_version = false;
[417] Fix | Delete
}
[418] Fix | Delete
/* translators: %s: Theme name. */
[419] Fix | Delete
$skin->feedback( __( 'Updating theme: %s' ), $item_name );
[420] Fix | Delete
break;
[421] Fix | Delete
case 'plugin':
[422] Fix | Delete
$upgrader_item = $item->plugin;
[423] Fix | Delete
$plugin_data = get_plugin_data( $context . '/' . $upgrader_item );
[424] Fix | Delete
$item_name = $plugin_data['Name'];
[425] Fix | Delete
// Add the current version so that it can be reported in the notification email.
[426] Fix | Delete
$item->current_version = $plugin_data['Version'];
[427] Fix | Delete
if ( empty( $item->current_version ) ) {
[428] Fix | Delete
$item->current_version = false;
[429] Fix | Delete
}
[430] Fix | Delete
/* translators: %s: Plugin name. */
[431] Fix | Delete
$skin->feedback( __( 'Updating plugin: %s' ), $item_name );
[432] Fix | Delete
break;
[433] Fix | Delete
case 'translation':
[434] Fix | Delete
$language_item_name = $upgrader->get_name_for_update( $item );
[435] Fix | Delete
/* translators: %s: Project name (plugin, theme, or WordPress). */
[436] Fix | Delete
$item_name = sprintf( __( 'Translations for %s' ), $language_item_name );
[437] Fix | Delete
/* translators: 1: Project name (plugin, theme, or WordPress), 2: Language. */
[438] Fix | Delete
$skin->feedback( sprintf( __( 'Updating translations for %1$s (%2$s)&#8230;' ), $language_item_name, $item->language ) );
[439] Fix | Delete
break;
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
$allow_relaxed_file_ownership = false;
[443] Fix | Delete
if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
[444] Fix | Delete
$allow_relaxed_file_ownership = true;
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
$is_debug = WP_DEBUG && WP_DEBUG_LOG;
[448] Fix | Delete
if ( 'plugin' === $type ) {
[449] Fix | Delete
$was_active = is_plugin_active( $upgrader_item );
[450] Fix | Delete
if ( $is_debug ) {
[451] Fix | Delete
error_log( ' Upgrading plugin ' . var_export( $item->slug, true ) . '...' );
[452] Fix | Delete
}
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
if ( 'theme' === $type && $is_debug ) {
[456] Fix | Delete
error_log( ' Upgrading theme ' . var_export( $item->theme, true ) . '...' );
[457] Fix | Delete
}
[458] Fix | Delete
[459] Fix | Delete
/*
[460] Fix | Delete
* Enable maintenance mode before upgrading the plugin or theme.
[461] Fix | Delete
*
[462] Fix | Delete
* This avoids potential non-fatal errors being detected
[463] Fix | Delete
* while scraping for a fatal error if some files are still
[464] Fix | Delete
* being moved.
[465] Fix | Delete
*
[466] Fix | Delete
* While these checks are intended only for plugins,
[467] Fix | Delete
* maintenance mode is enabled for all upgrade types as any
[468] Fix | Delete
* update could contain an error or warning, which could cause
[469] Fix | Delete
* the scrape to miss a fatal error in the plugin update.
[470] Fix | Delete
*/
[471] Fix | Delete
if ( 'translation' !== $type ) {
[472] Fix | Delete
$upgrader->maintenance_mode( true );
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
// Boom, this site's about to get a whole new splash of paint!
[476] Fix | Delete
$upgrade_result = $upgrader->upgrade(
[477] Fix | Delete
$upgrader_item,
[478] Fix | Delete
array(
[479] Fix | Delete
'clear_update_cache' => false,
[480] Fix | Delete
// Always use partial builds if possible for core updates.
[481] Fix | Delete
'pre_check_md5' => false,
[482] Fix | Delete
// Only available for core updates.
[483] Fix | Delete
'attempt_rollback' => true,
[484] Fix | Delete
// Allow relaxed file ownership in some scenarios.
[485] Fix | Delete
'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
[486] Fix | Delete
)
[487] Fix | Delete
);
[488] Fix | Delete
[489] Fix | Delete
/*
[490] Fix | Delete
* After WP_Upgrader::upgrade() completes, maintenance mode is disabled.
[491] Fix | Delete
*
[492] Fix | Delete
* Re-enable maintenance mode while attempting to detect fatal errors
[493] Fix | Delete
* and potentially rolling back.
[494] Fix | Delete
*
[495] Fix | Delete
* This avoids errors if the site is visited while fatal errors exist
[496] Fix | Delete
* or while files are still being moved.
[497] Fix | Delete
*/
[498] Fix | Delete
if ( 'translation' !== $type ) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function