themes_api( string $action, array|object $args = array() ): object|array|WP_Error
- Since
- 2.8.0
- Source
wp-admin/includes/theme.php:495
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: emptyThe theme slug.$per_pageintdefault: 24Number of themes per page.$pageintdefault: 1Number of current page.$numberintNumber of tags to be queried.$searchstringdefault: emptyA search term.$tagstringdefault: emptyTag to filter themes.$authorstringdefault: emptyUsername of an author to filter themes.$userstringdefault: emptyUsername to query for their favorites.$browsestringBrowse 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: falseWhether to return the theme full description.$sectionsbooldefault: falseWhether to return the theme readme sections: description, installation, FAQ, screenshots, other notes, and changelog.$ratingbooldefault: falseWhether to return the rating in percent and total number of ratings.$ratingsbooldefault: falseWhether to return the number of rating for each star (1-5).$downloadedbooldefault: falseWhether to return the download count.$downloadlinkbooldefault: falseWhether to return the download link for the package.$last_updatedbooldefault: falseWhether to return the date of the last update.$tagsbooldefault: falseWhether to return the assigned tags.$homepagebooldefault: falseWhether to return the theme homepage link.$screenshotsbooldefault: falseWhether to return the screenshots.$screenshot_countintdefault: 1Number of screenshots to return.$screenshot_urlbooldefault: falseWhether to return the URL of the first screenshot.$photon_screenshotsbooldefault: falseWhether to return the screenshots via Photon.$templatebooldefault: falseWhether to return the slug of the parent theme.$parentbooldefault: falseWhether to return the slug, name and homepage of the parent theme.$versionsbooldefault: falseWhether to return the list of all available versions.$theme_urlbooldefault: falseWhether 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
- Scaling
- Scales with input
- Instructions
- 31–174
- Plugin surface
- 3 hooks
- Called by
- 8
Reaches an outbound HTTP request via wp_remote_get().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.4, depending on the branch taken. The body compiles to 209.
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.
8 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - httpoutbound HTTP request
wp_remote_get()called directly - serializeserialisation
json_decode()called directly - querycontent query
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
!is_array($args) && isset($args) | 31–33 | apply_filters()apply_filters()apply_filters() |
!is_array($args) | 35–37 | get_user_locale()apply_filters()apply_filters()apply_filters() |
!is_array($args) | 37–39 | wp_get_wp_version()apply_filters()apply_filters()apply_filters() |
!is_array($args) && $action !== "query_themes" && !isset($args) | 41 | get_user_locale()wp_get_wp_version()apply_filters()apply_filters()apply_filters() |
!is_array($args) && isset($args) && !is_wp_error() | 84–104 | 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() | 88–108 | 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) && !is_wp_error() | 88–108 | get_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–109 | 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) && is_wp_error() | 89–101 | 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() | 90–110 | 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) && !is_wp_error() | 92–112 | get_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–113 | 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() |
88 further outcomes, up to 174 instructions
!is_array($args) && !is_wp_error() | 93–113 | get_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–105 | 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) && is_wp_error() | 93–105 | get_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–114 | 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) && $action !== "query_themes" && !isset($args) && !is_wp_error() | 94–112 | get_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–106 | 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() | 95–115 | 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) && is_wp_error() | 95–107 | 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) && isset($args) && wp_doing_ajax() | 96–116 | 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() | 97–117 | get_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–109 | get_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–116 | get_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–110 | 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() | 98–110 | get_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–119 | 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) && $action !== "query_themes" && !isset($args) && !is_wp_error() | 99–117 | get_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–111 | 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) && $action !== "query_themes" && !isset($args) && is_wp_error() | 99–109 | get_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–120 | get_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–112 | 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) && isset($args) && wp_doing_ajax() | 101–121 | 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() && wp_doing_ajax() | 101–113 | 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) && wp_doing_ajax() | 102–122 | 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) | 102–114 | get_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–121 | get_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 === null | 103–122 | 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) && $action !== "query_themes" && !isset($args) | 103–113 | get_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–116 | 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) && $action !== "query_themes" && !isset($args) && is_wp_error() | 104–114 | get_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–125 | get_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–117 | get_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–124 | get_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–118 | 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) && wp_doing_ajax() | 107–127 | 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) && isset($args) && !is_wp_error() && !is_array($res) && $res === null | 107–126 | 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 === null | 107–126 | get_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–119 | 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 === null | 108–127 | 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) && $action !== "query_themes" && !isset($args) | 108–118 | get_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 === null | 109–128 | 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() && wp_doing_ajax() | 110–122 | get_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–129 | get_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 === null | 111–130 | get_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–121 | get_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 === null | 112–131 | 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) && !is_wp_error() && !is_array($res) && $res === null | 112–131 | get_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–124 | 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) && !is_wp_error() && !is_array($res) && $res === null | 113–132 | 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) && $action !== "query_themes" && !isset($args) && !is_wp_error() && !is_array($res) && $res === null | 113–130 | get_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 === null | 114–133 | 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) && isset($args) && wp_doing_ajax() && !is_array($res) && $res === null | 115–134 | 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) && !is_wp_error() && !is_array($res) && $res === null | 116–135 | get_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–126 | get_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 === null | 117–134 | get_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 === null | 118–137 | 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) && $action !== "query_themes" && !isset($args) && !is_wp_error() && !is_array($res) && $res === null | 118–135 | get_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 === null | 119–138 | get_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 === null | 120–139 | 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) && !wp_doing_ajax() | 121–143 | 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() && !is_array($res) && $res === null | 121–140 | 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) && $action !== "query_themes" && !isset($args) && !is_wp_error() && !is_array($res) && $res === null | 122–139 | get_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 === null | 124–143 | get_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–147 | get_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 === null | 125–142 | get_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–148 | 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) && wp_doing_ajax() && !is_array($res) && $res === null | 126–145 | 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) && isset($args) && is_wp_error() && !wp_doing_ajax() | 126–140 | 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) && !wp_doing_ajax() | 127–149 | 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) && !wp_doing_ajax() | 130–150 | get_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 === null | 130–147 | get_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–144 | get_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–151 | get_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–145 | 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() | 132–154 | 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) && is_wp_error() && !wp_doing_ajax() | 132–146 | 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) && $action !== "query_themes" && is_wp_error() && !wp_doing_ajax() | 135–147 | get_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–156 | get_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–148 | get_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–151 | 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) && isset($args) && !wp_doing_ajax() && !is_array($res) && $res === null | 140–161 | 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) && $action !== "query_themes" && !isset($args) && is_wp_error() && !wp_doing_ajax() | 141–153 | get_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 === null | 144–165 | get_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 === null | 145–166 | 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) && !wp_doing_ajax() && !is_array($res) && $res === null | 146–167 | 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 === null | 149–168 | get_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 === null | 150–169 | get_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 === null | 151–172 | 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() |
!is_array($args) && $action !== "query_themes" && !isset($args) && !wp_doing_ajax() && !is_array($res) && $res === null | 155–174 | get_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
7.4 | 212 | 31–177 | 21 | More instructions than PHP 8.4 |
8.1 | 212 | 31–177 | 21 | More instructions than PHP 8.4 |
8.2 | 212 | 31–177 | 21 | More instructions than PHP 8.4 |
8.3 | 212 | 31–177 | 21 | More instructions than PHP 8.4 |
8.4 | 209 | 31–174 | 21 | Compiles 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:
- 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.
- apply_filters( themes_api )filterline 542 (+47 into the body)
Filters whether to override the WordPress.org Themes API.
- apply_filters( themes_api_result )filterline 638 (+143 into the body)
Filters the returned WordPress.org Themes API response.
Uses · 14
- get_user_locale()Retrieves the locale of a user.
- wp_get_wp_version()Returns the current WordPress version.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- add_query_arg()Retrieves a modified URL query string.
- wp_http_supports()Determines if there is an HTTP Transport that can process this request.
- set_url_scheme()Sets the scheme for a URL.
- home_url()Retrieves the URL for the current site where the front end is accessible.
- wp_remote_get()Performs an HTTP request using the GET method and returns its response.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- wp_doing_ajax()Determines whether the current request is a WordPress Ajax request.
- wp_trigger_error()Generates a user-level error/warning/notice/deprecation message.
- __()Retrieves the translation of $text.
Show all 14
- wp_remote_retrieve_body()Retrieves only the body from the raw response.
- WP_Error::__construct()Initializes the error.
Used by · 8
- Theme_Upgrader::check_parent_theme_filter()Checks if a child theme is being installed and its parent also needs to be installed.
- WP_Customize_Manager::handle_load_themes_request()Loads themes into the theme browsing/installation UI.
- WP_Theme_Install_List_Table::prepare_items()
- get_theme_feature_list()Retrieves list of WordPress theme features (aka theme tags).
- install_theme_information()Displays theme information in dialog box form.
- install_themes_feature_list()Retrieves the list of WordPress theme features (aka theme tags).
- wp_ajax_install_theme()Handles installing a theme via AJAX.
- wp_ajax_query_themes()Handles getting themes from themes_api() via AJAX.
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’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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 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.