Make WordPress Core

Changeset 29226


Ignore:
Timestamp:
07/18/2014 08:48:28 PM (11 years ago)
Author:
nacin
Message:

Add 'Details' links to installed plugins.

Installed plugins that are up to date are now returned in the update-check API response.

props tellyworth.
see #17902.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r29206 r29226  
    109109            update_option( 'recently_activated', $recently_activated );
    110110        }
     111       
     112        $plugin_info = get_site_transient( 'update_plugins' );
    111113
    112114        foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
     115            // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
     116            if ( isset( $plugin_info->response[ $plugin_file ] ) ) {
     117                $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
     118            } elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
     119                $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
     120            }
     121
    113122            // Filter into individual sections
    114123            if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
     
    345354            'deactivate' => '',
    346355            'activate' => '',
     356            'details' => '',
    347357            'edit' => '',
    348358            'delete' => '',
     
    393403                        $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
    394404                } // end if $is_active
     405               
    395406             } // end if $screen->in_admin( 'network' )
     407
     408            // Details link using API info, if available
     409            if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && isset( $plugin_data['slug'] ) ) {
     410                $actions['details'] = sprintf( '<a href="%s" class="thickbox" title="%s">%s</a>',
     411                    esc_url( self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] .
     412                        '&TB_iframe=true&width=600&height=550' ) ),
     413                    esc_attr( sprintf( __( 'More information about %s' ), $plugin_data['Name'] ) ),
     414                    __( 'Details' ) );
     415            }
    396416
    397417            if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
  • trunk/src/wp-includes/update.php

    r28823 r29226  
    278278            'translations' => json_encode( $translations ),
    279279            'locale'       => json_encode( $locales ),
     280            'all'          => json_encode( true ),
    280281        ),
    281282        'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
     
    304305    }
    305306    unset( $plugin );
     307    foreach ( $response['no_update'] as &$plugin ) {
     308        $plugin = (object) $plugin;
     309    }
     310    unset( $plugin );
    306311
    307312    if ( is_array( $response ) ) {
    308313        $new_option->response = $response['plugins'];
    309314        $new_option->translations = $response['translations'];
     315        // TODO: Perhaps better to store no_update in a separate transient with an expiry?
     316        $new_option->no_update = $response['no_update'];
    310317    } else {
    311318        $new_option->response = array();
    312319        $new_option->translations = array();
     320        $new_option->no_update = array();
    313321    }
    314322
Note: See TracChangeset for help on using the changeset viewer.