Automattic\WooCommerce\Admin\Features
Onboarding::has_woocommerce_support() public WC 1.0
Check if theme has declared support for WooCommerce.
{} Это метод класса: Onboarding{}
Хуков нет.
Возвращает
true|false
. Ничего.
Использование
$result = Onboarding::has_woocommerce_support( $theme );
- $theme(WP_Theme) (обязательный)
- Theme to check.
Код Onboarding::has_woocommerce_support() Onboarding::has woocommerce support WC 5.2.2
public static function has_woocommerce_support( $theme ) {
$themes = array( $theme );
if ( $theme->get( 'Template' ) ) {
$parent_theme = wp_get_theme( $theme->get( 'Template' ) );
$themes[] = $parent_theme;
}
foreach ( $themes as $theme ) {
$stylesheet_file = $theme->theme_root . '/' . $theme->stylesheet;
if ( ! file_exists( $stylesheet_file ) ) {
continue;
}
$directory = new \RecursiveDirectoryIterator( $stylesheet_file );
$iterator = new \RecursiveIteratorIterator( $directory );
$files = new \RegexIterator( $iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH );
foreach ( $files as $file ) {
$content = file_get_contents( $file[0] );
if ( preg_match( '/add_theme_support\(([^(]*)(\'|\")woocommerce(\'|\")([^(]*)/si', $content, $matches ) ) {
return true;
}
}
}
return false;
}