Ticket #11640: 11640.patch
| File 11640.patch, 2.8 KB (added by hakre, 3 years ago) |
|---|
-
wp-admin/includes/plugin-install.php
24 24 * 25 25 * @param string $action 26 26 * @param array|object $args Optional. Arguments to serialize for the Plugin Info API. 27 * @return mixed 27 * @return mixed plugins_api response object, WP_Error on error, mixed values 28 28 */ 29 29 function plugins_api($action, $args = null) { 30 30 … … 34 34 if ( !isset($args->per_page) ) 35 35 $args->per_page = 24; 36 36 37 $args = apply_filters('plugins_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter.38 $res = apply_filters('plugins_api', false, $action, $args); //NOTE: Allows a plugin to completely override the builtin WordPress.org API.37 $args = apply_filters('plugins_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter. 38 $res = apply_filters('plugins_api', false, $action, $args); //NOTE: Allows a plugin to completely override the builtin WordPress.org API. 39 39 40 if ( !$res ) {41 $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( ' body' => array('action' => $action, 'request' => serialize($args))) );40 if ( false === $res ) { 41 $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))) ); 42 42 if ( is_wp_error($request) ) { 43 43 $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message() ); 44 } else { 45 $res = unserialize($request['body']); 46 if ( ! $res ) 47 $res = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']); 44 } elseif ( false === ( $res = unserialize( $request['body'] ) ) ) { 45 $res = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']); 48 46 } 49 } elseif ( !is_wp_error($res) ) { 47 } elseif ( !is_wp_error( $res ) ) { 48 $res = (object) $res; 50 49 $res->external = true; 51 50 } 52 51 … … 197 196 function install_popular($page = 1) { 198 197 $args = array('browse' => 'popular', 'page' => $page); 199 198 $api = plugins_api('query_plugins', $args); 199 if ( is_wp_error($api) ) 200 wp_die($api); 200 201 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 201 202 } 202 203 … … 248 249 function install_updated($page = 1) { 249 250 $args = array('browse' => 'updated', 'page' => $page); 250 251 $api = plugins_api('query_plugins', $args); 252 if ( is_wp_error($api) ) 253 wp_die($api); 251 254 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 252 255 } 253 256
