wppaste
WordPress

WP_Theme::get_allowed_on_site( int $blog_id = null ): string[]

Since
3.4.0
Source
wp-includes/class-wp-theme.php:1705
Returns array of stylesheet names of themes allowed on the site.

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

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Scales with input

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

Instructions
17–83

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

Plugin surface
1 hook

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

Called by
4

4 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
  • optionoption read or writeget_option()called directly
  • cacheobject cachewp_cache_get()one call below WP_Theme::get_allowed_on_site()
  • serializeserialisationmaybe_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.

WhenInstructionsCalls it makes
isset($allowed_themes[$blog_id])17get_current_blog_id(), apply_filters()
is_multisite() && isset($allowed_themes[$blog_id])17is_multisite(), apply_filters()
!is_multisite() && isset($allowed_themes[$blog_id])20is_multisite(), get_current_blog_id(), apply_filters()
!isset($allowed_themes[$blog_id]) && $blog_id === false30get_current_blog_id(), get_current_blog_id(), get_option(), apply_filters()
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false30is_multisite(), get_current_blog_id(), get_option(), apply_filters()
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false33is_multisite(), get_current_blog_id(), get_current_blog_id(), get_option(), apply_filters()
!isset($allowed_themes[$blog_id]) && $blog_id !== false34get_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 !== false34is_multisite(), get_current_blog_id(), switch_to_blog(), get_option(), restore_current_blog(), apply_filters()
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id !== false37is_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 === false46–50get_current_blog_id(), get_current_blog_id(), get_option(), get_option(), is_admin(), apply_filters()
is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false46–50is_multisite(), get_current_blog_id(), get_option(), get_option(), is_admin(), apply_filters()
!is_multisite() && !isset($allowed_themes[$blog_id]) && $blog_id === false49–53is_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–54get_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–54get_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–54is_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–54is_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–56get_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–56is_multisite(), get_current_blog_id(), get_option(), get_option(), wp_get_themes(), is_admin(), apply_filters()
!is_multisite() && !isset($allowed_themes[$blog_id])53–57is_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–57is_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 !== false54–58get_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 !== false54–58is_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–59is_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–60get_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–60get_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–60is_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–60is_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 !== false57–61is_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_themes60–62get_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_themes60–62is_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–63is_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–63is_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–64get_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–64is_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_themes63–65is_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_themes64–66get_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_themes64–66get_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_themes64–66get_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_themes64–66is_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_themes64–66is_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_themes64–66is_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–67is_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_themes67–68get_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_themes67–68is_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_themes67–69is_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_themes67–69is_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_themes67–69is_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_themes68–70get_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_themes68–70get_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_themes68–70get_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_themes68–70is_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_themes68–70is_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_themes68–70is_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_themes70–71is_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_themes71–72get_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_themes71–72get_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_themes71–72get_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_themes71–72is_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_themes71–72is_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_themes71–72is_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_themes71–73is_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_themes71–73is_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_themes71–73is_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_themes72–74get_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_themes72–74is_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_themes74–75is_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_themes74–75is_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_themes74–75is_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_themes75–76get_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_themes75–76get_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_themes75–76get_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_themes75–76is_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_themes75–76is_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_themes75–76is_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_themes75–77is_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_themes78–79is_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_themes78–79is_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_themes78–79is_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_themes79–80get_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_themes79–80is_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_themes82–83is_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:

  1. apply_filters( site_allowed_themes )filterline 1721 (+16 into the body)

    Filters the array of themes allowed on the site.

  2. apply_filters( site_allowed_themes )filterline 1774 (+69 into the body)

    Filters the array of themes allowed on the site.

Uses · 10

Used by · 4

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.

  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-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.