Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default fonts get loaded (twice) #1348

Closed
mapsteps opened this issue May 31, 2017 · 7 comments
Closed

default fonts get loaded (twice) #1348

mapsteps opened this issue May 31, 2017 · 7 comments
Milestone

Comments

@mapsteps
Copy link
Contributor

mapsteps commented May 31, 2017

kirki-default-fonts-twice

Issue description:

I've specified Roboto as a default font in the customizer. Now, on a fresh installation, not having saved the customizer yet it loads Roboto twice.

Is there a way not to load default fonts if they weren't specified?
I have a bunch of typography fields with roboto as the default font, not sure why they get loaded twice.

Also, I've noticed that the kirky-styles-global-css gets enqueued. In my case I create my own stylesheet from the kirki controls. Also the file CSS file it links to doesn't exist. How can i get rid of it? By just dequeuing it?

Version used:

Latest Dev

@aristath
Copy link
Contributor

aristath commented May 31, 2017

I just pushed a commit that fixes the double issue. (4b580b6)

Is there a way not to load default fonts if they weren't specified?

Isn't this the same question as on #1297?

Also, I've noticed that the kirky-styles-global-css gets enqueued. In my case I create my own stylesheet from the kirki controls.

Can you please elaborate? How do you create them? Do you mean that you have something implemented that writes the compiled CSS to a file and then that file is enqueued? If so, then you don't even need to do that... You can simply add this:

add_filter( 'kirki/dynamic_css/method', function() {
    return 'file';
});

This will tell kirki to write its styles to a CSS file and then that will be enqueued - including the googlefonts styles, all minimized and ready for production - which also get reset when you save the customizer.

Also the file CSS file it links to doesn't exist. How can i get rid of it? By just dequeuing it?

The file does exist, and it's empty. The reason it's enqueued is because all extra styles are added using wp_add_inline_style - and that function needs to reference a stylesheet ID.
You can simply dequeue the kirki-styles-{$config_id} style.
In your screenshot above that's the global style which is used in this case because googlefonts are global and not specific to a config-id, so they get attached there.

But if you switch to file mode using the code I posted above you won't need it anyway so feel free to just dequeue it 👍

@mapsteps
Copy link
Contributor Author

mapsteps commented Jun 1, 2017

Can you please elaborate? How do you create them? Do you mean that you have something implemented that writes the compiled CSS to a file and then that file is enqueued?

That's exactly what I do. I remember I wasn't as flexible as i wanted to be using kirkis output method.

Oh yes, the file does exist - was looking at the wrong folder. I was trying to switch to the file method as suggested above and figured that the new stylesheet that got enqueued (wp-content/uploads/kirki-css/styles.css) is empty too.

@aristath
Copy link
Contributor

aristath commented Jun 1, 2017

Well... version 3.0 adds a lot more versatility to the output arguments so hopefully you'll be able to use the output arguments if you want, and stylesheets will be auto-created.
Not documented yet on the site, but you can now do things like this:

'output'      => array(
	array(
		'element'  => array(
			'#main-navigation',
			'#main-navigation a',
			'#main-navigation a:hover',
		),
		'property'        => 'background',
		'media_query'     => '@media (min-width: 600px)'
		'value_pattern'   => 'linear-gradient(to right, $ 0%,{value2} 100%)',
		'pattern_replace' => array(
			'{value2}' => 'nav_color1',
		),
	),
),

the value_pattern combined with pattern_replace allow you to use multiple settings for the same CSS.
In the example above, $ gets replaced by the current control's value (just like in previous versions) and {value2} will be replaced by the value of the nav_color1 setting 😉
There are more goodies available now too, pending docs once 3.0 is released

@aristath
Copy link
Contributor

aristath commented Jun 1, 2017

I was trying to switch to the file method as suggested above and figured that the new stylesheet that got enqueued (wp-content/uploads/kirki-css/styles.css) is empty too.

Perhaps you've disabled css output?
I seem to remember in a previous post you're using a filter to disable the CSS output in Kirki?

@aristath
Copy link
Contributor

aristath commented Jun 1, 2017

If you're still having an issue with the stylesheet in wp-content/uploads/kirki-css/styles.css being empty can you perhaps send me a copy of your theme so that I may check out what's happening?

@mapsteps
Copy link
Contributor Author

mapsteps commented Jun 4, 2017

Since we fixed this one, every time I change a font in the customizer - then go to the front end and hit refresh - no fonts are loaded. I need to refresh the browser one more time to get the google fonts loaded.

@aristath aristath reopened this Jun 5, 2017
@aristath aristath modified the milestone: 3.0 Jun 7, 2017
@aristath
Copy link
Contributor

It should be ok now, fixed in 3053069

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants