plugins_api [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Retrieve plugin installer pages from WordPress Plugins API.
It is possible for a plugin to override the Plugin API result with three filters. Assume this is for plugins, which can extend on the Plugin Info to offer more choices. This is very powerful and must be used with care, when overriding the filters.
The first filter, 'plugins_api_args', is for the args and gives the action as the second parameter. The hook for 'plugins_api_args' must ensure that an object is returned.
The second filter, 'plugins_api', is the result that would be returned.
Source
<?php
function plugins_api($action, $args = null) {
if ( is_array($args) )
$args = (object)$args;
if ( !isset($args->per_page) )
$args->per_page = 24;
// Allows a plugin to override the WordPress.org API entirely.
// Use the filter 'plugins_api_result' to merely add results.
// Please ensure that a object is returned from the following filters.
$args = apply_filters('plugins_api_args', $args, $action);
$res = apply_filters('plugins_api', false, $action, $args);
if ( false === $res ) {
$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))) );
if ( is_wp_error($request) ) {
$res = new WP_Error('plugins_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('plugins_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 ) );
}
} elseif ( !is_wp_error($res) ) {
$res->external = true;
}
return apply_filters('plugins_api_result', $res, $action, $args);
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- PHPXRef 0.7 : WordPress : Function Reference: plugins_api()
Function and Method Cross Reference. plugins_api(). Defined at: /wp-admin/ includes/plugin-install.php -> line 9. Referenced 5 times: ...
phpxref.ftwr.co.uk - #12696 (Add ordering support to plugins_api() when filtered on tag ...
Add ordering support to plugins_api() when filtered on tag or search term ... It would be awesome if you could pass an ordering parameter to plugins_api() that ...
core.trac.wordpress.org - PHP Fatal error: Cannot redeclare plugins_api() - WordPress
Please read this forum thread: http://wordpress.org/support/topic/problem-while- trying-to-add-a-new-plugin. Your plugin is NOT working properly! peplamb ...
wordpress.org - plugins_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