get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'blog_town_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'blog_town_customize_partial_blogdescription', ) ); } /*BlogTown Option Panel*/ $wp_customize->add_panel( 'blog_town_theme_options', array( 'title' => __( 'BlogTown Theme Options', 'blog-town' ), 'priority' => 1, ) ); /*Top Header Options Section*/ $wp_customize->add_section( 'blog_town_top_header_options', array ( 'title' => __( 'Top Header Options', 'blog-town' ), 'panel' => 'blog_town_theme_options', 'priority' => 10, 'description' => __( 'Personalize the settings top header.', 'blog-town' ), ) ); // Top Header Display Control $wp_customize->add_setting ( 'blog_town_top_header_display', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_top_header_display', array ( 'label' => __( 'Display Top Header', 'blog-town' ), 'section' => 'blog_town_top_header_options', 'priority' => 1, 'type' => 'checkbox', ) ); // Top Header Latest Posts Display Control $wp_customize->add_setting ( 'blog_town_latest_post_display', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_latest_post_display', array ( 'label' => __( 'Display Latest Posts', 'blog-town' ), 'section' => 'blog_town_top_header_options', 'priority' => 5, 'type' => 'checkbox', 'active_callback' => 'blog_town_header_active_callback' ) ); // Top Header Date Display Control $wp_customize->add_setting ( 'blog_town_date_display', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_date_display', array ( 'label' => __( 'Display Date', 'blog-town' ), 'section' => 'blog_town_top_header_options', 'priority' => 10, 'type' => 'checkbox', 'active_callback' => 'blog_town_header_active_callback' ) ); /*Header Social Option*/ $wp_customize->add_section( 'blog_town_header_social', array ( 'title' => __( 'Header Social Options', 'blog-town' ), 'panel' => 'blog_town_theme_options', 'priority' => 20, 'description' => __( 'Personalize the header social icon of your theme.', 'blog-town' ), ) ); // Top Header Menu Social Icon Display Control $wp_customize->add_setting ( 'blog_town_header_social_icon_display', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_header_social_icon_display', array ( 'label' => __( 'Display Header Social Icons', 'blog-town' ), 'section' => 'blog_town_header_social', 'priority' => 1, 'type' => 'checkbox', //'active_callback' => 'blog_town_header_active_callback' ) ); // Facebook URL $wp_customize->add_setting ( 'blog_town_social_icon_fb_url', array( 'default' => __( '#', 'blog-town' ), 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control ( 'blog_town_social_icon_fb_url', array( 'label' => __( 'Facebook URL', 'blog-town' ), 'section' => 'blog_town_header_social', 'priority' => 9, 'type' => 'url', 'active_callback' => 'blog_town_header_social_active_callback' ) ); // Twitter URL $wp_customize->add_setting ( 'blog_town_social_icon_twitter_url', array( 'default' => __( '#', 'blog-town' ), 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control ( 'blog_town_social_icon_twitter_url', array( 'label' => __( 'Twitter URL', 'blog-town' ), 'section' => 'blog_town_header_social', 'priority' => 10, 'type' => 'url', 'active_callback' => 'blog_town_header_social_active_callback' ) ); // Instagram URL $wp_customize->add_setting ( 'blog_town_social_icon_insta_url', array( 'default' => __( '#', 'blog-town' ), 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control ( 'blog_town_social_icon_insta_url', array( 'label' => __( 'Instagram URL', 'blog-town' ), 'section' => 'blog_town_header_social', 'priority' => 12, 'type' => 'url', 'active_callback' => 'blog_town_header_social_active_callback' ) ); // Social URL Target Display Control $wp_customize->add_setting ( 'blog_town_social_icon_target_display', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_social_icon_target_display', array ( 'label' => __( 'Display Social URL in new Window', 'blog-town' ), 'section' => 'blog_town_header_social', 'priority' => 15, 'type' => 'checkbox', 'active_callback' => 'blog_town_header_social_active_callback' ) ); /*Slider Section*/ $wp_customize->add_section('blog_town_slider_section', array( 'title' => __('Slider Options', 'blog-town') , 'panel' => 'blog_town_theme_options', 'priority' => 30 )); $wp_customize->add_setting('blog_town_slider_display', array( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', )); $wp_customize->add_control('blog_town_slider_display', array( 'label' => esc_html__('Display Slider', 'blog-town') , 'section' => 'blog_town_slider_section', 'priority' => 10, 'type' => 'checkbox', )); /*category post*/ $categories = get_categories(); $category = array(); $k = 0; foreach ($categories as $cat) { if ($k == 0) { $default = $cat->slug; $k++; } $category[$cat->slug] = $cat->name; } $wp_customize->add_setting('blog_town_feature_category', array( 'default' => $default, 'sanitize_callback' => 'blog_town_sanitize_select', )); $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'blog_town_feature_category', array( 'label' => 'Select category for slider', 'description' => '', 'section' => 'blog_town_slider_section', 'settings' => 'blog_town_feature_category', 'priority' => 20, 'type' => 'select', 'choices' => $category, 'active_callback' => 'blog_town_slider_callback' ))); // Number of post $wp_customize->add_setting('blog_town_number_of_post', array( 'default' => 5, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('blog_town_number_of_post', array( 'label' => esc_html__('Number of Post', 'blog-town') , 'section' => 'blog_town_slider_section', 'priority' => 30, 'type' => 'number', 'active_callback' => 'blog_town_slider_callback' )); /*General Options Section*/ $wp_customize->add_section( 'blog_town_general_options', array ( 'title' => __( 'General Options', 'blog-town' ), 'panel' => 'blog_town_theme_options', 'priority' => 40, 'description' => __( 'Personalize the settings of your theme.', 'blog-town' ), ) ); // Read More Label $wp_customize->add_setting ( 'blog_town_read_more_label', array( 'default' => __( 'Read More', 'blog-town' ), 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control ( 'blog_town_read_more_label', array( 'label' => __( 'Read More Label', 'blog-town' ), 'section' => 'blog_town_general_options', 'priority' => 1, 'type' => 'text', ) ); // Excerpt Length $wp_customize->add_setting ( 'blog_town_excerpt_length', array( 'default' => __( '55', 'blog-town' ), 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control ( 'blog_town_excerpt_length', array( 'label' => __( 'Excerpt Length', 'blog-town' ), 'description' => __( '0 length will not show the excerpt.', 'blog-town' ), 'section' => 'blog_town_general_options', 'priority' => 2, 'type' => 'number', ) ); /*layout options*/ $wp_customize->add_section( 'blog_town_layout_options', array ( 'title' => __( 'Layout Options', 'blog-town' ), 'panel' => 'blog_town_theme_options', 'priority' => 50, 'description' => __( 'Personalize the layout settings of your theme.', 'blog-town' ), ) ); // Theme Layout $wp_customize->add_setting ( 'blog_town_theme_layout', array( 'default' => __('wide', 'blog-town' ), 'sanitize_callback' => 'blog_town_sanitize_select', ) ); $wp_customize->add_control ( 'blog_town_theme_layout', array( 'label' => __( 'Theme Layout', 'blog-town' ), 'description' => __( 'Box layout will be visible at minimum 1200px display', 'blog-town' ), 'section' => 'blog_town_layout_options', 'priority' => 1, 'type' => 'select', 'choices' => array( 'wide' => __( 'Wide', 'blog-town' ), 'box' => __( 'Box', 'blog-town' ), ), ) ); // Main Sidebar Position $wp_customize->add_setting ( 'blog_town_sidebar_position', array ( 'default' => __( 'right', 'blog-town' ), 'sanitize_callback' => 'blog_town_sanitize_select', ) ); $wp_customize->add_control ( 'blog_town_sidebar_position', array ( 'label' => __( 'Sidebar Position', 'blog-town' ), 'section' => 'blog_town_layout_options', 'priority' => 2, 'type' => 'select', 'choices' => array( 'right' => __( 'Right Sidebar', 'blog-town'), 'left' => __( 'Left Sidebar', 'blog-town'), 'no' => __( 'No Sidebar', 'blog-town'), ), ) ); /*Blog Post Options*/ $wp_customize->add_section( 'blog_town_archive_content_options', array ( 'title' => __( 'Blog Post Options', 'blog-town' ), 'panel' => 'blog_town_theme_options', 'priority' => 60, 'description' => __( 'Setting will also apply on archieve and search page.', 'blog-town' ), ) ); // Post Author Display Control $wp_customize->add_setting ( 'blog_town_archive_post_author', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_archive_post_author', array ( 'label' => __( 'Display Author', 'blog-town' ), 'section' => 'blog_town_archive_content_options', 'priority' => 2, 'type' => 'checkbox', ) ); // Post Date Display Control $wp_customize->add_setting ( 'blog_town_archive_post_date', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_archive_post_date', array ( 'label' => __( 'Display Date', 'blog-town' ), 'section' => 'blog_town_archive_content_options', 'priority' => 3, 'type' => 'checkbox', ) ); // Post Comments Display Control $wp_customize->add_setting ( 'blog_town_post_view_count', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_post_view_count', array ( 'label' => __( 'Display Post View Count', 'blog-town' ), 'section' => 'blog_town_archive_content_options', 'priority' => 4, 'type' => 'checkbox', ) ); // Post Comments Display Control $wp_customize->add_setting ( 'blog_town_archive_post_comments', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_archive_post_comments', array ( 'label' => __( 'Display Comments Count', 'blog-town' ), 'section' => 'blog_town_archive_content_options', 'priority' => 5, 'type' => 'checkbox', ) ); // Featured Image Archive Control $wp_customize->add_setting ( 'blog_town_archive_featured_image', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_archive_featured_image', array ( 'label' => __( 'Display Featured Image', 'blog-town' ), 'section' => 'blog_town_archive_content_options', 'priority' => 6, 'type' => 'checkbox', ) ); /*Single Post Options*/ $wp_customize->add_section( 'blog_town_single_content_options', array ( 'title' => __( 'Single Post Options', 'blog-town' ), 'panel' => 'blog_town_theme_options', 'priority' => 70, 'description' => __( 'Setting will apply on the content of single posts.', 'blog-town' ), ) ); // Post Categories Display Control $wp_customize->add_setting ( 'blog_town_single_post_categories', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_single_post_categories', array ( 'label' => __( 'Display Categories', 'blog-town' ), 'section' => 'blog_town_single_content_options', 'priority' => 1, 'type' => 'checkbox', ) ); // Post Date Display Control $wp_customize->add_setting ( 'blog_town_single_post_date', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_single_post_date', array ( 'label' => __( 'Display Date', 'blog-town' ), 'section' => 'blog_town_single_content_options', 'priority' => 2, 'type' => 'checkbox', ) ); // Post Author Display Control $wp_customize->add_setting ( 'blog_town_single_post_view', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_single_post_view', array ( 'label' => __( 'Display Post View Count', 'blog-town' ), 'section' => 'blog_town_single_content_options', 'priority' => 3, 'type' => 'checkbox', ) ); // Single Post Comments Display Control $wp_customize->add_setting ( 'blog_town_single_post_comments', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_single_post_comments', array ( 'label' => __( 'Display Comments Count', 'blog-town' ), 'section' => 'blog_town_single_content_options', 'priority' => 4, 'type' => 'checkbox', ) ); // Single Post Tags Display Control $wp_customize->add_setting ( 'blog_town_single_post_tags', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_single_post_tags', array ( 'label' => __( 'Display Tags', 'blog-town' ), 'section' => 'blog_town_single_content_options', 'priority' => 5, 'type' => 'checkbox', ) ); // Featured Image Post Display Control $wp_customize->add_setting ( 'blog_town_single_featured_image', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_single_featured_image', array ( 'label' => __( 'Display Featured Image', 'blog-town' ), 'section' => 'blog_town_single_content_options', 'priority' => 7, 'type' => 'checkbox', ) ); /*Footer Option*/ $wp_customize->add_section( 'blog_town_footer_options', array ( 'title' => __( 'Footer Options', 'blog-town' ), 'panel' => 'blog_town_theme_options', 'priority' => 80, 'description' => __( 'Personalize the footer settings of your theme.', 'blog-town' ), ) ); // Top Header Display Control $wp_customize->add_setting ( 'blog_town_footer_copyright_display', array ( 'default' => true, 'sanitize_callback' => 'blog_town_sanitize_checkbox', ) ); $wp_customize->add_control ( 'blog_town_footer_copyright_display', array ( 'label' => __( 'Display Copyright Footer', 'blog-town' ), 'section' => 'blog_town_footer_options', 'priority' => 1, 'type' => 'checkbox', ) ); // Copyright Control $wp_customize->add_setting ( 'blog_town_copyright_content', array ( 'default' => __( 'Copyright © 2021 BlogTown Powered by WordPress.', 'blog-town' ), 'sanitize_callback' => 'wp_kses_post', ) ); $wp_customize->add_control ( 'blog_town_copyright_content', array ( 'label' => __( 'Copyright', 'blog-town' ), 'section' => 'blog_town_footer_options', 'priority' => 2, 'type' => 'textarea', 'active_callback' => 'blog_town_footer_copyright_callback' ) ); } add_action( 'customize_register', 'blog_town_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function blog_town_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function blog_town_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function blog_town_customize_preview_js() { wp_enqueue_script( 'blog-town-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), BLOG_TOWN_S_VERSION, true ); } add_action( 'customize_preview_init', 'blog_town_customize_preview_js' ); /*callback function for top header section*/ if ( !function_exists('blog_town_header_active_callback') ) : function blog_town_header_active_callback(){ $show_topheader = get_theme_mod('blog_town_top_header_display',true); if( true == $show_topheader ){ return true; } else{ return false; } } endif; if ( !function_exists('blog_town_footer_copyright_callback') ) : function blog_town_footer_copyright_callback(){ $show_copyright = get_theme_mod('blog_town_footer_copyright_display',true); if( true == $show_copyright ){ return true; } else{ return false; } } endif; if ( !function_exists('blog_town_header_social_active_callback') ) : function blog_town_header_social_active_callback(){ $show_social = get_theme_mod('blog_town_header_social_icon_display',true); if( $show_social ){ return true; } else{ return false; } } endif; if (!function_exists('blog_town_slider_callback')): function blog_town_slider_callback() { $display_slider = get_theme_mod('blog_town_slider_display', true); if (true == $display_slider) { return true; } else { return false; } } endif;