{"action":"created","issue":{"url":"https://api.github.com/repos/aristath/kirki/issues/482","labels_url":"https://api.github.com/repos/aristath/kirki/issues/482/labels{/name}","comments_url":"https://api.github.com/repos/aristath/kirki/issues/482/comments","events_url":"https://api.github.com/repos/aristath/kirki/issues/482/events","html_url":"https://github.com/aristath/kirki/issues/482","id":117986291,"number":482,"title":"Google Font output when using defaults","user":{"login":"doitmax","id":241255,"avatar_url":"https://avatars.githubusercontent.com/u/241255?v=3","gravatar_id":"","url":"https://api.github.com/users/doitmax","html_url":"https://github.com/doitmax","followers_url":"https://api.github.com/users/doitmax/followers","following_url":"https://api.github.com/users/doitmax/following{/other_user}","gists_url":"https://api.github.com/users/doitmax/gists{/gist_id}","starred_url":"https://api.github.com/users/doitmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doitmax/subscriptions","organizations_url":"https://api.github.com/users/doitmax/orgs","repos_url":"https://api.github.com/users/doitmax/repos","events_url":"https://api.github.com/users/doitmax/events{/privacy}","received_events_url":"https://api.github.com/users/doitmax/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-20T08:05:15Z","updated_at":"2015-12-06T10:23:04Z","closed_at":"2015-12-06T10:23:04Z","body":"Hi,\r\n\r\nfirst thank you guys for this fantastic tool. I am just about to start working with it but already love the functionality and simplicity to create things :)\r\n\r\nI have a little question about using Google Fonts and using default values for a font-family select field.\r\n\r\nSo basically my setup for a font-family dropdown with Google Fonts looks like the example from the Wiki:\r\n\r\n```php\r\nKirki::add_field( '', array(\r\n    'type'     => 'select',\r\n    'settings' => 'my_setting',\r\n    'label'    => __( 'Font Family', 'example' ),\r\n    'section'  => 'base_typography',\r\n    'default'  => 'Roboto',\r\n    'priority' => 20,\r\n    'choices'  => Kirki_Fonts::get_font_choices(),\r\n    'output' => ( 'Roboto' != Kirki::get_option( 'dummy_config', 'my_setting' ) ) ? array(\r\n        'element'  => 'body',\r\n        'property' => 'font-family',\r\n   ) : null,\r\n) );\r\n```\r\n\r\nIn the code example above i am checking for the default value in addition to not generate the output when the option matches the default value. But when using Google Fonts this is of course not outputting the Google Font link in the `<head>`.\r\n\r\nThe idea is to keep generating dynamic css at a minimum and avoid unnecessary output by using the default CSS values from the styles.css as much as possible.\r\n\r\nNow my question is how to handle such a situation best?\r\n\r\nShould i check for the default value in my theme and include the the Google Font link on my own or is there any other way Kirki can handle such a situation?\r\n\r\nOf course i can loop any other font-family in my set of customizer options and prevent double output in the head. Not really a big problem, but i would like to keep it as simple as possible and stick with any build in solution, if there is any :)\r\n\r\nCheers,\r\nDennis"},"comment":{"url":"https://api.github.com/repos/aristath/kirki/issues/comments/162298455","html_url":"https://github.com/aristath/kirki/issues/482#issuecomment-162298455","issue_url":"https://api.github.com/repos/aristath/kirki/issues/482","id":162298455,"user":{"login":"aristath","id":588688,"avatar_url":"https://avatars.githubusercontent.com/u/588688?v=3","gravatar_id":"","url":"https://api.github.com/users/aristath","html_url":"https://github.com/aristath","followers_url":"https://api.github.com/users/aristath/followers","following_url":"https://api.github.com/users/aristath/following{/other_user}","gists_url":"https://api.github.com/users/aristath/gists{/gist_id}","starred_url":"https://api.github.com/users/aristath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aristath/subscriptions","organizations_url":"https://api.github.com/users/aristath/orgs","repos_url":"https://api.github.com/users/aristath/repos","events_url":"https://api.github.com/users/aristath/events{/privacy}","received_events_url":"https://api.github.com/users/aristath/received_events","type":"User","site_admin":false},"created_at":"2015-12-06T10:23:04Z","updated_at":"2015-12-06T10:23:04Z","body":"@doitmax I'm sorry for the delay here....\r\n\r\n> Should i check for the default value in my theme and include the the Google Font link on my own or is there any other way Kirki can handle such a situation?\r\n\r\nNo, I'm afraid there's no way Kirki can handle this... \r\nYou'll have to check the value of the theme_mod and manually add the google-font link to your head if the value equals your default value....\r\n\r\nSomething like this should do the trick:\r\n```php\r\nfunction google_fonts() {\r\n\t$query_args = array(\r\n\t\t'family' => 'Roboto'\r\n\t\t'subset' => 'latin,latin-ext',\r\n\t);\r\n\tif ( 'Roboto' == get_theme_mod( 'my_setting', 'Roboto' ) ) {\r\n\t\twp_register_style( 'google_fonts', add_query_arg( $query_args, \"//fonts.googleapis.com/css\" ), array(), null );\r\n\t}\r\n}\r\nadd_action( 'wp_enqueue_scripts', 'google_fonts' );\r\n```"}}