: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
'version' => $this->get( 'Version' ),
* Filters the cache expiration time for theme files.
* @param int $cache_expiration Cache expiration time in seconds.
* @param string $cache_type Type of cache being set.
$cache_expiration = (int) apply_filters( 'wp_theme_files_cache_ttl', self::$cache_expiration, 'theme_block_patterns' );
// We don't want to cache patterns infinitely.
if ( $cache_expiration <= 0 ) {
/* translators: %1$s: The filter name.*/
__( 'The %1$s filter must return an integer value greater than 0.' ),
'<code>wp_theme_files_cache_ttl</code>'
$cache_expiration = self::$cache_expiration;
set_site_transient( 'wp_theme_files_patterns-' . $this->cache_hash, $pattern_data, $cache_expiration );
* Clears block pattern cache.
* @since 6.6.0 Uses transients to cache regardless of site environment.
public function delete_pattern_cache() {
delete_site_transient( 'wp_theme_files_patterns-' . $this->cache_hash );
* Enables a theme for all sites on the current network.
* @param string|string[] $stylesheets Stylesheet name or array of stylesheet names.
public static function network_enable_theme( $stylesheets ) {
if ( ! is_multisite() ) {
if ( ! is_array( $stylesheets ) ) {
$stylesheets = array( $stylesheets );
$allowed_themes = get_site_option( 'allowedthemes' );
foreach ( $stylesheets as $stylesheet ) {
$allowed_themes[ $stylesheet ] = true;
update_site_option( 'allowedthemes', $allowed_themes );
* Disables a theme for all sites on the current network.
* @param string|string[] $stylesheets Stylesheet name or array of stylesheet names.
public static function network_disable_theme( $stylesheets ) {
if ( ! is_multisite() ) {
if ( ! is_array( $stylesheets ) ) {
$stylesheets = array( $stylesheets );
$allowed_themes = get_site_option( 'allowedthemes' );
foreach ( $stylesheets as $stylesheet ) {
if ( isset( $allowed_themes[ $stylesheet ] ) ) {
unset( $allowed_themes[ $stylesheet ] );
update_site_option( 'allowedthemes', $allowed_themes );
* @param WP_Theme[] $themes Array of theme objects to sort (passed by reference).
public static function sort_by_name( &$themes ) {
if ( str_starts_with( get_user_locale(), 'en_' ) ) {
uasort( $themes, array( 'WP_Theme', '_name_sort' ) );
foreach ( $themes as $key => $theme ) {
$theme->translate_header( 'Name', $theme->headers['Name'] );
uasort( $themes, array( 'WP_Theme', '_name_sort_i18n' ) );
* Callback function for usort() to naturally sort themes by name.
* Accesses the Name header directly from the class for maximum speed.
* Would choke on HTML but we don't care enough to slow it down with strip_tags().
* @param WP_Theme $a First theme.
* @param WP_Theme $b Second theme.
* @return int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall equally.
* Greater than 0 if `$a` falls higher in the natural order than `$b`. Used with usort().
private static function _name_sort( $a, $b ) {
return strnatcasecmp( $a->headers['Name'], $b->headers['Name'] );
* Callback function for usort() to naturally sort themes by translated name.
* @param WP_Theme $a First theme.
* @param WP_Theme $b Second theme.
* @return int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall equally.
* Greater than 0 if `$a` falls higher in the natural order than `$b`. Used with usort().
private static function _name_sort_i18n( $a, $b ) {
return strnatcasecmp( $a->name_translated, $b->name_translated );
private static function _check_headers_property_has_correct_type( $headers ) {
if ( ! is_array( $headers ) ) {
foreach ( $headers as $key => $value ) {
if ( ! is_string( $key ) || ! is_string( $value ) ) {