Make WordPress Core

Changeset 36182


Ignore:
Timestamp:
01/06/2016 07:52:53 AM (9 years ago)
Author:
dd32
Message:

Updates: Don't perform an API call to WordPress.org for every plugin update displayed. The API has been updated to return this information with the update response.

See #35301

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/update-core.php

    r35952 r36182  
    254254<?php
    255255    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 
    278256        // 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, '>=') ) {
    280258            $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);
    284262        } else {
    285263            $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
     
    287265        // Get plugin compat for updated version of WordPress.
    288266        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, '>=' ) ) {
    290268                $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);
    294272            } else {
    295273                $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
  • trunk/src/wp-includes/update.php

    r36180 r36182  
    311311    foreach ( $response['plugins'] as &$plugin ) {
    312312        $plugin = (object) $plugin;
    313     }
    314     unset( $plugin );
     313        if ( isset( $plugin->compatibility ) ) {
     314            $plugin->compatibility = (object) $plugin->compatibility;
     315            foreach ( $plugin->compatibility as &$data ) {
     316                $data = (object) $data;
     317            }
     318        }
     319    }
     320    unset( $plugin, $data );
    315321    foreach ( $response['no_update'] as &$plugin ) {
    316322        $plugin = (object) $plugin;
Note: See TracChangeset for help on using the changeset viewer.