Retrieves plugin installer pages from the WordPress.org Plugins API.
Description
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', allows a plugin to override the WordPress.org Plugin Installation API entirely. If $action is 'query_plugins' or 'plugin_information', an object MUST be passed. If $action is 'hot_tags', an array MUST be passed. Finally, the third filter, 'plugins_api_result', makes it possible to filter the response object or array, depending on the $action type. Supported arguments per action: <table> <thead> <tr> <th>Argument Name</th> <th style="text-align: center;">query_plugins</th> <th style="text-align: center;">plugin_information</th> <th style="text-align: center;">hot_tags</th> </tr> </thead> <tbody> <tr> <td>$slug</td> <td style="text-align: center;">No</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$per_page</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$page</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$number</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> <td style="text-align: center;">Yes</td> </tr> <tr> <td>$search</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$tag</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$author</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$user</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$browse</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$locale</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$installed_plugins</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$is_ssl</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> </tr> <tr> <td>$fields</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">Yes</td> <td style="text-align: center;">No</td> </tr> </tbody> </table>
Parameters
$actionstring
API action to perform: 'query_plugins', 'plugin_information', or 'hot_tags'.
$argsarray|objectoptional
Array or object of arguments to serialize for the Plugin Info API.Default: array()
$localestringdefault: is the value of get_locale()
Locale to provide context-sensitive results.
$installed_pluginsstring
Installed plugins to provide context-sensitive results.
$is_sslbooldefault: false
Whether links should be returned with https or not.
$fieldsarray
{ Array of fields which should or should not be returned.
$short_descriptionbooldefault: true
Whether to return the plugin short description.
$descriptionbooldefault: false
Whether to return the plugin full description.
$sectionsbooldefault: false
Whether to return the plugin readme sections: description, installation, FAQ, screenshots, other notes, and changelog.
$testedbooldefault: true
Whether to return the 'Compatible up to' value.
$requiresbooldefault: true
Whether to return the required WordPress version.
$requires_phpbooldefault: true
Whether to return the required PHP version.
$ratingbooldefault: true
Whether to return the rating in percent and total number of ratings.
$ratingsbooldefault: true
Whether to return the number of rating for each star (1-5).
$downloadedbooldefault: true
Whether to return the download count.
$downloadlinkbooldefault: true
Whether to return the download link for the package.
$last_updatedbooldefault: true
Whether to return the date of the last update.
$addedbooldefault: true
Whether to return the date when the plugin was added to the wordpress.org repository.
$tagsbooldefault: true
Whether to return the assigned tags.
$compatibilitybooldefault: true
Whether to return the WordPress compatibility list.
$homepagebooldefault: true
Whether to return the plugin homepage link.
$versionsbooldefault: false
Whether to return the list of all available versions.
$donate_linkbooldefault: true
Whether to return the donation link.
$reviewsbooldefault: false
Whether to return the plugin reviews.
$bannersbooldefault: false
Whether to return the banner images links.
$iconsbooldefault: false
Whether to return the icon links.
$active_installsbooldefault: false
Whether to return the number of active installations.
$contributorsbooldefault: false. }
Whether to return the list of contributors.
Return
object|array|WP_Error
Response object or array on success, WP_Error on failure. See the <a href="https://developer.wordpress.org/reference/functions/plugins_api/">https://developer.wordpress.org/reference/functions/plugins_api/</a> function reference article for more information on the make-up of possible return values depending on the value of $action.
Hooks fired · 3
3 hooks fire while plugins_api() runs, in this order:
100functionplugins_api($action,$args=array()){101if(is_array($args)){102$args=(object)$args;103}104105if('query_plugins'===$action){106if(!isset($args->per_page)){107$args->per_page=24;108}109}110111if(!isset($args->locale)){112$args->locale=get_user_locale();113}114115if(!isset($args->wp_version)){116$args->wp_version=substr(wp_get_wp_version(),0,3);// x.y117}118119/**120 * Filters the WordPress.org Plugin Installation API arguments.121 *122 * Important: An object MUST be returned to this filter.123 *124 * @since 2.7.0125 *126 * @param object $args Plugin API arguments.127 * @param string $action The type of information being requested from the Plugin Installation API.128 */129$args=apply_filters('plugins_api_args',$args,$action);130131/**132 * Filters the response for the current WordPress.org Plugin Installation API request.133 *134 * Returning a non-false value will effectively short-circuit the WordPress.org API request.135 *136 * If `$action` is 'query_plugins' or 'plugin_information', an object MUST be passed.137 * If `$action` is 'hot_tags', an array should be passed.138 *139 * @since 2.7.0140 *141 * @param false|object|array $result The result object or array. Default false.142 * @param string $action The type of information being requested from the Plugin Installation API.143 * @param object $args Plugin API arguments.144 */145$res=apply_filters('plugins_api',false,$action,$args);146147if(false===$res){148149$url='http://api.wordpress.org/plugins/info/1.2/';150$url=add_query_arg(151array(152'action'=>$action,153'request'=>$args,154),155$url156);157158$http_url=$url;159$ssl=wp_http_supports(array('ssl'));160if($ssl){161$url=set_url_scheme($url,'https');162}163164$http_args=array(165'timeout'=>15,166'user-agent'=>'WordPress/'.wp_get_wp_version().'; '.home_url('/'),167);168$request=wp_remote_get($url,$http_args);169170if($ssl&&is_wp_error($request)){171if(!wp_is_json_request()){172wp_trigger_error(173__FUNCTION__,174sprintf(175/* translators: %s: Support forums URL. */176__('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="%s">support forums</a>.'),177__('https://wordpress.org/support/forums/')178).' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'),179headers_sent()||WP_DEBUG?E_USER_WARNING:E_USER_NOTICE
History
Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-admin/includes/plugin-install.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.