wppaste
WordPress

plugins_api( string $action, array|object $args = array() ): object|array|WP_Error

Since
2.7.0
Source
wp-admin/includes/plugin-install.php:100
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:

Argument Name query_plugins plugin_information hot_tags
$slug No Yes No
$per_page Yes No No
$page Yes No No
$number No No Yes
$search Yes No No
$tag Yes No No
$author Yes No No
$user Yes No No
$browse Yes No No
$locale Yes Yes No
$installed_plugins Yes No No
$is_ssl Yes Yes No
$fields Yes Yes No

Compatibility

WordPress
since 2.7.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

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()
  • $slugstringdefault: empty

    The plugin slug.
  • $per_pageintdefault: 24

    Number of plugins per page.
  • $pageintdefault: 1

    Number of current page.
  • $numberint

    Number of tags or categories to be queried.
  • $searchstringdefault: empty

    A search term.
  • $tagstringdefault: empty

    Tag to filter plugins.
  • $authorstringdefault: empty

    Username of an plugin author to filter plugins.
  • $userstringdefault: empty

    Username to query for their favorites.
  • $browsestring

    Browse view: 'popular', 'new', 'beta', 'recommended'.
  • $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 value

object|array|WP_Error
Response object or array on success, WP_Error on failure. See the https://developer.wordpress.org/reference/functions/plugins_api/ function reference article for more information on the make-up of possible return values depending on the value of $action.

Performance profile

How much work a call to plugins_api() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Expensive

Reaches an outbound HTTP request via wp_remote_get().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
36–168

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 197.

Plugin surface
3 hooks

Third-party callbacks on 'plugins_api_args', 'plugins_api', 'plugins_api_result' run inside this call, and their cost is not bounded by anything here.

Called by
8

8 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • httpoutbound HTTP requestwp_remote_get()called directly
  • serializeserialisationjson_decode()called directly
  • querycontent queryget_user_by()one call below plugins_api()

Further down the call graph this can also reach option, cache and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 100 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost plugins_api() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
isset($args) && $res !== false36–44apply_filters(), apply_filters(), is_wp_error(), apply_filters()
$res !== false40–48get_user_locale(), apply_filters(), apply_filters(), is_wp_error(), apply_filters()
$res !== false42–50wp_get_wp_version(), apply_filters(), apply_filters(), is_wp_error(), apply_filters()
!isset($args) && $res !== false46–54get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), is_wp_error(), apply_filters()
isset($args) && $res === false && !is_wp_error()81–96apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && !is_wp_error()85–100apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && !is_wp_error()85–100get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && !is_wp_error()86–101apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && is_wp_error()86–92apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !is_wp_error()87–102wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && !is_wp_error()89–104get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && !is_wp_error()90–105apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
88 further outcomes, up to 168 instructions
$res === false && !is_wp_error()90–105get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false90–96apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && is_wp_error()90–96get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !is_wp_error()91–106wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
!isset($args) && $res === false && !is_wp_error()91–106get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && is_wp_error()91–97apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !is_wp_error()92–107wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && is_wp_error()92–98wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
isset($args) && $res === false && wp_is_json_request()93–108apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && !is_wp_error()94–109get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false94–100get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && !is_wp_error()95–110get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false95–101apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && is_wp_error()95–101get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !is_wp_error()96–111wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
!isset($args) && $res === false && !is_wp_error()96–111get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false96–102wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && is_wp_error()96–102get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && wp_is_json_request()97–112get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && is_wp_error()97–103wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
isset($args) && $res === false && wp_is_json_request()98–113apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && is_wp_error() && wp_is_json_request()98–104apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && wp_is_json_request()99–114wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false99–105get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && !is_wp_error()100–115get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && !is_wp_error() && !is_array($res) && $res === null100–114apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false100–106get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false101–107wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && is_wp_error()101–107get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && wp_is_json_request()102–117get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && is_wp_error() && wp_is_json_request()102–108get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && wp_is_json_request()103–118get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && is_wp_error() && wp_is_json_request()103–109apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && wp_is_json_request()104–119wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && !is_wp_error() && !is_array($res) && $res === null104–118apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !is_wp_error() && !is_array($res) && $res === null104–118get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && is_wp_error() && wp_is_json_request()104–110wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
isset($args) && $res === false && !is_wp_error() && !is_array($res) && $res === null105–119apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false105–111get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !is_wp_error() && !is_array($res) && $res === null106–120wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && is_wp_error() && wp_is_json_request()107–113get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && wp_is_json_request()108–123get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && !is_wp_error() && !is_array($res) && $res === null108–122get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false && is_wp_error() && wp_is_json_request()108–114get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
isset($args) && $res === false && !is_wp_error() && !is_array($res) && $res === null109–123apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !is_wp_error() && !is_array($res) && $res === null109–123get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && is_wp_error() && wp_is_json_request()109–115wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !is_wp_error() && !is_array($res) && $res === null110–124wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false && !is_wp_error() && !is_array($res) && $res === null110–124get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !is_wp_error() && !is_array($res) && $res === null111–125wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
isset($args) && $res === false && wp_is_json_request() && !is_array($res) && $res === null112–126apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !is_wp_error() && !is_array($res) && $res === null113–127get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false && is_wp_error() && wp_is_json_request()113–119get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && !is_wp_error() && !is_array($res) && $res === null114–128get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !is_wp_error() && !is_array($res) && $res === null115–129wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false && !is_wp_error() && !is_array($res) && $res === null115–129get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && wp_is_json_request() && !is_array($res) && $res === null116–130get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
isset($args) && $res === false && wp_is_json_request() && !is_array($res) && $res === null117–131apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
isset($args) && $res === false && !wp_is_json_request()118–135apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && wp_is_json_request() && !is_array($res) && $res === null118–132wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false && !is_wp_error() && !is_array($res) && $res === null119–133get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && wp_is_json_request() && !is_array($res) && $res === null121–135get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !wp_is_json_request()122–139get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
!isset($args) && $res === false && wp_is_json_request() && !is_array($res) && $res === null122–136get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
isset($args) && $res === false && !wp_is_json_request()123–140apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && wp_is_json_request() && !is_array($res) && $res === null123–137wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
isset($args) && $res === false && is_wp_error() && !wp_is_json_request()123–131apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !wp_is_json_request()124–141wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && !wp_is_json_request()127–144get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
!isset($args) && $res === false && wp_is_json_request() && !is_array($res) && $res === null127–141get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && is_wp_error() && !wp_is_json_request()127–135get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && !wp_is_json_request()128–145get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
isset($args) && $res === false && is_wp_error() && !wp_is_json_request()128–136apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !wp_is_json_request()129–146wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
$res === false && is_wp_error() && !wp_is_json_request()129–137wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && is_wp_error() && !wp_is_json_request()132–140get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
!isset($args) && $res === false && !wp_is_json_request()133–150get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), apply_filters()
!isset($args) && $res === false && is_wp_error() && !wp_is_json_request()133–141get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && is_wp_error() && !wp_is_json_request()134–142wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
isset($args) && $res === false && !wp_is_json_request() && !is_array($res) && $res === null137–153apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false && is_wp_error() && !wp_is_json_request()138–146get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), ->get_error_message(), timeout(), apply_filters()
$res === false && !wp_is_json_request() && !is_array($res) && $res === null141–157get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
isset($args) && $res === false && !wp_is_json_request() && !is_array($res) && $res === null142–158apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !wp_is_json_request() && !is_array($res) && $res === null143–159wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !wp_is_json_request() && !is_array($res) && $res === null146–162get_user_locale(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false && !wp_is_json_request() && !is_array($res) && $res === null147–163get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
$res === false && !wp_is_json_request() && !is_array($res) && $res === null148–164wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()
!isset($args) && $res === false && !wp_is_json_request() && !is_array($res) && $res === null152–168get_user_locale(), wp_get_wp_version(), apply_filters(), apply_filters(), action(), wp_http_supports(), set_url_scheme(), wp_get_wp_version(), home_url(), wp_remote_get(), is_wp_error(), wp_is_json_request(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_body(), json_decode(), __(), __(), sprintf(), wp_remote_retrieve_body(), add_query_arg(), apply_filters()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev19736–16817
8.519736–16817
8.419736–168173 fewer instructions than PHP 8.3
8.320036–17117
8.220036–17117
8.120036–17117
7.420036–17117

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 3

3 hooks fire while plugins_api() runs, in this order:

  1. apply_filters( plugins_api_args )filterline 129 (+29 into the body)

    Filters the WordPress.org Plugin Installation API arguments.

  2. apply_filters( plugins_api )filterline 145 (+45 into the body)

    Filters the response for the current WordPress.org Plugin Installation API request.

  3. apply_filters( plugins_api_result )filterline 230 (+130 into the body)

    Filters the Plugin Installation API response results.

Uses · 14

Show all 14

Used by · 8

Source code

function plugins_api( $action, $args = array() ) {	if ( is_array( $args ) ) {		$args = (object) $args;	} 	if ( 'query_plugins' === $action ) {		if ( ! isset( $args->per_page ) ) {			$args->per_page = 24;		}	} 	if ( ! isset( $args->locale ) ) {		$args->locale = get_user_locale();	} 	if ( ! isset( $args->wp_version ) ) {		$args->wp_version = substr( wp_get_wp_version(), 0, 3 ); // x.y	} 	/**	 * Filters the WordPress.org Plugin Installation API arguments.	 *	 * Important: An object MUST be returned to this filter.	 *	 * @since 2.7.0	 *	 * @param object $args   Plugin API arguments.	 * @param string $action The type of information being requested from the Plugin Installation API.	 */	$args = apply_filters( 'plugins_api_args', $args, $action ); 	/**	 * Filters the response for the current WordPress.org Plugin Installation API request.	 *	 * Returning a non-false value will effectively short-circuit the WordPress.org API request.	 *	 * If `$action` is 'query_plugins' or 'plugin_information', an object MUST be passed.	 * If `$action` is 'hot_tags', an array should be passed.	 *	 * @since 2.7.0	 *	 * @param false|object|array $result The result object or array. Default false.	 * @param string             $action The type of information being requested from the Plugin Installation API.	 * @param object             $args   Plugin API arguments.	 */	$res = apply_filters( 'plugins_api', false, $action, $args ); 	if ( false === $res ) { 		$url = 'http://api.wordpress.org/plugins/info/1.2/';		$url = add_query_arg(			array(				'action'  => $action,				'request' => $args,			),			$url		); 		$http_url = $url;		$ssl      = wp_http_supports( array( 'ssl' ) );		if ( $ssl ) {			$url = set_url_scheme( $url, 'https' );		} 		$http_args = array(			'timeout'    => 15,			'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),		);		$request   = wp_remote_get( $url, $http_args ); 		if ( $ssl && is_wp_error( $request ) ) {			if ( ! wp_is_json_request() ) {				wp_trigger_error(					__FUNCTION__,					sprintf(						/* translators: %s: Support forums URL. */						__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),						__( 'https://wordpress.org/support/forums/' )					) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),					headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE

Changelog

Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 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.