site_allowed_themes
Filter HookDescription
Filters the array of themes allowed on the site.Hook Information
File Location |
wp-includes/class-wp-theme.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1774 |
Hook Parameters
Type | Name | Description |
---|---|---|
string[]
|
$allowed_themes
|
An array of theme stylesheet names. |
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. |
Usage Examples
Basic Usage
<?php
// Hook into site_allowed_themes
add_filter('site_allowed_themes', 'my_custom_filter', 10, 2);
function my_custom_filter($allowed_themes, $blog_id) {
// Your custom filtering logic here
return $allowed_themes;
}
Source Code Context
wp-includes/class-wp-theme.php:1774
- How this hook is used in WordPress core
<?php
1769 }
1770 }
1771 }
1772
1773 /** This filter is documented in wp-includes/class-wp-theme.php */
1774 return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id );
1775 }
1776
1777 /**
1778 * Returns the folder names of the block template directories.
1779 *
PHP Documentation
<?php
/**
* 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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/class-wp-theme.php
Related Hooks
Related hooks will be displayed here in future updates.