Changeset 55874
- Timestamp:
- 06/01/2023 03:12:16 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/update.php
r55624 r55874 16 16 function get_preferred_from_update_core() { 17 17 $updates = get_core_updates(); 18 18 19 if ( ! is_array( $updates ) ) { 19 20 return false; 20 21 } 22 21 23 if ( empty( $updates ) ) { 22 24 return (object) array( 'response' => 'latest' ); 23 25 } 26 24 27 return $updates[0]; 25 28 } … … 35 38 */ 36 39 function get_core_updates( $options = array() ) { 37 $options 40 $options = array_merge( 38 41 array( 39 42 'available' => true, … … 42 45 $options 43 46 ); 47 44 48 $dismissed = get_site_option( 'dismissed_update_core' ); 45 49 … … 56 60 $updates = $from_api->updates; 57 61 $result = array(); 62 58 63 foreach ( $updates as $update ) { 59 64 if ( 'autoupdate' === $update->response ) { … … 73 78 } 74 79 } 80 75 81 return $result; 76 82 } … … 87 93 function find_core_auto_update() { 88 94 $updates = get_site_transient( 'update_core' ); 95 89 96 if ( ! $updates || empty( $updates->updates ) ) { 90 97 return false; … … 95 102 $auto_update = false; 96 103 $upgrader = new WP_Automatic_Updater(); 104 97 105 foreach ( $updates->updates as $update ) { 98 106 if ( 'autoupdate' !== $update->response ) { … … 108 116 } 109 117 } 118 110 119 return $auto_update; 111 120 } … … 125 134 126 135 $ssl = wp_http_supports( array( 'ssl' ) ); 136 127 137 if ( $ssl ) { 128 138 $url = set_url_scheme( $url, 'https' ); … … 134 144 135 145 $response = wp_remote_get( $url, $options ); 146 136 147 if ( $ssl && is_wp_error( $response ) ) { 137 148 trigger_error( … … 143 154 headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE 144 155 ); 156 145 157 $response = wp_remote_get( $http_url, $options ); 146 158 } 147 159 148 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {160 if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { 149 161 return false; 150 162 } … … 171 183 $dismissed = get_site_option( 'dismissed_update_core' ); 172 184 $dismissed[ $update->current . '|' . $update->locale ] = true; 185 173 186 return update_site_option( 'dismissed_update_core', $dismissed ); 174 187 } … … 192 205 193 206 unset( $dismissed[ $key ] ); 207 194 208 return update_site_option( 'dismissed_update_core', $dismissed ); 195 209 } … … 212 226 213 227 $updates = $from_api->updates; 228 214 229 foreach ( $updates as $update ) { 215 if ( $update->current == $version && $update->locale== $locale ) {230 if ( $update->current === $version && $update->locale === $locale ) { 216 231 return $update; 217 232 } 218 233 } 234 219 235 return false; 220 236 } … … 235 251 236 252 $cur = get_preferred_from_update_core(); 253 237 254 if ( ! is_object( $cur ) ) { 238 255 $cur = new stdClass(); … … 336 353 function update_right_now_message() { 337 354 $theme_name = wp_get_theme(); 355 338 356 if ( current_user_can( 'switch_themes' ) ) { 339 357 $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name ); … … 385 403 $upgrade_plugins = array(); 386 404 $current = get_site_transient( 'update_plugins' ); 405 387 406 foreach ( (array) $all_plugins as $plugin_file => $plugin_data ) { 388 407 if ( isset( $current->response[ $plugin_file ] ) ) { … … 406 425 407 426 $plugins = get_site_transient( 'update_plugins' ); 427 408 428 if ( isset( $plugins->response ) && is_array( $plugins->response ) ) { 409 429 $plugins = array_keys( $plugins->response ); 430 410 431 foreach ( $plugins as $plugin_file ) { 411 432 add_action( "after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2 ); … … 425 446 function wp_plugin_update_row( $file, $plugin_data ) { 426 447 $current = get_site_transient( 'update_plugins' ); 448 427 449 if ( ! isset( $current->response[ $file ] ) ) { 428 450 return false; … … 608 630 609 631 $update_themes = array(); 632 610 633 foreach ( $current->response as $stylesheet => $data ) { 611 634 $update_themes[ $stylesheet ] = wp_get_theme( $stylesheet ); … … 627 650 628 651 $themes = get_site_transient( 'update_themes' ); 652 629 653 if ( isset( $themes->response ) && is_array( $themes->response ) ) { 630 654 $themes = array_keys( $themes->response ); … … 819 843 * 820 844 * @global int $upgrading 845 * 821 846 * @return void|false 822 847 */ … … 825 850 require ABSPATH . WPINC . '/version.php'; 826 851 global $upgrading; 852 827 853 $nag = isset( $upgrading ); 854 828 855 if ( ! $nag ) { 829 856 $failed = get_site_option( 'auto_core_update_failed' );
Note: See TracChangeset
for help on using the changeset viewer.