Definition:
function themes_api($action, $args = null) {}
Retrieve theme installer pages from WordPress Themes API.
It is possible for a theme to override the Themes API result with three filters. Assume this is for themes, which can extend on the Theme Info to offer more choices. This is very powerful and must be used with care, when overridding the filters.
Parameters
- string $action
- array|object $args: Optional. Arguments to serialize for the Theme Info API.
Defined filters
- themes_api_args
apply_filters('themes_api_args', $args, $action)
- themes_api
apply_filters('themes_api', false, $action, $args)
- themes_api_result
apply_filters('themes_api_result', $res, $action, $args)
Source code
function themes_api($action, $args = null) { if ( is_array($args) ) $args = (object)$args; if ( !isset($args->per_page) ) $args->per_page = 24; $args = apply_filters('themes_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter. $res = apply_filters('themes_api', false, $action, $args); //NOTE: Allows a theme to completely override the builtin WordPress.org API. if ( ! $res ) { $request = wp_remote_post('http://api.wordpress.org/themes/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) ); if ( is_wp_error($request) ) { $res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() ); } else { $res = unserialize( wp_remote_retrieve_body( $request ) ); if ( ! $res ) $res = new WP_Error('themes_api_failed', __('An unknown error occurred.'), wp_remote_retrieve_body( $request ) ); } } //var_dump(array($args, $res)); return apply_filters('themes_api_result', $res, $action, $args); }
10329
No comments yet... Be the first to leave a reply!