Example โ Single Page Title โ https://www.screencast.com/t/kWfiuJS1
You can see that the two title locations are by default OFF, but still the title is shown in all the three locations. This is not fixed Until I go to single page panel and save.
Maybe because Kirki is installed after theme installation so customizer settings do not get saved. Any Fix sir?
The WordPress Customizer in general doesn't save unmodified values. The defaults are not saved anywhere. That's just the way the customizer works and there's no way around that.
The solution is to properly use the get_theme_mod function in your theme and add the defaults for the setting as the 2nd argument of the function.
In https://codex.wordpress.org/Function_Reference/get_theme_mod you can see that if you don't define a 2nd argument, the default value is set to false.
Example with and without a default value:
// No default value defined - returns false if not set.
$show_title = get_theme_mod( 'show_title' );
// Default value set to true - returns true if not set.
$show_title = get_theme_mod( 'show_title', true );
So If I am into color palette I will write it like this โ
border: 1px solid <?php echo get_theme_mod('themename_themecolor_primary', '#DCDCDC'); ?>;
Exactly ๐
Though it would be better with some sanitization as well...
Themes are required to sanitize everything on output - especially if they are to be submitted on wordpress.org.
So your above code would become
<?php $themename_themecolor_primary = get_theme_mod( themename_themecolor_primary, '#DCDCDC' ); ?>
border: 1px solid <?php echo esc_attr( $themename_themecolor_primary ); ?>;
I think we can also do it like this โ
border: 1px solid <?php echo esc_attr( get_theme_mod( themename_themecolor_primary, '#DCDCDC' ); ?>;
Sure, it's the same thing.
I just wrote it in 2 separate lines because it's easier to read and I saw
the theme_mod was the primary colour so I assume it's used multiple times -
in which case it's useful to have it as a variable that you can reuse and
avoid the extra get_theme_mod calls :)
On Tue, 14 Nov 2017, 14:07 fastmarketo, notifications@github.com wrote:
I think we can also do it like this โ
border: 1px solid themename_themecolor_primary, '#DCDCDC' ); ?>;โ
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/aristath/kirki/issues/1630#issuecomment-344239380,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAj7kIvubg5G-NK2v78BsBfkDm6MTV1dks5s2YKIgaJpZM4Qc3k3
.
Yes, You are right. It is used 13 times. Thanks for the help. You can close this case now.
I have one last question from this thread โ
<?php if ( true == get_theme_mod( 'newsletter_hp', true ) ) { ?>
I think we do not need to use โ esc_attr here, because we are not echoing anything. Right?
correct ๐