themes_api [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
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.
The first filter, 'themes_api_args', is for the args and gives the action as the second parameter. The hook for 'themes_api_args' must ensure that an object is returned.
The second filter, 'themes_api', is the result that would be returned.
Source
<?php
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 error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() );
} else {
$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
if ( ! is_object( $res ) && ! is_array( $res ) )
$res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) );
}
}
return apply_filters('themes_api_result', $res, $action, $args);
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- WordPress › Support » wp_remote_post fails in themes_api
[resolved] wp_remote_post fails in themes_api (2 posts). Drew Member Posted 1 year ago #. In 'wp-admin/includes/theme-install.php' at line 55 is: $request ...
wordpress.org - Duplicate "try again" links when themes_api fails - WordPress Trac
When the Themes API fails, for example when searching for themes (in my case because of timed out connection to wp.org, two "Try again" links are presented ...
core.trac.wordpress.org - iGoogle Themes - iGoogle Themes API — Google Developers
The Themes API allows you to build themes about outer space, cartoons, dogs, or anything you can dream up. This is your chance to redesign the Google ...
developers.google.com - themes_api Wordpress hook details -- Adam Brown, BYU Political ...
Detailed information about every action hook and filter used in WordPress. Makes Plugin API easier to use. Lists appearance, file location, and deprecation data ...
adambrown.info