Hi I am adding options to WP Customize.
Mostly everything works, but One of my variable is not refreshed in the preview window.
$wp_customize->add_setting('checkbox', array(
'capability' => 'edit_theme_options',
'default' => false,
));
$wp_customize->add_control('checkbox_control', array(
'settings' => 'checkbox',
'label' => __('Activate Coming Soon Page', 'ln'),
'section' => 'general_settings',
'type' => 'checkbox',
'priority' => 1,
));
This is how I add the checkbox and here is my check in functions.php
function template_redirect() {
if(true == get_theme_mod('checkbox')) {
include (TEMPLATEPATH . '/coming-soon.php');
exit;
}
}
add_action( 'template_redirect', 'template_redirect' );
So everything works. ~The only problem is that the preview window when you are in WP Customize and click the checkbox it reloads the page but it doesn't shows the change. If I click save and refresh manually then everything is fine.
Any suggestion how to fix this issue?
Thank you
UPDATE:
I found what is breaking WP CUSTOMIZER, it is the exit of the redirect. Is there another way how to fix this issue. I need to redirect to that page if the checkbox is TRUE
function template_redirect() {
if(true == get_theme_mod('checkbox')) {
include (TEMPLATEPATH . '/coming-soon.php');
exit; !!!!!!!!!!!!!!!!!
}
}
add_action( 'template_redirect', 'template_redirect' );