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.

Built from https://develop.svn.wordpress.org/trunk@29226


git-svn-id: http://core.svn.wordpress.org/trunk@29010 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-07-18 20:49:17 +00:00
parent 4da975b68f
commit 860f0922b7
2 changed files with 28 additions and 0 deletions

View File

@ -109,7 +109,16 @@ class WP_Plugins_List_Table extends WP_List_Table {
update_option( 'recently_activated', $recently_activated ); update_option( 'recently_activated', $recently_activated );
} }
$plugin_info = get_site_transient( 'update_plugins' );
foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
// Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
if ( isset( $plugin_info->response[ $plugin_file ] ) ) {
$plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
} elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
$plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
}
// Filter into individual sections // Filter into individual sections
if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) { if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
// On the non-network screen, filter out network-only plugins as long as they're not individually activated // On the non-network screen, filter out network-only plugins as long as they're not individually activated
@ -344,6 +353,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$actions = array( $actions = array(
'deactivate' => '', 'deactivate' => '',
'activate' => '', 'activate' => '',
'details' => '',
'edit' => '', 'edit' => '',
'delete' => '', 'delete' => '',
); );
@ -392,8 +402,18 @@ class WP_Plugins_List_Table extends WP_List_Table {
if ( ! is_multisite() && current_user_can('delete_plugins') ) if ( ! is_multisite() && current_user_can('delete_plugins') )
$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>'; $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>';
} // end if $is_active } // end if $is_active
} // end if $screen->in_admin( 'network' ) } // end if $screen->in_admin( 'network' )
// Details link using API info, if available
if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && isset( $plugin_data['slug'] ) ) {
$actions['details'] = sprintf( '<a href="%s" class="thickbox" title="%s">%s</a>',
esc_url( self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] .
'&TB_iframe=true&width=600&height=550' ) ),
esc_attr( sprintf( __( 'More information about %s' ), $plugin_data['Name'] ) ),
__( 'Details' ) );
}
if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
$actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
} // end if $context } // end if $context

View File

@ -277,6 +277,7 @@ function wp_update_plugins( $extra_stats = array() ) {
'plugins' => json_encode( $to_send ), 'plugins' => json_encode( $to_send ),
'translations' => json_encode( $translations ), 'translations' => json_encode( $translations ),
'locale' => json_encode( $locales ), 'locale' => json_encode( $locales ),
'all' => json_encode( true ),
), ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
); );
@ -303,13 +304,20 @@ function wp_update_plugins( $extra_stats = array() ) {
$plugin = (object) $plugin; $plugin = (object) $plugin;
} }
unset( $plugin ); unset( $plugin );
foreach ( $response['no_update'] as &$plugin ) {
$plugin = (object) $plugin;
}
unset( $plugin );
if ( is_array( $response ) ) { if ( is_array( $response ) ) {
$new_option->response = $response['plugins']; $new_option->response = $response['plugins'];
$new_option->translations = $response['translations']; $new_option->translations = $response['translations'];
// TODO: Perhaps better to store no_update in a separate transient with an expiry?
$new_option->no_update = $response['no_update'];
} else { } else {
$new_option->response = array(); $new_option->response = array();
$new_option->translations = array(); $new_option->translations = array();
$new_option->no_update = array();
} }
set_site_transient( 'update_plugins', $new_option ); set_site_transient( 'update_plugins', $new_option );