Browse and install your wordpress.org plugin favorites from the plugin installer. props Otto42, Japh, DrewAPicture. fixes #22002.

git-svn-id: http://core.svn.wordpress.org/trunk@22026 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-09-27 00:47:01 +00:00
parent 3c6ef163d6
commit fc5fb63599
3 changed files with 47 additions and 10 deletions

View File

@ -29,10 +29,11 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$tabs['dashboard'] = __( 'Search' );
if ( 'search' == $tab )
$tabs['search'] = __( 'Search Results' );
$tabs['upload'] = __( 'Upload' );
$tabs['featured'] = _x( 'Featured','Plugin Installer' );
$tabs['popular'] = _x( 'Popular','Plugin Installer' );
$tabs['new'] = _x( 'Newest','Plugin Installer' );
$tabs['upload'] = __( 'Upload' );
$tabs['featured'] = _x( 'Featured', 'Plugin Installer' );
$tabs['popular'] = _x( 'Popular', 'Plugin Installer' );
$tabs['new'] = _x( 'Newest', 'Plugin Installer' );
$tabs['favorites'] = _x( 'Favorites', 'Plugin Installer' );
$nonmenu_tabs = array( 'plugin-information' ); //Valid actions to perform which do not have a Menu item.
@ -71,6 +72,17 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$args['browse'] = $tab;
break;
case 'favorites':
$user = isset( $_GET['user'] ) ? stripslashes( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
if ( $user )
$args['user'] = $user;
else
$args = false;
add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 );
break;
default:
$args = false;
}

View File

@ -154,6 +154,26 @@ function install_plugins_upload( $page = 1 ) {
}
add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
/**
* Show a username form for the favorites page
* @since 3.5.0
*
*/
function install_plugins_favorites_form() {
$user = ! empty( $_GET['user'] ) ? stripslashes( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
?>
<p class="install-help"><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p>
<form method="get" action="">
<input type="hidden" name="tab" value="favorites" />
<p>
<label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label>
<input type="search" id="user" name="user" value="<?php echo esc_attr( $user ); ?>" />
<input type="submit" class="button" value="<?php esc_attr_e( 'Get Favorites' ); ?>" />
</p>
</form>
<?php
}
/**
* Display plugin content based on plugin list.
*
@ -162,12 +182,16 @@ add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
function display_plugins_table() {
global $wp_list_table;
if ( current_filter() == 'install_plugins_favorites' && empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) )
return;
$wp_list_table->display();
}
add_action('install_plugins_search', 'display_plugins_table');
add_action('install_plugins_featured', 'display_plugins_table');
add_action('install_plugins_popular', 'display_plugins_table');
add_action('install_plugins_new', 'display_plugins_table');
add_action( 'install_plugins_search', 'display_plugins_table' );
add_action( 'install_plugins_featured', 'display_plugins_table' );
add_action( 'install_plugins_popular', 'display_plugins_table' );
add_action( 'install_plugins_new', 'display_plugins_table' );
add_action( 'install_plugins_favorites', 'display_plugins_table' );
/**
* Determine the status we can perform on a plugin.

View File

@ -45,9 +45,10 @@ get_current_screen()->add_help_tab( array(
'id' => 'adding-plugins',
'title' => __('Adding Plugins'),
'content' =>
'<p>' . __('If you know what you&#8217;re looking for, Search is your best bet. The Search screen has options to search the WordPress.org Plugin Directory for a particular Term, Author, or Tag. You can also search the directory by selecting a popular tags. Tags in larger type mean more plugins have been labeled with that tag.') . '</p>' .
'<p>' . __('If you know what you&#8217;re looking for, Search is your best bet. The Search screen has options to search the WordPress.org Plugin Directory for a particular Term, Author, or Tag. You can also search the directory by selecting popular tags. Tags in larger type mean more plugins have been labeled with that tag.') . '</p>' .
'<p>' . __('If you just want to get an idea of what&#8217;s available, you can browse Featured, Popular, and Newest plugins by using the links in the upper left of the screen. These sections rotate regularly.') . '</p>' .
'<p>' . __('If you want to install a plugin that you&#8217;ve downloaded elsewhere, click the Upload in the upper left. You will be prompted to upload the .zip package, and once uploaded, you can activate the new plugin.') . '</p>'
'<p>' . __('You can also browse a user&#8217;s favorite plugins, by using the Favorites link in the upper left of the screen and entering their WordPress.org username.') . '</p>' .
'<p>' . __('If you want to install a plugin that you&#8217;ve downloaded elsewhere, click the Upload link in the upper left. You will be prompted to upload the .zip package, and once uploaded, you can activate the new plugin.') . '</p>'
) );
get_current_screen()->set_help_sidebar(