WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Рекомендуемые продукты со скидкой от Template Monster
функция не описана

WP_Theme::get_allowed_on_site() WP 3.4.0

Returns array of stylesheet names of themes allowed on the site.

Это метод класса: WP_Theme

Хуки из метода
Возвращает

Строку[]. Array of stylesheet names.

Использование

$var = WP_Theme::get_allowed_on_site( $blog_id );
$blog_id(число)
ID of the site.
По умолчанию: current site

Заметки

  • Static. Массив. $allowed_themes

Список изменений

С версии 3.4.0 Введена.

Код WP Theme::get allowed on site: wp-includes/class-wp-theme.php WP 5.2.4

<?php
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 = $blog_id == get_current_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 ] );
				delete_option( 'allowed_themes' );
			} else {
				switch_to_blog( $blog_id );
				update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
				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 );
}