WC_Helper::get_local_woo_themes()
Get locally installed Woo themes.
Description Description
Source Source
File: includes/admin/helper/class-wc-helper.php
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 ( 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',
);
$woo_themes[ $data['_filename'] ] = $data;
}
return $woo_themes;
}