Autoptimize ignores some styles
-
Hi! Your plugin is great and useful indeed, thank you for your work.
But I have some troubles with stylesheets combining.
Stylesheets attached by functions.php with following code:
add_action('init', 'my_custom_css_stylesheet', 0); function my_custom_css_stylesheet() { wp_register_style( 'custom-style-one', get_stylesheet_directory_uri() . '/libs/OwlCarousel2/assets/owl.carousel.min.css' ); wp_register_style( 'custom-style-two', get_stylesheet_directory_uri() . '/libs/OwlCarousel2/assets/owl.theme.default.min.css' ); wp_register_style( 'custom-style-three', get_stylesheet_directory_uri() . '/libs/Choices/choices.min.css' ); } wp_enqueue_style( 'custom-style-one' ); wp_enqueue_style( 'custom-style-two' ); wp_enqueue_style( 'custom-style-three' ); function attach_style_articles() { wp_enqueue_style( 'wpdocs-header-new-style', get_template_directory_uri() . '/css/style-article.css' ); } function attach_style_basket() { wp_enqueue_style( 'wpdocs-header-new-style', get_template_directory_uri() . '/css/style-basket.css' ); } function attach_style_home() { wp_enqueue_style( 'wpdocs-header-new-style', get_template_directory_uri() . '/css/style.css' ); } function attach_style_landing() { wp_enqueue_style( 'wpdocs-header-new-style', get_template_directory_uri() . '/css/style-index2.css' ); } function attach_style_product() { wp_enqueue_style( 'wpdocs-header-new-style', get_template_directory_uri() . '/css/style-product.css' ); } function attach_style_shop() { wp_enqueue_style( 'wpdocs-header-new-style', get_template_directory_uri() . '/css/style-goods.css' ); } function attach_style_other() { wp_enqueue_style( 'wpdocs-header-new-style', get_template_directory_uri() . '/css/style-articles.css' ); } function wpdocs_themeslug_header_hook( $name ) { if ( 'articles' == $name ) { add_action( 'wp_enqueue_scripts', 'attach_style_articles' ); } elseif ( 'basket' == $name ) { add_action( 'wp_enqueue_scripts', 'attach_style_basket' ); } elseif ( 'home' == $name ) { add_action( 'wp_enqueue_scripts', 'attach_style_home' ); } elseif ( 'landing' == $name ) { add_action( 'wp_enqueue_scripts', 'attach_style_landing' ); } elseif ( 'product' == $name ) { add_action( 'wp_enqueue_scripts', 'attach_style_product' ); } elseif ( 'shop' == $name ) { add_action( 'wp_enqueue_scripts', 'attach_style_shop' ); } else { add_action( 'wp_enqueue_scripts', 'attach_style_other' ); } } add_action( 'get_header', 'wpdocs_themeslug_header_hook' );
It looks like plugin can’t get stylesheets attached this way, am I right? Is it possible to fix somehow?
The page I need help with: [log in to see the link]
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Autoptimize ignores some styles’ is closed to new replies.