Fix theme support checks
This commit is contained in:
parent
6701917e5a
commit
2fd540fdf6
|
@ -163,10 +163,11 @@ class WC_Settings_Products extends WC_Settings_Page {
|
|||
);
|
||||
|
||||
$theme_support = get_theme_support( 'woocommerce' );
|
||||
$theme_support = is_array( $theme_support ) ? $theme_support[0]: false;
|
||||
$theme_defines_all_sizes = false;
|
||||
$image_settings = array();
|
||||
|
||||
if ( isset( $theme_support['shop_thumbnail'], $theme_support['shop_single'], $theme_support['shop_catalog'] ) ) {
|
||||
if ( isset( $theme_support['shop_thumbnail_image_size'], $theme_support['shop_single_image_size'], $theme_support['shop_catalog_image_size'] ) ) {
|
||||
$theme_defines_all_sizes = true;
|
||||
}
|
||||
|
||||
|
@ -179,7 +180,7 @@ class WC_Settings_Products extends WC_Settings_Page {
|
|||
);
|
||||
}
|
||||
|
||||
if ( ! isset( $theme_support['shop_catalog'] ) ) {
|
||||
if ( ! isset( $theme_support['shop_catalog_image_size'] ) ) {
|
||||
$image_settings[] = array(
|
||||
'title' => __( 'Catalog images', 'woocommerce' ),
|
||||
'desc' => __( 'This size is usually used in product listings. (W x H)', 'woocommerce' ),
|
||||
|
@ -195,7 +196,7 @@ class WC_Settings_Products extends WC_Settings_Page {
|
|||
);
|
||||
}
|
||||
|
||||
if ( ! isset( $theme_support['shop_single'] ) ) {
|
||||
if ( ! isset( $theme_support['shop_single_image_size'] ) ) {
|
||||
$image_settings[] = array(
|
||||
'title' => __( 'Single product image', 'woocommerce' ),
|
||||
'desc' => __( 'This is the size used by the main image on the product page. (W x H)', 'woocommerce' ),
|
||||
|
@ -211,7 +212,7 @@ class WC_Settings_Products extends WC_Settings_Page {
|
|||
);
|
||||
}
|
||||
|
||||
if ( ! isset( $theme_support['shop_thumbnail'] ) ) {
|
||||
if ( ! isset( $theme_support['shop_thumbnail_image_size'] ) ) {
|
||||
$image_settings[] = array(
|
||||
'title' => __( 'Product thumbnails', 'woocommerce' ),
|
||||
'desc' => __( 'This size is usually used for the gallery of images on the product page. (W x H)', 'woocommerce' ),
|
||||
|
|
|
@ -670,6 +670,7 @@ function wc_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r
|
|||
*/
|
||||
function wc_get_image_size( $image_size ) {
|
||||
$theme_support = get_theme_support( 'woocommerce' );
|
||||
$theme_support = is_array( $theme_support ) ? $theme_support[0] : false;
|
||||
$size = $image_size_defaults = array(
|
||||
'width' => 500,
|
||||
'height' => 500,
|
||||
|
@ -683,8 +684,8 @@ function wc_get_image_size( $image_size ) {
|
|||
'crop' => isset( $image_size[2] ) ? $image_size[2] : 1,
|
||||
);
|
||||
$image_size = $size['width'] . '_' . $size['height'];
|
||||
} elseif ( isset( $theme_support[0], $theme_support[0][ $image_size . '_image_size' ] ) ) {
|
||||
$size = wp_parse_args( $theme_support[0][ $image_size . '_image_size' ], $image_size_defaults ); // If the theme supports woocommerce, take image sizes from that definition.
|
||||
} elseif ( isset( $theme_support[ $image_size . '_image_size' ] ) ) {
|
||||
$size = wp_parse_args( $theme_support[ $image_size . '_image_size' ], $image_size_defaults ); // If the theme supports woocommerce, take image sizes from that definition.
|
||||
} elseif ( in_array( $image_size, array( 'shop_thumbnail', 'shop_catalog', 'shop_single' ) ) ) {
|
||||
$size = wp_parse_args( get_option( $image_size . '_image_size', array() ), $image_size_defaults );
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue