Changeset 32635
- Timestamp:
- 05/28/2015 03:28:10 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/update.php
r31825 r32635 15 15 * 16 16 * @since 2.3.0 17 * @uses $wp_version Used to check against the newest WordPress version. 17 * @global string $wp_version Used to check against the newest WordPress version. 18 * @global wpdb $wpdb 19 * @global string $wp_local_package 18 20 * 19 21 * @param array $extra_stats Extra statistics to report to the WordPress.org API. 20 * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set. 21 * @return null|false Returns null if update is unsupported. Returns false if check is too soon. 22 * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set. 22 23 */ 23 24 function wp_version_check( $extra_stats = array(), $force_check = false ) { 24 if ( defined('WP_INSTALLING') ) 25 return; 26 27 global $wpdb, $wp_local_package; 28 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 25 if ( defined( 'WP_INSTALLING' ) ) { 26 return; 27 } 28 29 global $wp_version, $wpdb, $wp_local_package; 30 // include an unmodified $wp_version 31 include( ABSPATH . WPINC . '/version.php' ); 29 32 $php_version = phpversion(); 30 33 … … 48 51 $timeout = 60; 49 52 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); 50 if ( ! $force_check && $time_not_changed ) 51 return false;52 53 $locale = get_locale(); 53 if ( ! $force_check && $time_not_changed ) 54 return; 55 } 56 54 57 /** 55 58 * Filter the locale requested for WordPress core translations. … … 59 62 * @param string $locale Current locale. 60 63 */ 61 $locale = apply_filters( 'core_version_check_locale', $locale);64 $locale = apply_filters( 'core_version_check_locale', ); 62 65 63 66 // Update last_checked for current to prevent multiple blocking requests if request hangs … … 121 124 } 122 125 123 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) 124 return false; 126 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { 127 return; 128 } 125 129 126 130 $body = trim( wp_remote_retrieve_body( $response ) ); 127 131 $body = json_decode( $body, true ); 128 132 129 if ( ! is_array( $body ) || ! isset( $body['offers'] ) ) 130 return false; 133 if ( ! is_array( $body ) || ! isset( $body['offers'] ) ) { 134 return; 135 } 131 136 132 137 $offers = $body['offers']; … … 178 183 * 179 184 * @since 2.3.0 180 * @ uses$wp_version Used to notify the WordPress version.185 * @ $wp_version Used to notify the WordPress version. 181 186 * 182 187 * @param array $extra_stats Extra statistics to report to the WordPress.org API. 183 * @return false|null Returns null if update is unsupported. Returns false if check is too soon.184 188 */ 185 189 function wp_update_plugins( $extra_stats = array() ) { 186 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 187 188 if ( defined('WP_INSTALLING') ) 189 return false; 190 if ( defined( 'WP_INSTALLING' ) ) { 191 return; 192 } 193 194 global $wp_version; 195 // include an unmodified $wp_version 196 include( ABSPATH . WPINC . '/version.php' ); 190 197 191 198 // If running blog-side, bail unless we've not checked in the last 12 hours … … 245 252 246 253 // Bail if we've checked recently and if nothing has changed 247 if ( ! $plugin_changed ) 248 return false; 254 if ( ! $plugin_changed ) { 255 return; 256 } 249 257 } 250 258 … … 255 263 $to_send = compact( 'plugins', 'active' ); 256 264 257 $locales = array( get_locale() );258 265 /** 259 266 * Filter the locales requested for plugin translations. … … 263 270 * @param array $locales Plugin locale. Default is current locale of the site. 264 271 */ 265 $locales = apply_filters( 'plugins_update_check_locales', $locales);272 $locales = apply_filters( 'plugins_update_check_locales', ); 266 273 267 274 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { … … 297 304 } 298 305 299 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) 300 return false; 306 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { 307 return; 308 } 301 309 302 310 $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); … … 335 343 * 336 344 * @param array $extra_stats Extra statistics to report to the WordPress.org API. 337 * @return false|null Returns null if update is unsupported. Returns false if check is too soon.338 345 */ 339 346 function wp_update_themes( $extra_stats = array() ) { 340 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 341 342 if ( defined( 'WP_INSTALLING' ) ) 343 return false; 347 if ( defined( 'WP_INSTALLING' ) ) { 348 return; 349 } 350 global $wp_version; 351 // include an unmodified $wp_version 352 include( ABSPATH . WPINC . '/version.php' ); 344 353 345 354 $installed_themes = wp_get_themes(); … … 408 417 409 418 // Bail if we've checked recently and if nothing has changed 410 if ( ! $theme_changed ) 411 return false; 419 if ( ! $theme_changed ) { 420 return; 421 } 412 422 } 413 423 … … 418 428 $request['themes'] = $themes; 419 429 420 $locales = array( get_locale() );421 430 /** 422 431 * Filter the locales requested for theme translations. … … 426 435 * @param array $locales Theme locale. Default is current locale of the site. 427 436 */ 428 $locales = apply_filters( 'themes_update_check_locales', $locales);437 $locales = apply_filters( 'themes_update_check_locales', ); 429 438 430 439 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { … … 459 468 } 460 469 461 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) 462 return false; 470 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { 471 return; 472 } 463 473 464 474 $new_update = new stdClass; … … 493 503 * 494 504 * @since 3.7.0 505 506 495 507 */ 496 508 function wp_get_translation_updates() { … … 498 510 $transients = array( 'update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme' ); 499 511 foreach ( $transients as $transient => $type ) { 500 501 512 $transient = get_site_transient( $transient ); 502 513 if ( empty( $transient->translations ) ) … … 507 518 } 508 519 } 509 510 520 return $updates; 511 521 } … … 572 582 } 573 583 584 585 586 574 587 function _maybe_update_core() { 588 575 589 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 576 590 577 591 $current = get_site_transient( 'update_core' ); 578 592 579 if ( isset( $current->last_checked ) &&593 if ( isset( $current->last_checked ) && 580 594 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) && 581 isset( $current->version_checked ) && 582 $current->version_checked == $wp_version ) 583 return; 584 595 $current->version_checked == $wp_version ) { 596 return; 597 } 585 598 wp_version_check(); 586 599 } … … 615 628 if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) 616 629 return; 617 618 630 wp_update_themes(); 619 631 }
Note: See TracChangeset
for help on using the changeset viewer.