WP_Theme::get_allowed_on_site( int $blog_id = null ): string[]
- Since
- 3.4.0
- Source
wp-includes/class-wp-theme.php:1705
Compatibility
- WordPress
- since 3.4.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
$blog_idintoptional- ID of the site. Defaults to the current site.Default:
null
Return value
string[]- Array of stylesheet names.
Performance profile
How much work a call to WP_Theme::get_allowed_on_site() 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
- Heavy
- Scaling
- Scales with input
- Instructions
- 17–83
- Plugin surface
- 1 hook
- Called by
- 4
Reads stored settings via get_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 128.
Third-party callbacks on 'site_allowed_themes' run inside this call, and their cost is not bounded by anything here.
4 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 - optionoption read or write
get_option()called directly - cacheobject cache
wp_cache_get()one call below WP_Theme::get_allowed_on_site() - serializeserialisation
maybe_unserialize()one call below WP_Theme::get_allowed_on_site()
Further down the call graph this can also reach transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 81 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Theme::get_allowed_on_site() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
isset($allowed_themes[$blog_id]) | 17 | get_current_blog_id(), apply_filters() |
is_multisite() && isset($allowed_themes[$blog_id]) | 17 | is_multisite(), apply_filters() |
!is_multisite() && isset($allowed_themes[$blog_id]) | 20 | is_multisite(), get_current_blog_id(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id === false | 30 | get_current_blog_id(), get_current_blog_id(), get_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false | 30 | is_multisite(), get_current_blog_id(), get_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false | 33 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id !== false | 34 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false | 34 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false | 37 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id === false | 46–50 | get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), is_admin(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false | 46–50 | is_multisite(), get_current_blog_id(), get_option(), get_option(), is_admin(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false | 49–53 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), is_admin(), apply_filters() |
69 further outcomes, up to 83 instructions
!isset($allowed_themes[$blog_id]) | 50–54 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), apply_filters() |
!isset($allowed_themes[$blog_id]) | 50–54 | get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) | 50–54 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) | 50–54 | is_multisite(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id === false && !empty($allowed_themes[$blog_id]) | 53–56 | get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false && !empty($allowed_themes[$blog_id]) | 53–56 | is_multisite(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) | 53–57 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) | 53–57 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id !== false | 54–58 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false | 54–58 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false && !empty($allowed_themes[$blog_id]) | 56–59 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), apply_filters() |
!isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) | 57–60 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), apply_filters() |
!isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) | 57–60 | get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) | 57–60 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) | 57–60 | is_multisite(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false | 57–61 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id === false && is_admin() && $allowed_themes | 60–62 | get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), is_admin(), update_option(), delete_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false && is_admin() && $allowed_themes | 60–62 | is_multisite(), get_current_blog_id(), get_option(), get_option(), is_admin(), update_option(), delete_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) | 60–63 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) | 60–63 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id !== false && !empty($allowed_themes[$blog_id]) | 61–64 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false && !empty($allowed_themes[$blog_id]) | 61–64 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false && is_admin() && $allowed_themes | 63–65 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), is_admin(), update_option(), delete_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 64–66 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), update_option(), delete_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 64–66 | get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), update_option(), delete_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 64–66 | get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 64–66 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), update_option(), delete_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 64–66 | is_multisite(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), update_option(), delete_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 64–66 | is_multisite(), get_current_blog_id(), get_option(), get_option(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false && !empty($allowed_themes[$blog_id]) | 64–67 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id === false && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 67–68 | get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 67–68 | is_multisite(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 67–69 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), update_option(), delete_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 67–69 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), update_option(), delete_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 67–69 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 68–70 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), update_option(), delete_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 68–70 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 68–70 | get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 68–70 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), update_option(), delete_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 68–70 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 68–70 | is_multisite(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 70–71 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–72 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–72 | get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–72 | get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–72 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–72 | is_multisite(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–72 | is_multisite(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–73 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), update_option(), delete_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–73 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 71–73 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id !== false && is_admin() && $allowed_themes | 72–74 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false && is_admin() && $allowed_themes | 72–74 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 74–75 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 74–75 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 74–75 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 75–76 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
!isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 75–76 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 75–76 | get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 75–76 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 75–76 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 75–76 | is_multisite(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false && is_admin() && $allowed_themes | 75–77 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 78–79 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), update_option(), delete_option(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 78–79 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), get_option(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 78–79 | is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!isset($allowed_themes[$blog_id]) && $blog_id !== false && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 79–80 | get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 79–80 | is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false && !empty($allowed_themes[$blog_id]) && is_admin() && $allowed_themes | 82–83 | is_multisite(), get_current_blog_id(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), switch_to_blog(), get_option(), restore_current_blog(), wp_get_themes(), is_admin(), switch_to_blog(), update_option(), delete_option(), restore_current_blog(), apply_filters() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 128 instructions, 17–83 executed per call, 14 branches. The work does not change between versions.
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 · 2
2 hooks fire while WP_Theme::get_allowed_on_site() runs, in this order:
- apply_filters( site_allowed_themes )filterline 1721 (+16 into the body)
Filters the array of themes allowed on the site.
- apply_filters( site_allowed_themes )filterline 1774 (+69 into the body)
Filters the array of themes allowed on the site.
Uses · 10
- is_multisite()Determines whether Multisite is enabled.
- get_current_blog_id()Retrieves the current site ID.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_option()Retrieves an option value based on an option name.
- switch_to_blog()Switches the current blog.
- restore_current_blog()Restores the current blog, after calling switch_to_blog().
- wp_get_themes()Returns an array of WP_Theme objects based on the arguments.
- is_admin()Determines whether the current request is for an administrative interface page.
- update_option()Updates the value of an option that was already added.
- delete_option()Removes an option by name. Prevents removal of protected WordPress options.
Used by · 4
- WP_Theme::get_allowed()Returns array of stylesheet names of themes allowed on the site or network.
- WP_Theme::is_allowed()Determines whether the theme is allowed (multisite only).
- wp_get_themes()Returns an array of WP_Theme objects based on the arguments.
- wpmu_get_blog_allowedthemes()Deprecated functionality for getting themes allowed on a specific site.
Source code
public static function get_allowed_on_site( $blog_id = null ) { static $allowed_themes = array(); if ( ! $blog_id || ! is_multisite() ) { $blog_id = get_current_blog_id(); } if ( isset( $allowed_themes[ $blog_id ] ) ) { /** * Filters the array of themes allowed on the site. * * @since 4.5.0 * * @param string[] $allowed_themes An array of theme stylesheet names. * @param int $blog_id ID of the site. Defaults to current site. */ return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id ); } $current = get_current_blog_id() === $blog_id; if ( $current ) { $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); } else { switch_to_blog( $blog_id ); $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); restore_current_blog(); } /* * This is all super old MU back compat joy. * 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. */ if ( false === $allowed_themes[ $blog_id ] ) { if ( $current ) { $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); } else { switch_to_blog( $blog_id ); $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); restore_current_blog(); } if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) { $allowed_themes[ $blog_id ] = array(); } else { $converted = array(); $themes = wp_get_themes(); foreach ( $themes as $stylesheet => $theme_data ) { if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get( 'Name' ) ] ) ) { $converted[ $stylesheet ] = true; } } $allowed_themes[ $blog_id ] = $converted; } // Set the option so we never have to go through this pain again. if ( is_admin() && $allowed_themes[ $blog_id ] ) { if ( $current ) { update_option( 'allowedthemes', $allowed_themes[ $blog_id ], false ); delete_option( 'allowed_themes' ); } else { switch_to_blog( $blog_id ); update_option( 'allowedthemes', $allowed_themes[ $blog_id ], false ); delete_option( 'allowed_themes' ); restore_current_blog(); } } } /** This filter is documented in wp-includes/class-wp-theme.php */ return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id ); }Changelog
Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/class-wp-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.