Changeset 47778
- Timestamp:
- 05/09/2020 12:50:43 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/update.php
r47550 r47778 23 23 */ 24 24 function wp_version_check( $extra_stats = array(), $force_check = false ) { 25 global $wpdb, $wp_local_package; 26 25 27 if ( wp_installing() ) { 26 28 return; 27 29 } 28 30 29 global $wpdb, $wp_local_package;30 31 // Include an unmodified $wp_version. 31 32 require ABSPATH . WPINC . '/version.php'; … … 36 37 37 38 // Invalidate the transient when $wp_version changes. 38 if ( is_object( $current ) && $wp_version != $current->version_checked ) {39 if ( is_object( $current ) && $wp_version !== $current->version_checked ) { 39 40 $current = false; 40 41 } … … 53 54 $timeout = MINUTE_IN_SECONDS; 54 55 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); 56 55 57 if ( ! $force_check && $time_not_changed ) { 56 58 return; … … 136 138 $http_url = $url; 137 139 $ssl = wp_http_supports( array( 'ssl' ) ); 140 138 141 if ( $ssl ) { 139 142 $url = set_url_scheme( $url, 'https' ); … … 153 156 154 157 $response = wp_remote_post( $url, $options ); 158 155 159 if ( $ssl && is_wp_error( $response ) ) { 156 160 trigger_error( … … 165 169 } 166 170 167 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {171 if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { 168 172 return; 169 173 } … … 180 184 foreach ( $offers as &$offer ) { 181 185 foreach ( $offer as $offer_key => $value ) { 182 if ( 'packages' == $offer_key ) {186 if ( 'packages' === $offer_key ) { 183 187 $offer['packages'] = (object) array_intersect_key( 184 188 array_map( 'esc_url', $offer['packages'] ), 185 189 array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial', 'rollback' ), '' ) 186 190 ); 187 } elseif ( 'download' == $offer_key ) {191 } elseif ( 'download' === $offer_key ) { 188 192 $offer['download'] = esc_url( $value ); 189 193 } else { … … 227 231 if ( ! empty( $body['ttl'] ) ) { 228 232 $ttl = (int) $body['ttl']; 233 229 234 if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) { 230 235 // Queue an event to re-run the update check in $ttl seconds. … … 274 279 $active = get_option( 'active_plugins', array() ); 275 280 $current = get_site_transient( 'update_plugins' ); 281 276 282 if ( ! is_object( $current ) ) { 277 283 $current = new stdClass; … … 307 313 if ( $time_not_changed && ! $extra_stats ) { 308 314 $plugin_changed = false; 315 309 316 foreach ( $plugins as $file => $p ) { 310 317 $new_option->checked[ $file ] = $p['Version']; … … 374 381 $http_url = $url; 375 382 $ssl = wp_http_supports( array( 'ssl' ) ); 383 376 384 if ( $ssl ) { 377 385 $url = set_url_scheme( $url, 'https' ); … … 379 387 380 388 $raw_response = wp_remote_post( $url, $options ); 389 381 390 if ( $ssl && is_wp_error( $raw_response ) ) { 382 391 trigger_error( … … 391 400 } 392 401 393 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) {402 if ( is_wp_error( $raw_response ) || 200 !== wp_remote_retrieve_response_code( $raw_response ) ) { 394 403 return; 395 404 } 396 405 397 406 $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); 407 398 408 foreach ( $response['plugins'] as &$plugin ) { 399 409 $plugin = (object) $plugin; 410 400 411 if ( isset( $plugin->compatibility ) ) { 401 412 $plugin->compatibility = (object) $plugin->compatibility; 413 402 414 foreach ( $plugin->compatibility as &$data ) { 403 415 $data = (object) $data; … … 405 417 } 406 418 } 419 407 420 unset( $plugin, $data ); 421 408 422 foreach ( $response['no_update'] as &$plugin ) { 409 423 $plugin = (object) $plugin; 410 424 } 425 411 426 unset( $plugin ); 412 427 … … 449 464 450 465 $last_update = get_site_transient( 'update_themes' ); 466 451 467 if ( ! is_object( $last_update ) ) { 452 468 $last_update = new stdClass; … … 500 516 if ( $time_not_changed && ! $extra_stats ) { 501 517 $theme_changed = false; 518 502 519 foreach ( $checked as $slug => $v ) { 503 520 if ( ! isset( $last_update->checked[ $slug ] ) || strval( $last_update->checked[ $slug ] ) !== strval( $v ) ) { … … 564 581 $http_url = $url; 565 582 $ssl = wp_http_supports( array( 'ssl' ) ); 583 566 584 if ( $ssl ) { 567 585 $url = set_url_scheme( $url, 'https' ); … … 569 587 570 588 $raw_response = wp_remote_post( $url, $options ); 589 571 590 if ( $ssl && is_wp_error( $raw_response ) ) { 572 591 trigger_error( … … 581 600 } 582 601 583 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) {602 if ( is_wp_error( $raw_response ) || 200 !== wp_remote_retrieve_response_code( $raw_response ) ) { 584 603 return; 585 604 } … … 626 645 'update_themes' => 'theme', 627 646 ); 647 628 648 foreach ( $transients as $transient => $type ) { 629 649 $transient = get_site_transient( $transient ); 650 630 651 if ( empty( $transient->translations ) ) { 631 652 continue; … … 636 657 } 637 658 } 659 638 660 return $updates; 639 661 } … … 655 677 656 678 $plugins = current_user_can( 'update_plugins' ); 679 657 680 if ( $plugins ) { 658 681 $update_plugins = get_site_transient( 'update_plugins' ); 682 659 683 if ( ! empty( $update_plugins->response ) ) { 660 684 $counts['plugins'] = count( $update_plugins->response ); … … 663 687 664 688 $themes = current_user_can( 'update_themes' ); 689 665 690 if ( $themes ) { 666 691 $update_themes = get_site_transient( 'update_themes' ); 692 667 693 if ( ! empty( $update_themes->response ) ) { 668 694 $counts['themes'] = count( $update_themes->response ); … … 671 697 672 698 $core = current_user_can( 'update_core' ); 699 673 700 if ( $core && function_exists( 'get_core_updates' ) ) { 674 701 $update_wordpress = get_core_updates( array( 'dismissed' => false ) ); 702 675 703 if ( ! empty( $update_wordpress ) 676 704 && ! in_array( $update_wordpress[0]->response, array( 'development', 'latest' ), true ) … … 687 715 $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'] + $counts['translations']; 688 716 $titles = array(); 717 689 718 if ( $counts['wordpress'] ) { 690 719 /* translators: %d: Number of available WordPress updates. */ 691 720 $titles['wordpress'] = sprintf( __( '%d WordPress Update' ), $counts['wordpress'] ); 692 721 } 722 693 723 if ( $counts['plugins'] ) { 694 724 /* translators: %d: Number of available plugin updates. */ 695 725 $titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] ); 696 726 } 727 697 728 if ( $counts['themes'] ) { 698 729 /* translators: %d: Number of available theme updates. */ 699 730 $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] ); 700 731 } 732 701 733 if ( $counts['translations'] ) { 702 734 $titles['translations'] = __( 'Translation Updates' ); … … 738 770 $current = get_site_transient( 'update_core' ); 739 771 740 if ( isset( $current->last_checked, $current->version_checked ) && 741 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) && 742 $current->version_checked == $wp_version ) { 743 return; 744 } 772 if ( isset( $current->last_checked, $current->version_checked ) 773 && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) 774 && $current->version_checked === $wp_version 775 ) { 776 return; 777 } 778 745 779 wp_version_check(); 746 780 } … … 757 791 function _maybe_update_plugins() { 758 792 $current = get_site_transient( 'update_plugins' ); 759 if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) { 760 return; 761 } 793 794 if ( isset( $current->last_checked ) 795 && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) 796 ) { 797 return; 798 } 799 762 800 wp_update_plugins(); 763 801 } … … 774 812 function _maybe_update_themes() { 775 813 $current = get_site_transient( 'update_themes' ); 776 if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) { 777 return; 778 } 814 815 if ( isset( $current->last_checked ) 816 && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) 817 ) { 818 return; 819 } 820 779 821 wp_update_themes(); 780 822 } … … 810 852 delete_site_transient( 'update_plugins' ); 811 853 } 854 812 855 wp_clean_themes_cache(); 856 813 857 delete_site_transient( 'update_core' ); 814 858 }
Note: See TracChangeset
for help on using the changeset viewer.