wppaste
WordPress

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

Since
2.8.0
Source
wp-admin/includes/theme.php:495
Retrieves theme installer pages from the WordPress.org Themes API.

Description

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 overriding 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', allows a plugin to override the WordPress.org Theme API entirely. If $action is 'query_themes', 'theme_information', or 'feature_list', an object MUST be passed. If $action is 'hot_tags', an array should be passed.

Finally, the third filter, 'themes_api_result', makes it possible to filter the response object or array, depending on the $action type.

Supported arguments per action:

Argument Name 'query_themes' 'theme_information' 'hot_tags' 'feature_list'
$slug No Yes No No
$per_page Yes No No No
$page Yes No No No
$number No No Yes No
$search Yes No No No
$tag Yes No No No
$author Yes No No No
$user Yes No No No
$browse Yes No No No
$locale Yes Yes No No
$fields Yes Yes No No

Parameters

$actionstring
API action to perform: Accepts 'query_themes', 'theme_information', 'hot_tags' or 'feature_list'.
$argsarray|objectoptional
Array or object of arguments to serialize for the Themes API. Default empty array.Default: array()
  • $slugstringdefault: empty

    The theme slug.
  • $per_pageintdefault: 24

    Number of themes per page.
  • $pageintdefault: 1

    Number of current page.
  • $numberint

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

    A search term.
  • $tagstringdefault: empty

    Tag to filter themes.
  • $authorstringdefault: empty

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

    Username to query for their favorites.
  • $browsestring

    Browse view: 'featured', 'popular', 'updated', 'favorites'.
  • $localestringdefault: is the value of get_locale()

    Locale to provide context-sensitive results.
  • $fieldsarray

    { Array of fields which should or should not be returned.
  • $descriptionbooldefault: false

    Whether to return the theme full description.
  • $sectionsbooldefault: false

    Whether to return the theme readme sections: description, installation, FAQ, screenshots, other notes, and changelog.
  • $ratingbooldefault: false

    Whether to return the rating in percent and total number of ratings.
  • $ratingsbooldefault: false

    Whether to return the number of rating for each star (1-5).
  • $downloadedbooldefault: false

    Whether to return the download count.
  • $downloadlinkbooldefault: false

    Whether to return the download link for the package.
  • $last_updatedbooldefault: false

    Whether to return the date of the last update.
  • $tagsbooldefault: false

    Whether to return the assigned tags.
  • $homepagebooldefault: false

    Whether to return the theme homepage link.
  • $screenshotsbooldefault: false

    Whether to return the screenshots.
  • $screenshot_countintdefault: 1

    Number of screenshots to return.
  • $screenshot_urlbooldefault: false

    Whether to return the URL of the first screenshot.
  • $photon_screenshotsbooldefault: false

    Whether to return the screenshots via Photon.
  • $templatebooldefault: false

    Whether to return the slug of the parent theme.
  • $parentbooldefault: false

    Whether to return the slug, name and homepage of the parent theme.
  • $versionsbooldefault: false

    Whether to return the list of all available versions.
  • $theme_urlbooldefault: false

    Whether to return theme's URL.
  • $extended_authorbooldefault: false. }

    Whether to return nicename or nicename and display name.

Return value

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

Performance profile

How much work a call to themes_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
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
31–174

Executed per call on PHP 8.4, depending on the branch taken. The body compiles to 209.

Plugin surface
3 hooks

Third-party callbacks on 'themes_api_args', 'themes_api', 'themes_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 themes_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 themes_api() can have, taken from its control-flow graph on PHP 8.4.

WhenInstructionsCalls it makes
!is_array($args) && isset($args)31–33apply_filters()apply_filters()apply_filters()
!is_array($args)35–37get_user_locale()apply_filters()apply_filters()apply_filters()
!is_array($args)37–39wp_get_wp_version()apply_filters()apply_filters()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args)41get_user_locale()wp_get_wp_version()apply_filters()apply_filters()apply_filters()
!is_array($args) && isset($args) && !is_wp_error()84–104apply_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !is_wp_error()88–108apply_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error()88–108get_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !is_wp_error()89–109apply_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && is_wp_error()89–101apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error()90–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_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error()92–112get_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !is_wp_error()93–113apply_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()is_wp_error()apply_filters()
88 further outcomes, up to 174 instructions
!is_array($args) && !is_wp_error()93–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_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && isset($args)93–105apply_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()is_wp_error()apply_filters()
!is_array($args) && is_wp_error()93–105get_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error()94–114wp_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !is_wp_error()94–112get_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && is_wp_error()94–106apply_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error()95–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_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && is_wp_error()95–107wp_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && wp_doing_ajax()96–116apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error()97–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()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args)97–109get_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !is_wp_error()98–116get_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()is_wp_error()apply_filters()
!is_array($args) && isset($args)98–110apply_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()is_wp_error()apply_filters()
!is_array($args) && is_wp_error()98–110get_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error()99–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()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !is_wp_error()99–117get_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()is_wp_error()apply_filters()
!is_array($args)99–111wp_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && is_wp_error()99–109get_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()is_wp_error()apply_filters()
!is_array($args) && wp_doing_ajax()100–120get_user_locale()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && is_wp_error()100–112wp_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && wp_doing_ajax()101–121apply_filters()apply_filters()action()wp_http_supports()set_url_scheme()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && isset($args) && is_wp_error() && wp_doing_ajax()101–113apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && wp_doing_ajax()102–122wp_get_wp_version()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args)102–114get_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !is_wp_error()103–121get_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !is_wp_error() && !is_array($res) && $res === null103–122apply_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args)103–113get_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()is_wp_error()apply_filters()
!is_array($args)104–116wp_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && is_wp_error()104–114get_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()is_wp_error()apply_filters()
!is_array($args) && wp_doing_ajax()105–125get_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_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && is_wp_error() && wp_doing_ajax()105–117get_user_locale()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && wp_doing_ajax()106–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_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && isset($args) && is_wp_error() && wp_doing_ajax()106–118apply_filters()apply_filters()action()wp_http_supports()set_url_scheme()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && wp_doing_ajax()107–127wp_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_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !is_wp_error() && !is_array($res) && $res === null107–126apply_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error() && !is_array($res) && $res === null107–126get_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()is_wp_error()apply_filters()
!is_array($args) && is_wp_error() && wp_doing_ajax()107–119wp_get_wp_version()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !is_wp_error() && !is_array($res) && $res === null108–127apply_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args)108–118get_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error() && !is_array($res) && $res === null109–128wp_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()is_wp_error()apply_filters()
!is_array($args) && is_wp_error() && wp_doing_ajax()110–122get_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_doing_ajax()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && wp_doing_ajax()111–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_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error() && !is_array($res) && $res === null111–130get_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && is_wp_error() && wp_doing_ajax()111–121get_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_doing_ajax()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !is_wp_error() && !is_array($res) && $res === null112–131apply_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error() && !is_array($res) && $res === null112–131get_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()is_wp_error()apply_filters()
!is_array($args) && is_wp_error() && wp_doing_ajax()112–124wp_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_doing_ajax()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error() && !is_array($res) && $res === null113–132wp_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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !is_wp_error() && !is_array($res) && $res === null113–130get_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error() && !is_array($res) && $res === null114–133wp_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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && wp_doing_ajax() && !is_array($res) && $res === null115–134apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error() && !is_array($res) && $res === null116–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()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && is_wp_error() && wp_doing_ajax()116–126get_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_doing_ajax()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !is_wp_error() && !is_array($res) && $res === null117–134get_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()is_wp_error()apply_filters()
!is_array($args) && !is_wp_error() && !is_array($res) && $res === null118–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()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !is_wp_error() && !is_array($res) && $res === null118–135get_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()is_wp_error()apply_filters()
!is_array($args) && wp_doing_ajax() && !is_array($res) && $res === null119–138get_user_locale()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && isset($args) && wp_doing_ajax() && !is_array($res) && $res === null120–139apply_filters()apply_filters()action()wp_http_supports()set_url_scheme()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !wp_doing_ajax()121–143apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && wp_doing_ajax() && !is_array($res) && $res === null121–140wp_get_wp_version()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !is_wp_error() && !is_array($res) && $res === null122–139get_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()is_wp_error()apply_filters()
!is_array($args) && wp_doing_ajax() && !is_array($res) && $res === null124–143get_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_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && !wp_doing_ajax()125–147get_user_locale()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && wp_doing_ajax() && !is_array($res) && $res === null125–142get_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_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !wp_doing_ajax()126–148apply_filters()apply_filters()action()wp_http_supports()set_url_scheme()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && wp_doing_ajax() && !is_array($res) && $res === null126–145wp_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_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && isset($args) && is_wp_error() && !wp_doing_ajax()126–140apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && !wp_doing_ajax()127–149wp_get_wp_version()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && !wp_doing_ajax()130–150get_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_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && wp_doing_ajax() && !is_array($res) && $res === null130–147get_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_doing_ajax()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()__()__()sprintf()wp_remote_retrieve_body()add_query_arg()is_wp_error()apply_filters()
!is_array($args) && is_wp_error() && !wp_doing_ajax()130–144get_user_locale()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !wp_doing_ajax()131–151get_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_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && isset($args) && is_wp_error() && !wp_doing_ajax()131–145apply_filters()apply_filters()action()wp_http_supports()set_url_scheme()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && !wp_doing_ajax()132–154wp_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_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && is_wp_error() && !wp_doing_ajax()132–146wp_get_wp_version()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && is_wp_error() && !wp_doing_ajax()135–147get_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_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !wp_doing_ajax()136–156get_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_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()wp_remote_retrieve_body()json_decode()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && is_wp_error() && !wp_doing_ajax()136–148get_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_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && is_wp_error() && !wp_doing_ajax()137–151wp_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_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !wp_doing_ajax() && !is_array($res) && $res === null140–161apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && is_wp_error() && !wp_doing_ajax()141–153get_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_doing_ajax()__()__()sprintf()__()headers_sent()wp_trigger_error()wp_remote_get()is_wp_error()__()__()sprintf()->get_error_message()timeout()is_wp_error()apply_filters()
!is_array($args) && !wp_doing_ajax() && !is_array($res) && $res === null144–165get_user_locale()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()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()is_wp_error()apply_filters()
!is_array($args) && isset($args) && !wp_doing_ajax() && !is_array($res) && $res === null145–166apply_filters()apply_filters()action()wp_http_supports()set_url_scheme()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()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()is_wp_error()apply_filters()
!is_array($args) && !wp_doing_ajax() && !is_array($res) && $res === null146–167wp_get_wp_version()apply_filters()apply_filters()action()wp_http_supports()wp_get_wp_version()home_url()wp_remote_get()is_wp_error()wp_doing_ajax()__()__()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()is_wp_error()apply_filters()
!is_array($args) && !wp_doing_ajax() && !is_array($res) && $res === null149–168get_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_doing_ajax()__()__()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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !wp_doing_ajax() && !is_array($res) && $res === null150–169get_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_doing_ajax()__()__()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()is_wp_error()apply_filters()
!is_array($args) && !wp_doing_ajax() && !is_array($res) && $res === null151–172wp_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_doing_ajax()__()__()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()is_wp_error()apply_filters()
!is_array($args) && $action !== "query_themes" && !isset($args) && !wp_doing_ajax() && !is_array($res) && $res === null155–174get_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_doing_ajax()__()__()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()is_wp_error()apply_filters()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
7.421231–17721More instructions than PHP 8.4
8.121231–17721More instructions than PHP 8.4
8.221231–17721More instructions than PHP 8.4
8.321231–17721More instructions than PHP 8.4
8.420931–17421Compiles to the same instructions

Oldest PHP that compiles this body: 7.4. An instruction is not a fixed amount of time, so a version with the same count is not necessarily the same speed; what the count rules out is a difference in the work itself.

Hooks and filters fired · 3

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

  1. apply_filters( themes_api_args )filterline 525 (+30 into the body)

    Filters arguments used to query for installer pages from the WordPress.org Themes API.

  2. apply_filters( themes_api )filterline 542 (+47 into the body)

    Filters whether to override the WordPress.org Themes API.

  3. apply_filters( themes_api_result )filterline 638 (+143 into the body)

    Filters the returned WordPress.org Themes API response.

Uses · 14

Show all 14

Used by · 8

Source code

function themes_api( $action, $args = array() ) {	if ( is_array( $args ) ) {		$args = (object) $args;	} 	if ( 'query_themes' === $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 arguments used to query for installer pages from the WordPress.org Themes API.	 *	 * Important: An object MUST be returned to this filter.	 *	 * @since 2.8.0	 *	 * @param object $args   Arguments used to query for installer pages from the WordPress.org Themes API.	 * @param string $action Requested action. Likely values are 'theme_information',	 *                       'feature_list', or 'query_themes'.	 */	$args = apply_filters( 'themes_api_args', $args, $action ); 	/**	 * Filters whether to override the WordPress.org Themes API.	 *	 * Returning a non-false value will effectively short-circuit the WordPress.org API request.	 *	 * If `$action` is 'query_themes', 'theme_information', or 'feature_list', an object MUST	 * be passed. If `$action` is 'hot_tags', an array should be passed.	 *	 * @since 2.8.0	 *	 * @param false|object|array $override Whether to override the WordPress.org Themes API. Default false.	 * @param string             $action   Requested action. Likely values are 'theme_information',	 *                                    'feature_list', or 'query_themes'.	 * @param object             $args     Arguments used to query for installer pages from the Themes API.	 */	$res = apply_filters( 'themes_api', false, $action, $args ); 	if ( ! $res ) {		$url = 'http://api.wordpress.org/themes/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_doing_ajax() ) {				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.)' ),

Changelog

Introduced in 2.8.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 6.8.8 tag, from src/wp-admin/includes/theme.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.