WC_Helper::get_local_woo_themes
Get locally installed Woo themes.
Method of the class: WC_Helper{}
No Hooks.
Returns
Array.
Usage
$result = WC_Helper::get_local_woo_themes();
WC_Helper::get_local_woo_themes() WC Helper::get local woo themes code WC 10.8.1
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;
}