Edit File by line
/home/barbar84/www/wp-inclu...
File: update.php
'Version' => $theme->get( 'Version' ),
[500] Fix | Delete
'Author' => $theme->get( 'Author' ),
[501] Fix | Delete
'Author URI' => $theme->get( 'AuthorURI' ),
[502] Fix | Delete
'Template' => $theme->get_template(),
[503] Fix | Delete
'Stylesheet' => $theme->get_stylesheet(),
[504] Fix | Delete
);
[505] Fix | Delete
}
[506] Fix | Delete
[507] Fix | Delete
$doing_cron = wp_doing_cron();
[508] Fix | Delete
[509] Fix | Delete
// Check for update on a different schedule, depending on the page.
[510] Fix | Delete
switch ( current_filter() ) {
[511] Fix | Delete
case 'upgrader_process_complete':
[512] Fix | Delete
$timeout = 0;
[513] Fix | Delete
break;
[514] Fix | Delete
case 'load-update-core.php':
[515] Fix | Delete
$timeout = MINUTE_IN_SECONDS;
[516] Fix | Delete
break;
[517] Fix | Delete
case 'load-themes.php':
[518] Fix | Delete
case 'load-update.php':
[519] Fix | Delete
$timeout = HOUR_IN_SECONDS;
[520] Fix | Delete
break;
[521] Fix | Delete
default:
[522] Fix | Delete
if ( $doing_cron ) {
[523] Fix | Delete
$timeout = 2 * HOUR_IN_SECONDS;
[524] Fix | Delete
} else {
[525] Fix | Delete
$timeout = 12 * HOUR_IN_SECONDS;
[526] Fix | Delete
}
[527] Fix | Delete
}
[528] Fix | Delete
[529] Fix | Delete
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
[530] Fix | Delete
[531] Fix | Delete
if ( $time_not_changed && ! $extra_stats ) {
[532] Fix | Delete
$theme_changed = false;
[533] Fix | Delete
[534] Fix | Delete
foreach ( $checked as $slug => $v ) {
[535] Fix | Delete
if ( ! isset( $last_update->checked[ $slug ] ) || (string) $last_update->checked[ $slug ] !== (string) $v ) {
[536] Fix | Delete
$theme_changed = true;
[537] Fix | Delete
}
[538] Fix | Delete
}
[539] Fix | Delete
[540] Fix | Delete
if ( isset( $last_update->response ) && is_array( $last_update->response ) ) {
[541] Fix | Delete
foreach ( $last_update->response as $slug => $update_details ) {
[542] Fix | Delete
if ( ! isset( $checked[ $slug ] ) ) {
[543] Fix | Delete
$theme_changed = true;
[544] Fix | Delete
break;
[545] Fix | Delete
}
[546] Fix | Delete
}
[547] Fix | Delete
}
[548] Fix | Delete
[549] Fix | Delete
// Bail if we've checked recently and if nothing has changed.
[550] Fix | Delete
if ( ! $theme_changed ) {
[551] Fix | Delete
return;
[552] Fix | Delete
}
[553] Fix | Delete
}
[554] Fix | Delete
[555] Fix | Delete
// Update last_checked for current to prevent multiple blocking requests if request hangs.
[556] Fix | Delete
$last_update->last_checked = time();
[557] Fix | Delete
set_site_transient( 'update_themes', $last_update );
[558] Fix | Delete
[559] Fix | Delete
$request['themes'] = $themes;
[560] Fix | Delete
[561] Fix | Delete
$locales = array_values( get_available_languages() );
[562] Fix | Delete
[563] Fix | Delete
/**
[564] Fix | Delete
* Filters the locales requested for theme translations.
[565] Fix | Delete
*
[566] Fix | Delete
* @since 3.7.0
[567] Fix | Delete
* @since 4.5.0 The default value of the `$locales` parameter changed to include all locales.
[568] Fix | Delete
*
[569] Fix | Delete
* @param array $locales Theme locales. Default is all available locales of the site.
[570] Fix | Delete
*/
[571] Fix | Delete
$locales = apply_filters( 'themes_update_check_locales', $locales );
[572] Fix | Delete
$locales = array_unique( $locales );
[573] Fix | Delete
[574] Fix | Delete
if ( $doing_cron ) {
[575] Fix | Delete
$timeout = 30;
[576] Fix | Delete
} else {
[577] Fix | Delete
// Three seconds, plus one extra second for every 10 themes.
[578] Fix | Delete
$timeout = 3 + (int) ( count( $themes ) / 10 );
[579] Fix | Delete
}
[580] Fix | Delete
[581] Fix | Delete
$options = array(
[582] Fix | Delete
'timeout' => $timeout,
[583] Fix | Delete
'body' => array(
[584] Fix | Delete
'themes' => wp_json_encode( $request ),
[585] Fix | Delete
'translations' => wp_json_encode( $translations ),
[586] Fix | Delete
'locale' => wp_json_encode( $locales ),
[587] Fix | Delete
),
[588] Fix | Delete
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
[589] Fix | Delete
);
[590] Fix | Delete
[591] Fix | Delete
if ( $extra_stats ) {
[592] Fix | Delete
$options['body']['update_stats'] = wp_json_encode( $extra_stats );
[593] Fix | Delete
}
[594] Fix | Delete
[595] Fix | Delete
$url = 'http://api.wordpress.org/themes/update-check/1.1/';
[596] Fix | Delete
$http_url = $url;
[597] Fix | Delete
$ssl = wp_http_supports( array( 'ssl' ) );
[598] Fix | Delete
[599] Fix | Delete
if ( $ssl ) {
[600] Fix | Delete
$url = set_url_scheme( $url, 'https' );
[601] Fix | Delete
}
[602] Fix | Delete
[603] Fix | Delete
$raw_response = wp_remote_post( $url, $options );
[604] Fix | Delete
[605] Fix | Delete
if ( $ssl && is_wp_error( $raw_response ) ) {
[606] Fix | Delete
trigger_error(
[607] Fix | Delete
sprintf(
[608] Fix | Delete
/* translators: %s: Support forums URL. */
[609] Fix | Delete
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
[610] Fix | Delete
__( 'https://wordpress.org/support/forums/' )
[611] Fix | Delete
) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
[612] Fix | Delete
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
[613] Fix | Delete
);
[614] Fix | Delete
$raw_response = wp_remote_post( $http_url, $options );
[615] Fix | Delete
}
[616] Fix | Delete
[617] Fix | Delete
if ( is_wp_error( $raw_response ) || 200 !== wp_remote_retrieve_response_code( $raw_response ) ) {
[618] Fix | Delete
return;
[619] Fix | Delete
}
[620] Fix | Delete
[621] Fix | Delete
$new_update = new stdClass;
[622] Fix | Delete
$new_update->last_checked = time();
[623] Fix | Delete
$new_update->checked = $checked;
[624] Fix | Delete
[625] Fix | Delete
$response = json_decode( wp_remote_retrieve_body( $raw_response ), true );
[626] Fix | Delete
[627] Fix | Delete
if ( is_array( $response ) ) {
[628] Fix | Delete
$new_update->response = $response['themes'];
[629] Fix | Delete
$new_update->no_update = $response['no_update'];
[630] Fix | Delete
$new_update->translations = $response['translations'];
[631] Fix | Delete
}
[632] Fix | Delete
[633] Fix | Delete
set_site_transient( 'update_themes', $new_update );
[634] Fix | Delete
}
[635] Fix | Delete
[636] Fix | Delete
/**
[637] Fix | Delete
* Performs WordPress automatic background updates.
[638] Fix | Delete
*
[639] Fix | Delete
* Updates WordPress core plus any plugins and themes that have automatic updates enabled.
[640] Fix | Delete
*
[641] Fix | Delete
* @since 3.7.0
[642] Fix | Delete
*/
[643] Fix | Delete
function wp_maybe_auto_update() {
[644] Fix | Delete
include_once ABSPATH . 'wp-admin/includes/admin.php';
[645] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
[646] Fix | Delete
[647] Fix | Delete
$upgrader = new WP_Automatic_Updater;
[648] Fix | Delete
$upgrader->run();
[649] Fix | Delete
}
[650] Fix | Delete
[651] Fix | Delete
/**
[652] Fix | Delete
* Retrieves a list of all language updates available.
[653] Fix | Delete
*
[654] Fix | Delete
* @since 3.7.0
[655] Fix | Delete
*
[656] Fix | Delete
* @return object[] Array of translation objects that have available updates.
[657] Fix | Delete
*/
[658] Fix | Delete
function wp_get_translation_updates() {
[659] Fix | Delete
$updates = array();
[660] Fix | Delete
$transients = array(
[661] Fix | Delete
'update_core' => 'core',
[662] Fix | Delete
'update_plugins' => 'plugin',
[663] Fix | Delete
'update_themes' => 'theme',
[664] Fix | Delete
);
[665] Fix | Delete
[666] Fix | Delete
foreach ( $transients as $transient => $type ) {
[667] Fix | Delete
$transient = get_site_transient( $transient );
[668] Fix | Delete
[669] Fix | Delete
if ( empty( $transient->translations ) ) {
[670] Fix | Delete
continue;
[671] Fix | Delete
}
[672] Fix | Delete
[673] Fix | Delete
foreach ( $transient->translations as $translation ) {
[674] Fix | Delete
$updates[] = (object) $translation;
[675] Fix | Delete
}
[676] Fix | Delete
}
[677] Fix | Delete
[678] Fix | Delete
return $updates;
[679] Fix | Delete
}
[680] Fix | Delete
[681] Fix | Delete
/**
[682] Fix | Delete
* Collect counts and UI strings for available updates
[683] Fix | Delete
*
[684] Fix | Delete
* @since 3.3.0
[685] Fix | Delete
*
[686] Fix | Delete
* @return array
[687] Fix | Delete
*/
[688] Fix | Delete
function wp_get_update_data() {
[689] Fix | Delete
$counts = array(
[690] Fix | Delete
'plugins' => 0,
[691] Fix | Delete
'themes' => 0,
[692] Fix | Delete
'wordpress' => 0,
[693] Fix | Delete
'translations' => 0,
[694] Fix | Delete
);
[695] Fix | Delete
[696] Fix | Delete
$plugins = current_user_can( 'update_plugins' );
[697] Fix | Delete
[698] Fix | Delete
if ( $plugins ) {
[699] Fix | Delete
$update_plugins = get_site_transient( 'update_plugins' );
[700] Fix | Delete
[701] Fix | Delete
if ( ! empty( $update_plugins->response ) ) {
[702] Fix | Delete
$counts['plugins'] = count( $update_plugins->response );
[703] Fix | Delete
}
[704] Fix | Delete
}
[705] Fix | Delete
[706] Fix | Delete
$themes = current_user_can( 'update_themes' );
[707] Fix | Delete
[708] Fix | Delete
if ( $themes ) {
[709] Fix | Delete
$update_themes = get_site_transient( 'update_themes' );
[710] Fix | Delete
[711] Fix | Delete
if ( ! empty( $update_themes->response ) ) {
[712] Fix | Delete
$counts['themes'] = count( $update_themes->response );
[713] Fix | Delete
}
[714] Fix | Delete
}
[715] Fix | Delete
[716] Fix | Delete
$core = current_user_can( 'update_core' );
[717] Fix | Delete
[718] Fix | Delete
if ( $core && function_exists( 'get_core_updates' ) ) {
[719] Fix | Delete
$update_wordpress = get_core_updates( array( 'dismissed' => false ) );
[720] Fix | Delete
[721] Fix | Delete
if ( ! empty( $update_wordpress )
[722] Fix | Delete
&& ! in_array( $update_wordpress[0]->response, array( 'development', 'latest' ), true )
[723] Fix | Delete
&& current_user_can( 'update_core' )
[724] Fix | Delete
) {
[725] Fix | Delete
$counts['wordpress'] = 1;
[726] Fix | Delete
}
[727] Fix | Delete
}
[728] Fix | Delete
[729] Fix | Delete
if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() ) {
[730] Fix | Delete
$counts['translations'] = 1;
[731] Fix | Delete
}
[732] Fix | Delete
[733] Fix | Delete
$counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'] + $counts['translations'];
[734] Fix | Delete
$titles = array();
[735] Fix | Delete
[736] Fix | Delete
if ( $counts['wordpress'] ) {
[737] Fix | Delete
/* translators: %d: Number of available WordPress updates. */
[738] Fix | Delete
$titles['wordpress'] = sprintf( __( '%d WordPress Update' ), $counts['wordpress'] );
[739] Fix | Delete
}
[740] Fix | Delete
[741] Fix | Delete
if ( $counts['plugins'] ) {
[742] Fix | Delete
/* translators: %d: Number of available plugin updates. */
[743] Fix | Delete
$titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] );
[744] Fix | Delete
}
[745] Fix | Delete
[746] Fix | Delete
if ( $counts['themes'] ) {
[747] Fix | Delete
/* translators: %d: Number of available theme updates. */
[748] Fix | Delete
$titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] );
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
if ( $counts['translations'] ) {
[752] Fix | Delete
$titles['translations'] = __( 'Translation Updates' );
[753] Fix | Delete
}
[754] Fix | Delete
[755] Fix | Delete
$update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : '';
[756] Fix | Delete
[757] Fix | Delete
$update_data = array(
[758] Fix | Delete
'counts' => $counts,
[759] Fix | Delete
'title' => $update_title,
[760] Fix | Delete
);
[761] Fix | Delete
/**
[762] Fix | Delete
* Filters the returned array of update data for plugins, themes, and WordPress core.
[763] Fix | Delete
*
[764] Fix | Delete
* @since 3.5.0
[765] Fix | Delete
*
[766] Fix | Delete
* @param array $update_data {
[767] Fix | Delete
* Fetched update data.
[768] Fix | Delete
*
[769] Fix | Delete
* @type array $counts An array of counts for available plugin, theme, and WordPress updates.
[770] Fix | Delete
* @type string $update_title Titles of available updates.
[771] Fix | Delete
* }
[772] Fix | Delete
* @param array $titles An array of update counts and UI strings for available updates.
[773] Fix | Delete
*/
[774] Fix | Delete
return apply_filters( 'wp_get_update_data', $update_data, $titles );
[775] Fix | Delete
}
[776] Fix | Delete
[777] Fix | Delete
/**
[778] Fix | Delete
* Determines whether core should be updated.
[779] Fix | Delete
*
[780] Fix | Delete
* @since 2.8.0
[781] Fix | Delete
*
[782] Fix | Delete
* @global string $wp_version The WordPress version string.
[783] Fix | Delete
*/
[784] Fix | Delete
function _maybe_update_core() {
[785] Fix | Delete
// Include an unmodified $wp_version.
[786] Fix | Delete
require ABSPATH . WPINC . '/version.php';
[787] Fix | Delete
[788] Fix | Delete
$current = get_site_transient( 'update_core' );
[789] Fix | Delete
[790] Fix | Delete
if ( isset( $current->last_checked, $current->version_checked )
[791] Fix | Delete
&& 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked )
[792] Fix | Delete
&& $current->version_checked === $wp_version
[793] Fix | Delete
) {
[794] Fix | Delete
return;
[795] Fix | Delete
}
[796] Fix | Delete
[797] Fix | Delete
wp_version_check();
[798] Fix | Delete
}
[799] Fix | Delete
/**
[800] Fix | Delete
* Check the last time plugins were run before checking plugin versions.
[801] Fix | Delete
*
[802] Fix | Delete
* This might have been backported to WordPress 2.6.1 for performance reasons.
[803] Fix | Delete
* This is used for the wp-admin to check only so often instead of every page
[804] Fix | Delete
* load.
[805] Fix | Delete
*
[806] Fix | Delete
* @since 2.7.0
[807] Fix | Delete
* @access private
[808] Fix | Delete
*/
[809] Fix | Delete
function _maybe_update_plugins() {
[810] Fix | Delete
$current = get_site_transient( 'update_plugins' );
[811] Fix | Delete
[812] Fix | Delete
if ( isset( $current->last_checked )
[813] Fix | Delete
&& 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked )
[814] Fix | Delete
) {
[815] Fix | Delete
return;
[816] Fix | Delete
}
[817] Fix | Delete
[818] Fix | Delete
wp_update_plugins();
[819] Fix | Delete
}
[820] Fix | Delete
[821] Fix | Delete
/**
[822] Fix | Delete
* Check themes versions only after a duration of time.
[823] Fix | Delete
*
[824] Fix | Delete
* This is for performance reasons to make sure that on the theme version
[825] Fix | Delete
* checker is not run on every page load.
[826] Fix | Delete
*
[827] Fix | Delete
* @since 2.7.0
[828] Fix | Delete
* @access private
[829] Fix | Delete
*/
[830] Fix | Delete
function _maybe_update_themes() {
[831] Fix | Delete
$current = get_site_transient( 'update_themes' );
[832] Fix | Delete
[833] Fix | Delete
if ( isset( $current->last_checked )
[834] Fix | Delete
&& 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked )
[835] Fix | Delete
) {
[836] Fix | Delete
return;
[837] Fix | Delete
}
[838] Fix | Delete
[839] Fix | Delete
wp_update_themes();
[840] Fix | Delete
}
[841] Fix | Delete
[842] Fix | Delete
/**
[843] Fix | Delete
* Schedule core, theme, and plugin update checks.
[844] Fix | Delete
*
[845] Fix | Delete
* @since 3.1.0
[846] Fix | Delete
*/
[847] Fix | Delete
function wp_schedule_update_checks() {
[848] Fix | Delete
if ( ! wp_next_scheduled( 'wp_version_check' ) && ! wp_installing() ) {
[849] Fix | Delete
wp_schedule_event( time(), 'twicedaily', 'wp_version_check' );
[850] Fix | Delete
}
[851] Fix | Delete
[852] Fix | Delete
if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() ) {
[853] Fix | Delete
wp_schedule_event( time(), 'twicedaily', 'wp_update_plugins' );
[854] Fix | Delete
}
[855] Fix | Delete
[856] Fix | Delete
if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() ) {
[857] Fix | Delete
wp_schedule_event( time(), 'twicedaily', 'wp_update_themes' );
[858] Fix | Delete
}
[859] Fix | Delete
}
[860] Fix | Delete
[861] Fix | Delete
/**
[862] Fix | Delete
* Clear existing update caches for plugins, themes, and core.
[863] Fix | Delete
*
[864] Fix | Delete
* @since 4.1.0
[865] Fix | Delete
*/
[866] Fix | Delete
function wp_clean_update_cache() {
[867] Fix | Delete
if ( function_exists( 'wp_clean_plugins_cache' ) ) {
[868] Fix | Delete
wp_clean_plugins_cache();
[869] Fix | Delete
} else {
[870] Fix | Delete
delete_site_transient( 'update_plugins' );
[871] Fix | Delete
}
[872] Fix | Delete
[873] Fix | Delete
wp_clean_themes_cache();
[874] Fix | Delete
[875] Fix | Delete
delete_site_transient( 'update_core' );
[876] Fix | Delete
}
[877] Fix | Delete
[878] Fix | Delete
if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) {
[879] Fix | Delete
return;
[880] Fix | Delete
}
[881] Fix | Delete
[882] Fix | Delete
add_action( 'admin_init', '_maybe_update_core' );
[883] Fix | Delete
add_action( 'wp_version_check', 'wp_version_check' );
[884] Fix | Delete
[885] Fix | Delete
add_action( 'load-plugins.php', 'wp_update_plugins' );
[886] Fix | Delete
add_action( 'load-update.php', 'wp_update_plugins' );
[887] Fix | Delete
add_action( 'load-update-core.php', 'wp_update_plugins' );
[888] Fix | Delete
add_action( 'admin_init', '_maybe_update_plugins' );
[889] Fix | Delete
add_action( 'wp_update_plugins', 'wp_update_plugins' );
[890] Fix | Delete
[891] Fix | Delete
add_action( 'load-themes.php', 'wp_update_themes' );
[892] Fix | Delete
add_action( 'load-update.php', 'wp_update_themes' );
[893] Fix | Delete
add_action( 'load-update-core.php', 'wp_update_themes' );
[894] Fix | Delete
add_action( 'admin_init', '_maybe_update_themes' );
[895] Fix | Delete
add_action( 'wp_update_themes', 'wp_update_themes' );
[896] Fix | Delete
[897] Fix | Delete
add_action( 'update_option_WPLANG', 'wp_clean_update_cache', 10, 0 );
[898] Fix | Delete
[899] Fix | Delete
add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' );
[900] Fix | Delete
[901] Fix | Delete
add_action( 'init', 'wp_schedule_update_checks' );
[902] Fix | Delete
[903] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function