Support » Plugin: Kirki Customizer Framework » No CSS Output on Front End

  • Resolved ThemeAWESOME

    (@tsquez)


    I’m a theme developer and I am trying out your plugin because I may want to include with my theme. I am using WordPress 4.9-alpha-40928.

    I searched and found this thread https://wordpress.org/support/topic/css-not-outputing-on-front-end-of-theme/ and just like in that thread, CSS is being applied to the customizer preview but no CSS being applied to the front end.

    So I took the example you provided:

    Kirki::add_config( 'primadonna_settings', array(
    	'capability'  => 'edit_theme_options',
    	'option_type' => 'theme_mod',
    ) );
    Kirki::add_field( 'primadonna_settings', array(
    	'type'     => 'typography',
    	'settings' => 'primadonna_body_font_setting',
    	'label'    => esc_attr__( 'Body Font', 'primadonna' ),
    	'section'  => 'footer_area',
    	'priority' => 1,
    	'default'  => array(
    		'font-family'    => 'Roboto',
    		'variant'        => 'regular',
    		'font-size'      => '14px',
    		'line-height'    => '1.5',
    		'letter-spacing' => '0',
    		'subsets'        => array( 'latin-ext' ),
    		'color'          => '#333333',
    		'text-transform' => 'none',
    		'text-align'     => 'left',
    	),
    	'output'   => array(
    		array(
    			'element' => 'body',
    		),
    	),
    ) );

    but I used body a instead:

    Kirki::add_section( 'my_section', array(
        'title'          => __( 'My Section' ),
        'description'    => __( 'This is my custom section' ),
        'panel'          => '', // Not typically needed.
        'priority'       => 160,
        'capability'     => 'edit_theme_options',
        'theme_supports' => '', // Rarely needed.
    ) );
    
    Kirki::add_config( 'primadonna_settings', array(
        'capability'  => 'edit_theme_options',
        'option_type' => 'theme_mod',
    ) );
    Kirki::add_field( 'primadonna_settings', array(
        'type'     => 'typography',
        'settings' => 'primadonna_body_font_setting',
        'label'    => esc_attr__( 'Body Font', 'primadonna' ),
        'section'  => 'my_section',
        'priority' => 1,
        'default'  => array(
            'font-family'    => 'Source Sans Pro',
            'variant'        => 'regular',
            'font-size'      => '18px',
            'line-height'    => '1.5',
            'letter-spacing' => '0',
            'subsets'        => array( 'latin-ext' ),
            'color'          => '#3f3f3f',
            'text-transform' => 'none',
            'text-align'     => 'left',
        ),
        'output'   => array(
            array(
                'element' => 'body a',
            ),
        ),
    ) );

    Just curious, do you think it has something to do with the version of WP I am using? I highly doubt it.

    Any ideas?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Ari Stathopoulos

    (@aristath)

    Hey there!

    I just tested this on an almost blank _s theme and it seems to be working fine.
    Perhaps the styles are being overriden by another stylesheet that’s getting loaded? If for example you’re also styling links in a stylesheet, then perhaps you may want to make the selector in the output control a bit more specific (something like html body a perhaps? Or anything that’s just more specific than the CSS selector used in the stylesheet. And also you may want to add the :visited state as well)

    The only thing I would advise you to add inside your controls is 'transport' => 'auto',.
    This way it will live-update the previews in the customizer without a refresh 😉

    OK I’ll give it a try and see what happens. I’ll let yah know.

    So basically if I want to use any of the awesome controls you have built into the plugin, I need to remove any and all styling from the theme.

    For example, if I want my theme site title and site description to use a specific font, be a specific color and so on I have to target those specifically correct? I have to remove font color, font size etc so the typography control can handle it.

    Am I correct or am I missing something?

    Plugin Author Ari Stathopoulos

    (@aristath)

    No, that’s not at all what I’m suggesting.
    You reported an issue, stating that the plugin doesn’t output any CSS.

    In my trying to understand what happens and your CSS doesn’t get applied, I could think of 2 reasons that could have caused this:
    1. a genuine bug that prevents any styles from being added in your page’s source, or
    2. what I mentioned in my previous reply.
    If a stylesheet is enqueued after the kirki styles are added and contains the exact same selector as the ones you’re using in the fields you’ve defined, then the styles from that other stylesheet would override the ones from kirki, not letting them be visually applied on your site.

    If this is indeed the issue, we can simply change the priority of the loaded styles and make them be enqueued after your theme’s stylesheet.
    But there’s no point in doing any of that unless we know that the issue you have is indeed the loading order of your stylesheets and not some other bug that prevents CSS completely from being added.

    In my tests your code worked fine, but I don’t know what you’re trying to do exactly. I see a couple dozen lines from a theme you’re writing, and I have no idea whatsoever about the rest of your theme’s implementation. Right now this is purely guesswork for me and I can’t do any real debugging or understand what your issues are.
    My best guess is what I suggested above, and if you can verify it then I can move on to solving the issue for you by suggesting solutions.
    If you’ve got the theme somewhere on github perhaps I could install it and take a look, that would certainly shed some light and help me understand.
    Before solving any issue you have, first I need to understand if there is no CSS output – as stated in the original post, or if the CSS is properly output in your page’s source but not applied. They are completely different issues and the solution will depend on which one of the 2 it is.

    OK I was thinking that maybe that was the case. I have tried your _s fork so I could see the type of css that is outputted on the front end and I can def confirm that there is no Kirki css being outputted.

    I can see changes in customizer preview, so I know that def works.

    The theme I am developing right now is based off _s 😉

    If possible I would like to email you a copy of my new theme so you can maybe take a look and figure out why its not playing nice with your plugin. If possible can you send me an email I can send it to tsquez at gmail dot com

    I am really looking forward to getting this corrected as i think your plugin is going to be a perfect fit for my theme 😉

    Or if you like you can contact me via my website and send me an email https://themeawesome.com/contact/

    Plugin Author Ari Stathopoulos

    (@aristath)

    Sent you an email from your site, we can continue resolving this via email 🙂

    Plugin Author Ari Stathopoulos

    (@aristath)

    Issue resolved via email.
    For anyone else coming here with the same – or similar – issues, the problem in this case was that the Kirki fields were added inside a function that was called in customize_register.
    Kirki fields don’t have to be wrapped in any functions or added in customize_register. Any actions etc that are needed for the customizer are already taken care of internally.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘No CSS Output on Front End’ is closed to new replies.