[Support request] Prioritize External Stylesheet

Home Forums Support [Support request] Prioritize External Stylesheet

Home Forums Support Prioritize External Stylesheet

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1046298
    Matthew

    Recently, I’ve run into a situation where the CSS edit environment in the Customizer takes precedence over the external style.css file. I’ve not experienced this in GP until very recently. Mostly, but not exclusively, the precedence takes place with WooCommerce styles.

    Is there a way I can prioritize so that the things so that style.css takes precedence over the Customizer stylesheet editor?
    I tried the following, but without success:

    add_action( ‘wp_enqueue_scripts’, ‘generate_remove_scripts’ );
    function generate_remove_scripts()
    {
    wp_dequeue_style( ‘generate-child’ );
    }

    add_action( ‘wp_enqueue_scripts’, ‘generate_move_scripts’, 999 );
    function generate_move_scripts()
    {
    if ( is_child_theme() ) :
    wp_enqueue_style( ‘generate-child’, get_stylesheet_uri(), true, filemtime( get_stylesheet_directory() . ‘/style.css’ ), ‘all’ );
    endif;
    }

    Thank you.

    #1046542
    David
    Staff
    Customer Support

    Hi there,

    By default child theme style sheets are enqueued after the customizer inline styles.

    So this could mean that the styles within your child theme style sheet are not specific enough. Woo’s CSS Selectors are a highly ( overly ) specific.

    If you can provide me with a password i can take a look.

    #1047218
    Matthew

    Here is the login information David:

    Site: http://www.castingdirectorscut.com
    **

    Thank you,
    Matthew

    #1047307
    Tom
    Lead Developer
    Lead Developer

    I actually think the Customizer CSS is added to wp_head, so it shows up later: https://github.com/WordPress/WordPress/blob/5.2.4/wp-includes/default-filters.php#L298
    https://github.com/WordPress/WordPress/blob/5.2.4/wp-includes/default-filters.php#L282

    You could move the Customizer CSS to 0 priority, but that might not be a great idea:

    add_action( 'wp', function() {
        remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
        add_action( 'wp_head', 'wp_custom_css_cb', 0 );
    } );
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.