Ticket #35301: 35301.2.diff
File 35301.2.diff, 6.8 KB (added by , 9 years ago) |
---|
-
src/wp-admin/update-core.php
function list_plugin_updates() { 241 241 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p> 242 242 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade"> 243 243 <?php wp_nonce_field('upgrade-core'); ?> 244 244 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> 245 245 <table class="widefat" id="update-plugins-table"> 246 246 <thead> 247 247 <tr> 248 248 <td scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td> 249 249 <th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th> 250 250 </tr> 251 251 </thead> 252 252 253 253 <tbody class="plugins"> 254 254 <?php 255 255 foreach ( (array) $plugins as $plugin_file => $plugin_data ) { 256 $info = plugins_api( 'plugin_information', array(257 'slug' => $plugin_data->update->slug,258 'fields' => array(259 'short_description' => false,260 'sections' => false,261 'requires' => false,262 'rating' => false,263 'ratings' => false,264 'downloaded' => false,265 'downloadlink' => false,266 'last_updated' => false,267 'added' => false,268 'tags' => false,269 'homepage' => false,270 'donate_link' => false,271 ),272 ) );273 274 if ( is_wp_error( $info ) ) {275 $info = false;276 }277 278 256 // Get plugin compat for running version of WordPress. 279 if ( isset($ info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {257 if ( isset($plugin_data->update->tested) && version_compare($plugin_data->update->tested, $cur_wp_version, '>=') ) { 280 258 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version); 281 } elseif ( isset($ info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {282 $compat = $ info->compatibility[$cur_wp_version][$plugin_data->update->new_version];283 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat [0], $compat[2], $compat[1]);259 } elseif ( isset($plugin_data->update->compatibility->{$cur_wp_version}) ) { 260 $compat = $plugin_data->update->compatibility->{$cur_wp_version}; 261 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat->percent, $compat->votes, $compat->total_votes); 284 262 } else { 285 263 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version); 286 264 } 287 265 // Get plugin compat for updated version of WordPress. 288 266 if ( $core_update_version ) { 289 if ( isset( $ info->tested ) && version_compare( $info->tested, $core_update_version, '>=' ) ) {267 if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) { 290 268 $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version ); 291 } elseif ( isset( $ info->compatibility[ $core_update_version ][ $plugin_data->update->new_version ]) ) {292 $update_compat = $ info->compatibility[$core_update_version][$plugin_data->update->new_version];293 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat [0], $update_compat[2], $update_compat[1]);269 } elseif ( isset( $plugin_data->update->compatibility->{$core_update_version} ) ) { 270 $update_compat = $plugin_data->update->compatibility->{$core_update_version}; 271 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat->percent, $update_compat->votes, $update_compat->total_votes); 294 272 } else { 295 273 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version); 296 274 } 297 275 } 298 276 // Get the upgrade notice for the new plugin version. 299 277 if ( isset($plugin_data->update->upgrade_notice) ) { 300 278 $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice); 301 279 } else { 302 280 $upgrade_notice = ''; 303 281 } 304 282 305 283 $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '§ion=changelog&TB_iframe=true&width=640&height=662'); 306 284 $details_name = sprintf( '<span class="screen-reader-text">%1$s</span>', esc_attr( $plugin_data->Name ) ); 307 285 /* translators: 1: Plugin name 2: Plugin version */ 308 286 $details_text = sprintf( __( 'View %1$s version %2$s details.' ), $details_name, $plugin_data->update->new_version ); -
src/wp-includes/update.php
function wp_update_plugins( $extra_stats 298 298 $url = set_url_scheme( $url, 'https' ); 299 299 300 300 $raw_response = wp_remote_post( $url, $options ); 301 301 if ( $ssl && is_wp_error( $raw_response ) ) { 302 302 trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); 303 303 $raw_response = wp_remote_post( $http_url, $options ); 304 304 } 305 305 306 306 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { 307 307 return; 308 308 } 309 309 310 310 $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); 311 311 foreach ( $response['plugins'] as &$plugin ) { 312 312 $plugin = (object) $plugin; 313 if ( $plugin->compatibility ) { 314 $plugin->compatibility = (object) $plugin->compatibility; 315 foreach ( $plugin->compatibility as $version => $data ) { 316 $plugin->compatibility->{$version} = (object) $data; 317 } 318 } 313 319 } 314 unset( $plugin );320 unset( $plugin, $_compat, $version, $data ); 315 321 foreach ( $response['no_update'] as &$plugin ) { 316 322 $plugin = (object) $plugin; 317 323 } 318 324 unset( $plugin ); 319 325 320 326 if ( is_array( $response ) ) { 321 327 $new_option->response = $response['plugins']; 322 328 $new_option->translations = $response['translations']; 323 329 // TODO: Perhaps better to store no_update in a separate transient with an expiry? 324 330 $new_option->no_update = $response['no_update']; 325 331 } else { 326 332 $new_option->response = array(); 327 333 $new_option->translations = array(); 328 334 $new_option->no_update = array(); 329 335 }