Fix/34667 (#34671)
* Add check for when the styles filter is used unexpectedly. * Changelog
This commit is contained in:
parent
4b4b5f36e2
commit
61e1cde33a
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Fix error when 'woocommerce_enqueue_styles' returns non-array.
|
|
@ -57,41 +57,47 @@ class WC_Frontend_Scripts {
|
||||||
public static function get_styles() {
|
public static function get_styles() {
|
||||||
$version = Constants::get_constant( 'WC_VERSION' );
|
$version = Constants::get_constant( 'WC_VERSION' );
|
||||||
|
|
||||||
return array_filter(
|
/**
|
||||||
apply_filters(
|
* Filter list of WooCommerce styles to enqueue.
|
||||||
'woocommerce_enqueue_styles',
|
*
|
||||||
array(
|
* @since 2.1.0
|
||||||
'woocommerce-layout' => array(
|
* @param array List of default WooCommerce styles.
|
||||||
'src' => self::get_asset_url( 'assets/css/woocommerce-layout.css' ),
|
* @retrun array List of styles to enqueue.
|
||||||
'deps' => '',
|
*/
|
||||||
'version' => $version,
|
$styles = apply_filters(
|
||||||
'media' => 'all',
|
'woocommerce_enqueue_styles',
|
||||||
'has_rtl' => true,
|
array(
|
||||||
),
|
'woocommerce-layout' => array(
|
||||||
'woocommerce-smallscreen' => array(
|
'src' => self::get_asset_url( 'assets/css/woocommerce-layout.css' ),
|
||||||
'src' => self::get_asset_url( 'assets/css/woocommerce-smallscreen.css' ),
|
'deps' => '',
|
||||||
'deps' => 'woocommerce-layout',
|
'version' => $version,
|
||||||
'version' => $version,
|
'media' => 'all',
|
||||||
'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
|
'has_rtl' => true,
|
||||||
'has_rtl' => true,
|
),
|
||||||
),
|
'woocommerce-smallscreen' => array(
|
||||||
'woocommerce-general' => array(
|
'src' => self::get_asset_url( 'assets/css/woocommerce-smallscreen.css' ),
|
||||||
'src' => self::get_asset_url( 'assets/css/woocommerce.css' ),
|
'deps' => 'woocommerce-layout',
|
||||||
'deps' => '',
|
'version' => $version,
|
||||||
'version' => $version,
|
'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
|
||||||
'media' => 'all',
|
'has_rtl' => true,
|
||||||
'has_rtl' => true,
|
),
|
||||||
),
|
'woocommerce-general' => array(
|
||||||
'woocommerce-blocktheme' => wc_current_theme_is_fse_theme() ? array(
|
'src' => self::get_asset_url( 'assets/css/woocommerce.css' ),
|
||||||
'src' => self::get_asset_url( 'assets/css/woocommerce-blocktheme.css' ),
|
'deps' => '',
|
||||||
'deps' => '',
|
'version' => $version,
|
||||||
'version' => $version,
|
'media' => 'all',
|
||||||
'media' => 'all',
|
'has_rtl' => true,
|
||||||
'has_rtl' => true,
|
),
|
||||||
) : false,
|
'woocommerce-blocktheme' => wc_current_theme_is_fse_theme() ? array(
|
||||||
)
|
'src' => self::get_asset_url( 'assets/css/woocommerce-blocktheme.css' ),
|
||||||
|
'deps' => '',
|
||||||
|
'version' => $version,
|
||||||
|
'media' => 'all',
|
||||||
|
'has_rtl' => true,
|
||||||
|
) : false,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
return is_array( $styles ) ? array_filter( $styles ) : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue