wp_get_active_and_valid_themes()WP 5.1.0

Retrieves an array of active and valid themes.

While upgrading or installing WordPress, no themes are returned.

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

Строку[]. Array of absolute paths to theme directories.

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

wp_get_active_and_valid_themes();

Заметки

  • Global. Строка. $pagenow The filename of the current screen.

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

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

Код wp_get_active_and_valid_themes() WP 6.4.3

function wp_get_active_and_valid_themes() {
	global $pagenow;

	$themes = array();

	if ( wp_installing() && 'wp-activate.php' !== $pagenow ) {
		return $themes;
	}

	$stylesheet_path = get_stylesheet_directory();
	$template_path   = get_template_directory();

	if ( $template_path !== $stylesheet_path ) {
		$themes[] = $stylesheet_path;
	}

	$themes[] = $template_path;

	/*
	 * Remove themes from the list of active themes when we're on an endpoint
	 * that should be protected against WSODs and the theme is paused.
	 */
	if ( wp_is_recovery_mode() ) {
		$themes = wp_skip_paused_themes( $themes );

		// If no active and valid themes exist, skip loading themes.
		if ( empty( $themes ) ) {
			add_filter( 'wp_using_themes', '__return_false' );
		}
	}

	return $themes;
}