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 c755f96fbd..f82180109e 100644 --- a/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -145,14 +145,8 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { $args = array( 'page' => $paged, 'per_page' => $per_page, - 'fields' => array( - 'last_updated' => true, - 'icons' => true, - 'active_installs' => true, - ), - // Send the locale and installed plugin slugs to the API so it can provide context-sensitive results. + // Send the locale to the API so it can provide context-sensitive results. 'locale' => get_user_locale(), - 'installed_plugins' => array_keys( $installed_plugins ), ); switch ( $tab ) { @@ -175,14 +169,15 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { break; case 'featured': - $args['fields']['group'] = true; - $this->orderby = 'group'; - // No break! case 'popular': case 'new': case 'beta': + $args['browse'] = $tab; + break; case 'recommended': $args['browse'] = $tab; + // Include the list of installed plugins so we can get relevant results. + $args['installed_plugins'] = array_keys( $installed_plugins ); break; case 'favorites': diff --git a/wp-admin/includes/plugin-install.php b/wp-admin/includes/plugin-install.php index 1838ce1cb3..d8b9cd3c8a 100644 --- a/wp-admin/includes/plugin-install.php +++ b/wp-admin/includes/plugin-install.php @@ -99,19 +99,27 @@ * for more information on the make-up of possible return values depending on the value of `$action`. */ function plugins_api( $action, $args = array() ) { + // include an unmodified $wp_version + include( ABSPATH . WPINC . '/version.php' ); if ( is_array( $args ) ) { $args = (object) $args; } - if ( ! isset( $args->per_page ) ) { - $args->per_page = 24; + if ( 'query_plugins' == $action ) { + if ( ! isset( $args->per_page ) ) { + $args->per_page = 24; + } } if ( ! isset( $args->locale ) ) { $args->locale = get_user_locale(); } + if ( ! isset( $args->wp_version ) ) { + $args->wp_version = substr( $wp_version, 0, 3 ); // X.y + } + /** * Filters the WordPress.org Plugin Installation API arguments. * @@ -141,10 +149,17 @@ function plugins_api( $action, $args = array() ) { $res = apply_filters( 'plugins_api', false, $action, $args ); if ( false === $res ) { - // include an unmodified $wp_version - include( ABSPATH . WPINC . '/version.php' ); - $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; + $url = 'http://api.wordpress.org/plugins/info/1.2/'; + $url = add_query_arg( + array( + 'action' => $action, + 'request' => $args, + ), + $url + ); + + $http_url = $url; if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { $url = set_url_scheme( $url, 'https' ); } @@ -152,12 +167,8 @@ function plugins_api( $action, $args = array() ) { $http_args = array( 'timeout' => 15, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), - 'body' => array( - 'action' => $action, - 'request' => serialize( $args ), - ), ); - $request = wp_remote_post( $url, $http_args ); + $request = wp_remote_get( $url, $http_args ); if ( $ssl && is_wp_error( $request ) ) { trigger_error( @@ -168,7 +179,7 @@ function plugins_api( $action, $args = array() ) { ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); - $request = wp_remote_post( $http_url, $http_args ); + $request = wp_remote_get( $http_url, $http_args ); } if ( is_wp_error( $request ) ) { @@ -182,8 +193,11 @@ function plugins_api( $action, $args = array() ) { $request->get_error_message() ); } else { - $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); - if ( ! is_object( $res ) && ! is_array( $res ) ) { + $res = json_decode( wp_remote_retrieve_body( $request ), true ); + if ( is_array( $res ) ) { + // Object casting is required in order to match the info/1.0 format. + $res = (object) $res; + } elseif ( null === $res ) { $res = new WP_Error( 'plugins_api_failed', sprintf( @@ -194,6 +208,10 @@ function plugins_api( $action, $args = array() ) { wp_remote_retrieve_body( $request ) ); } + + if ( isset( $res->error ) ) { + $res = new WP_Error( 'plugins_api_failed', $res->error ); + } } } elseif ( ! is_wp_error( $res ) ) { $res->external = true; @@ -485,13 +503,6 @@ function install_plugin_information() { $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), - 'is_ssl' => is_ssl(), - 'fields' => array( - 'banners' => true, - 'reviews' => true, - 'downloaded' => false, - 'active_installs' => true, - ), ) ); @@ -707,19 +718,17 @@ if ( ! empty( $api->contributors ) ) {