add_panel( 'bizstrait_gen_setting', [ 'priority' => 30, 'capability' => 'edit_theme_options', 'title' => __('General', 'bizstrait'), ] ); /* Blog Section */ $wp_customize->add_section( 'bizstrait_general_blog_Section', [ 'priority' => 1, 'title' => __('Blogs', 'bizstrait'), 'panel' => 'bizstrait_gen_setting', ] ); /* Color Section */ $wp_customize->add_section( 'colors', [ 'priority' => 1, 'title' => __('Colors', 'bizstrait'), 'panel' => 'bizstrait_gen_setting', ] ); $wp_customize->get_setting('background_color')->default = '#fff'; // date $wp_customize->add_setting('date_meta_display', [ 'default' => true, 'sanitize_callback' => 'bizstrait_switch_sanitization' ] ); $wp_customize->add_control(new Bizstrait_Toggle_Switch_Custom_Control($wp_customize, 'date_meta_display', [ 'label' => __('Date', 'bizstrait'), 'section' => 'bizstrait_general_blog_Section' ] )); // author $wp_customize->add_setting('author_meta_display', [ 'default' => true, 'sanitize_callback' => 'bizstrait_switch_sanitization' ] ); $wp_customize->add_control(new Bizstrait_Toggle_Switch_Custom_Control($wp_customize, 'author_meta_display', [ 'label' => __('Author', 'bizstrait'), 'section' => 'bizstrait_general_blog_Section' ] )); // category $wp_customize->add_setting('cat_meta_display', [ 'default' => true, 'sanitize_callback' => 'bizstrait_switch_sanitization' ] ); $wp_customize->add_control(new Bizstrait_Toggle_Switch_Custom_Control($wp_customize, 'cat_meta_display', [ 'label' => __('Category', 'bizstrait'), 'section' => 'bizstrait_general_blog_Section' ] )); //Button: Read More $wp_customize->add_setting('bizstrait_readmore_button_txt', [ 'capability' => 'edit_theme_options', 'default' => 'Read More', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('bizstrait_readmore_button_txt', [ 'type' => 'text', 'section' => 'bizstrait_general_blog_Section', // Add a default or your own section 'label' => __('Button Text', 'bizstrait'), 'description' => __('Change text of "Read More" button', 'bizstrait'), ]); /* Archive Sidebar type */ $wp_customize->add_setting('bizstrait_archive_sidebar_type', [ 'default' => esc_html__('right-sidebar', 'bizstrait'), 'sanitize_callback' => 'bizstrait_sanitize_select' ] ); $wp_customize->add_control('bizstrait_archive_sidebar_type', [ 'label' => esc_html__('Archive Blog Page Layout', 'bizstrait'), 'section' => 'bizstrait_general_blog_Section', 'description'=> 'The sidebar disappears if no widget assigned', 'type' => 'select', 'choices' => [ 'right-sidebar' => esc_html__('Right sidebar', 'bizstrait'), 'left-sidebar' => esc_html__('Left sidebar', 'bizstrait'), 'full-width' => esc_html__('No sidebar', 'bizstrait'), ] ] ); /* Single Blog page sidebar type */ $wp_customize->add_setting('bizstrait_single_blog_sidebar_type', [ 'default' => esc_html__('right-sidebar', 'bizstrait'), 'sanitize_callback' => 'bizstrait_sanitize_select' ] ); $wp_customize->add_control('bizstrait_single_blog_sidebar_type', [ 'label' => esc_html__('Single Blog Page Layout', 'bizstrait'), 'section' => 'bizstrait_general_blog_Section', // 'description'=> 'Default does not need any plugin, rest need respective plugins', 'type' => 'select', 'description'=> 'The sidebar disappears if no widget assigned', 'choices' => [ 'right-sidebar' => esc_html__('Right sidebar', 'bizstrait'), 'left-sidebar' => esc_html__('Left sidebar', 'bizstrait'), 'full-width' => esc_html__('No sidebar', 'bizstrait'), ] ] ); if (!function_exists('bizstrait_switch_sanitization')) { function bizstrait_switch_sanitization($input) { if (true === $input) { return 1; } else { return 0; } } } if (!function_exists('bizstrait_sanitize_select')) { function bizstrait_sanitize_select($input, $setting) { $input = sanitize_key($input); $choices = $setting->manager->get_control($setting->id)->choices; return ( array_key_exists($input, $choices) ? $input : $setting->default ); } } } add_action('customize_register', 'bizstrait_gen_customizer_setting');