WC_Helper::get_local_woo_themes()public staticWC 1.0

Get locally installed Woo themes.

Метод класса: WC_Helper{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$result = WC_Helper::get_local_woo_themes();

Код WC_Helper::get_local_woo_themes() WC 8.7.0

public static function get_local_woo_themes() {
	$themes     = wp_get_themes();
	$woo_themes = array();

	foreach ( $themes as $theme ) {
		$header = $theme->get( 'Woo' );

		// Backwards compatibility for theme_info.txt.
		if ( ! $header ) {
			$txt = $theme->get_stylesheet_directory() . '/theme_info.txt';
			if ( is_readable( $txt ) ) {
				$txt = file_get_contents( $txt );
				$txt = preg_split( '#\s#', $txt );
				if ( is_array( $txt ) && count( $txt ) >= 2 ) {
					$header = sprintf( '%d:%s', $txt[0], $txt[1] );
				}
			}
		}

		if ( empty( $header ) ) {
			continue;
		}

		list( $product_id, $file_id ) = explode( ':', $header );
		if ( empty( $product_id ) || empty( $file_id ) ) {
			continue;
		}

		$data = array(
			'Name'        => $theme->get( 'Name' ),
			'Version'     => $theme->get( 'Version' ),
			'Woo'         => $header,

			'_filename'   => $theme->get_stylesheet() . '/style.css',
			'_stylesheet' => $theme->get_stylesheet(),
			'_product_id' => absint( $product_id ),
			'_file_id'    => $file_id,
			'_type'       => 'theme',
			'slug'        => dirname( $theme->get_stylesheet() ),
		);

		$woo_themes[ $data['_filename'] ] = $data;
	}

	return $woo_themes;
}