Changeset 15727 for trunk/wp-admin/includes/theme-install.php
- Timestamp:
- 10/05/2010 01:24:41 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/theme-install.php
r15655 r15727 19 19 'tags' => true, 'num_ratings' => true 20 20 ); 21 22 23 /**24 * Retrieve theme installer pages from WordPress Themes API.25 *26 * It is possible for a theme to override the Themes API result with three27 * filters. Assume this is for themes, which can extend on the Theme Info to28 * offer more choices. This is very powerful and must be used with care, when29 * overridding the filters.30 *31 * The first filter, 'themes_api_args', is for the args and gives the action as32 * the second parameter. The hook for 'themes_api_args' must ensure that an33 * object is returned.34 *35 * The second filter, 'themes_api', is the result that would be returned.36 *37 * @since 2.8.038 *39 * @param string $action40 * @param array|object $args Optional. Arguments to serialize for the Theme Info API.41 * @return mixed42 */43 function themes_api($action, $args = null) {44 45 if ( is_array($args) )46 $args = (object)$args;47 48 if ( !isset($args->per_page) )49 $args->per_page = 24;50 51 $args = apply_filters('themes_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter.52 $res = apply_filters('themes_api', false, $action, $args); //NOTE: Allows a theme to completely override the builtin WordPress.org API.53 54 if ( ! $res ) {55 $request = wp_remote_post('http://api.wordpress.org/themes/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) );56 if ( is_wp_error($request) ) {57 $res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occured during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message() );58 } else {59 $res = unserialize($request['body']);60 if ( ! $res )61 $res = new WP_Error('themes_api_failed', __('An unknown error occured'), $request['body']);62 }63 }64 //var_dump(array($args, $res));65 return apply_filters('themes_api_result', $res, $action, $args);66 }67 21 68 22 /**
Note: See TracChangeset
for help on using the changeset viewer.