From fc5fb635994e15646739bf5e13892dfd047c804e Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 27 Sep 2012 00:47:01 +0000 Subject: [PATCH] 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 --- .../class-wp-plugin-install-list-table.php | 20 +++++++++--- wp-admin/includes/plugin-install.php | 32 ++++++++++++++++--- wp-admin/plugin-install.php | 5 +-- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/wp-admin/includes/class-wp-plugin-install-list-table.php b/wp-admin/includes/class-wp-plugin-install-list-table.php index da324ee701..ca06dbedf9 100644 --- a/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -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; } diff --git a/wp-admin/includes/plugin-install.php b/wp-admin/includes/plugin-install.php index 9cca51d58e..452b4df02b 100644 --- a/wp-admin/includes/plugin-install.php +++ b/wp-admin/includes/plugin-install.php @@ -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' ); + ?> +

+
+ +

+ + + +

+
+ 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. diff --git a/wp-admin/plugin-install.php b/wp-admin/plugin-install.php index 1116b02042..a8fade3c29 100644 --- a/wp-admin/plugin-install.php +++ b/wp-admin/plugin-install.php @@ -45,9 +45,10 @@ get_current_screen()->add_help_tab( array( 'id' => 'adding-plugins', 'title' => __('Adding Plugins'), 'content' => - '

' . __('If you know what you’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.') . '

' . + '

' . __('If you know what you’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.') . '

' . '

' . __('If you just want to get an idea of what’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.') . '

' . - '

' . __('If you want to install a plugin that you’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.') . '

' + '

' . __('You can also browse a user’s favorite plugins, by using the Favorites link in the upper left of the screen and entering their WordPress.org username.') . '

' . + '

' . __('If you want to install a plugin that you’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.') . '

' ) ); get_current_screen()->set_help_sidebar(