remove_control( 'background_color' ); // Theme uses it's own option for background color. $wp_customize->remove_section( 'background_image' ); // Theme not uses background image option in it's design for now. /** * Site Title. */ $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; /** * Site Logo. */ $wp_customize->selective_refresh->add_partial( 'custom_logo', array( 'selector' => '#site-header .site-logo', 'render_callback' => 'basho_header_logotype', ) ); $wp_customize->selective_refresh->add_partial( 'basho_retina_logo', array( 'selector' => '#site-header .site-logo', 'render_callback' => 'basho_header_logotype', ) ); /** * Add setting/control to enable retina logo option. */ $wp_customize->add_setting( 'basho_retina_logo', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'basho_retina_logo', array( 'type' => 'checkbox', 'section' => 'title_tagline', 'priority' => 10, 'label' => __( 'Retina logo', 'basho' ), 'description' => __( 'Scales the logo to half its uploaded size, making it sharp on high-res screens', 'basho' ), ) ); /** * Colors. */ /** * Site background color. */ $wp_customize->add_setting( 'basho_site_background_color', array( 'default' => '#ffffff', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basho_site_background_color', array( 'label' => __( 'Background Color', 'basho' ), 'description' => __( 'Make sure that the contrast is high enough so that the text is readable', 'basho' ), 'section' => 'colors', ) ) ); /** * Links color. */ $wp_customize->add_setting( 'basho_site_links_color', array( 'default' => '#3d3d3c', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basho_site_links_color', array( 'label' => __( 'Links Color', 'basho' ), 'description' => __( 'Make sure that the contrast is high enough and links are readable', 'basho' ), 'section' => 'colors', ) ) ); /** * Theme Settings Panel. */ $wp_customize->add_panel( 'basho_panel', array( 'priority' => 110, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __( 'Theme Settings', 'basho' ), ) ); $this->add_site_header_settings_section( $wp_customize ); $this->add_posts_page_settings_section( $wp_customize ); $this->add_single_post_settings_section( $wp_customize ); $this->add_site_footer_settings_section( $wp_customize ); } /** * Site Header Settings section. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ private function add_site_header_settings_section( $wp_customize ) { /** * Add section for the site header settings (header width, toggle search form display etc.). */ $wp_customize->add_section( 'basho_site_header_settings', array( 'title' => __( 'Site Header Settings', 'basho' ), 'priority' => 110, 'capability' => 'edit_theme_options', 'panel' => 'basho_panel', ) ); /** * Add setting/control to select site hader width. */ $wp_customize->add_setting( 'basho_site_header_width', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 'wide', ) ); $wp_customize->add_control( 'basho_site_header_width', array( 'type' => 'select', 'section' => 'basho_site_header_settings', 'label' => __( 'Width', 'basho' ), 'description' => __( 'Select site header width:', 'basho' ), 'choices' => array( 'small' => __( 'Small', 'basho' ), 'medium' => __( 'Medium', 'basho' ), 'wide' => __( 'Wide', 'basho' ), 'full-width' => __( 'Full Width', 'basho' ), ), ) ); /** * Make site header sticky. */ $wp_customize->add_setting( 'basho_sticky_header', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_sticky_header', array( 'type' => 'checkbox', 'section' => 'basho_site_header_settings', 'priority' => 10, 'label' => __( 'Make header sticky to the top of the screen', 'basho' ), ) ); /** * Display search form in the header of the website. */ $wp_customize->add_setting( 'basho_show_search_form', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_search_form', array( 'type' => 'checkbox', 'section' => 'basho_site_header_settings', 'priority' => 10, 'label' => __( 'Display search form', 'basho' ), 'description' => __( 'Otherwize only the seach icon will be shown', 'basho' ), ) ); } /** * Posts page Settings section. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ private function add_posts_page_settings_section( $wp_customize ) { /** * Add section for posts page options. */ $wp_customize->add_section( 'basho_posts_page_options', array( 'title' => __( 'Posts Page Settings', 'basho' ), 'priority' => 120, 'capability' => 'edit_theme_options', 'panel' => 'basho_panel', ) ); /** * Add setting/control to select archive hader width. */ $wp_customize->add_setting( 'basho_archive_header_width', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 'wide', ) ); $wp_customize->add_control( 'basho_archive_header_width', array( 'type' => 'select', 'section' => 'basho_posts_page_options', 'label' => __( 'Page header width', 'basho' ), 'description' => __( 'Select archive page header width:', 'basho' ), 'choices' => array( 'small' => __( 'Small', 'basho' ), 'medium' => __( 'Medium', 'basho' ), 'wide' => __( 'Wide', 'basho' ), 'full-width' => __( 'Full Width', 'basho' ), ), ) ); /** * Add setting/control to toggle blog categoires visibility. */ $wp_customize->add_setting( 'basho_show_blog_categories', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_blog_categories', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show categories', 'basho' ), 'description' => __( 'Will output blog categories on archive pages, they will be shown above blog posts.', 'basho' ), ) ); /** * Add setting/control to select loop container width. */ $wp_customize->add_setting( 'basho_loop_container_width', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 'wide', ) ); $wp_customize->add_control( 'basho_loop_container_width', array( 'type' => 'select', 'section' => 'basho_posts_page_options', 'label' => __( 'Posts container width', 'basho' ), 'description' => __( 'Select posts container width:', 'basho' ), 'choices' => array( 'small' => __( 'Small', 'basho' ), 'medium' => __( 'Medium', 'basho' ), 'wide' => __( 'Wide', 'basho' ), 'full-width' => __( 'Full Width', 'basho' ), ), ) ); /** * Add setting/control to select number of columns in the blog on extra small screens (phones in portrait mode). */ $wp_customize->add_setting( 'basho_blog_grid_columns_xs', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 2, ) ); $wp_customize->add_control( 'basho_blog_grid_columns_xs', array( 'type' => 'select', 'section' => 'basho_posts_page_options', 'label' => __( 'Columns on extra small screens', 'basho' ), 'description' => __( 'Select number of columns:', 'basho' ), 'choices' => array( 1 => 1, 2 => 2, ), ) ); /** * Add setting/control to select number of columns in the blog on small screens (phones in landscape mode). */ $wp_customize->add_setting( 'basho_blog_grid_columns_s', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 3, ) ); $wp_customize->add_control( 'basho_blog_grid_columns_s', array( 'type' => 'select', 'section' => 'basho_posts_page_options', 'label' => __( 'Columns on small screens', 'basho' ), 'description' => __( 'Select number of columns:', 'basho' ), 'choices' => array( 1 => 1, 2 => 2, 3 => 3, ), ) ); /** * Add setting/control to select number of columns in the blog on medium screens (tablets). */ $wp_customize->add_setting( 'basho_blog_grid_columns_m', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 4, ) ); $wp_customize->add_control( 'basho_blog_grid_columns_m', array( 'type' => 'select', 'section' => 'basho_posts_page_options', 'label' => __( 'Columns on medium screens', 'basho' ), 'description' => __( 'Select number of columns:', 'basho' ), 'choices' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, ), ) ); /** * Add setting/control to select number of columns in the blog on large screens (laptops). */ $wp_customize->add_setting( 'basho_blog_grid_columns_l', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 5, ) ); $wp_customize->add_control( 'basho_blog_grid_columns_l', array( 'type' => 'select', 'section' => 'basho_posts_page_options', 'label' => __( 'Columns on large screens', 'basho' ), 'description' => __( 'Select number of columns:', 'basho' ), 'choices' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, ), ) ); /** * Add setting/control to select number of columns in the blog on xlarge screens (large monitors). */ $wp_customize->add_setting( 'basho_blog_grid_columns_xl', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 6, ) ); $wp_customize->add_control( 'basho_blog_grid_columns_xl', array( 'type' => 'select', 'section' => 'basho_posts_page_options', 'label' => __( 'Columns on extra large screens', 'basho' ), 'description' => __( 'Select number of columns:', 'basho' ), 'choices' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, ), ) ); /** * Add custom control to display section title and description. */ $wp_customize->add_setting( 'basho_archive_entry_header_intro', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => '__return_true', ) ); $wp_customize->add_control( new Basho_Section_Intro_Control( $wp_customize, 'basho_archive_entry_header_intro', array( 'label' => __( 'Post meta before title', 'basho' ), 'section' => 'basho_posts_page_options', ) ) ); /** * Add setting/control to display categories before entry title on posts page. */ $wp_customize->add_setting( 'basho_show_categories_in_archive_entry_header', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_categories_in_archive_entry_header', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show categories', 'basho' ), ) ); /** * Add setting/control to display tags before entry title on posts page. */ $wp_customize->add_setting( 'basho_show_tags_in_archive_entry_header', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_tags_in_archive_entry_header', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show tags', 'basho' ), ) ); /** * Add setting/control to display post date before entry title on posts page. */ $wp_customize->add_setting( 'basho_show_post_date_in_archive_entry_header', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_post_date_in_archive_entry_header', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show post date', 'basho' ), ) ); /** * Add setting/control to display author before entry title on posts page. */ $wp_customize->add_setting( 'basho_show_author_in_archive_entry_header', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_author_in_archive_entry_header', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show author', 'basho' ), ) ); /** * Add setting/control to display comments link before entry title on posts page. */ $wp_customize->add_setting( 'basho_show_comments_in_archive_entry_header', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_comments_in_archive_entry_header', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show comments', 'basho' ), ) ); /** * Add custom control to display section title and description. */ $wp_customize->add_setting( 'basho_archive_content_intro', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => '__return_true', ) ); $wp_customize->add_control( new Basho_Section_Intro_Control( $wp_customize, 'basho_archive_content_intro', array( 'label' => __( 'Post excerpt', 'basho' ), 'section' => 'basho_posts_page_options', ) ) ); /** * Add setting/control to display post excerpt on posts page. */ $wp_customize->add_setting( 'basho_show_archive_excerpt', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_archive_excerpt', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show post excerpt', 'basho' ), ) ); /** * Add custom control to display section title and description. */ $wp_customize->add_setting( 'basho_archive_entry_footer_intro', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => '__return_true', ) ); $wp_customize->add_control( new Basho_Section_Intro_Control( $wp_customize, 'basho_archive_entry_footer_intro', array( 'label' => __( 'Post meta after excerpt', 'basho' ), 'section' => 'basho_posts_page_options', ) ) ); /** * Add setting/control to display categoreis in entry footer on posts page. */ $wp_customize->add_setting( 'basho_show_categories_in_archive_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_categories_in_archive_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show categories', 'basho' ), ) ); /** * Add setting/control to display tags in entry footer on posts page. */ $wp_customize->add_setting( 'basho_show_tags_in_archive_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_tags_in_archive_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show tags', 'basho' ), ) ); /** * Add setting/control to display post date in entry footer on posts page. */ $wp_customize->add_setting( 'basho_show_post_date_in_archive_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_post_date_in_archive_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show post date', 'basho' ), ) ); /** * Add setting/control to display author in entry footer on posts page. */ $wp_customize->add_setting( 'basho_show_author_in_archive_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_author_in_archive_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show author', 'basho' ), ) ); /** * Add setting/control to display comments link in entry footer on posts page. */ $wp_customize->add_setting( 'basho_show_comments_in_archive_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_comments_in_archive_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_posts_page_options', 'priority' => 10, 'label' => __( 'Show comments', 'basho' ), ) ); } /** * Single post Settings section. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ private function add_single_post_settings_section( $wp_customize ) { /** * Add section for the single post options. */ $wp_customize->add_section( 'basho_single_post_options', array( 'title' => __( 'Single Post Settings', 'basho' ), 'priority' => 120, 'capability' => 'edit_theme_options', 'panel' => 'basho_panel', ) ); /** * Add setting/control to select post hader width. */ $wp_customize->add_setting( 'basho_post_header_width', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 'small', ) ); $wp_customize->add_control( 'basho_post_header_width', array( 'type' => 'select', 'section' => 'basho_single_post_options', 'label' => __( 'Post header width', 'basho' ), 'description' => __( 'Select post header width:', 'basho' ), 'choices' => array( 'small' => __( 'Small', 'basho' ), 'medium' => __( 'Medium', 'basho' ), 'wide' => __( 'Wide', 'basho' ), 'full-width' => __( 'Full Width', 'basho' ), ), ) ); /** * Add setting/control to select post hader width. */ $wp_customize->add_setting( 'basho_display_post_featured_image', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_display_post_featured_image', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Display post featured image', 'basho' ), ) ); /** * Add custom control to display section title and description. */ $wp_customize->add_setting( 'basho_post_entry_header_top_intro', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => '__return_true', ) ); $wp_customize->add_control( new Basho_Section_Intro_Control( $wp_customize, 'basho_post_entry_header_top_intro', array( 'label' => __( 'Post meta before title', 'basho' ), 'section' => 'basho_single_post_options', ) ) ); /** * Add setting/control to display categoreis in 'entry-header-top' location on single post page. */ $wp_customize->add_setting( 'basho_show_categories_in_entry_header_top', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_categories_in_entry_header_top', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show categories', 'basho' ), ) ); /** * Add setting/control to display tags in 'entry-header-top' location on single post page. */ $wp_customize->add_setting( 'basho_show_tags_in_entry_header_top', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_tags_in_entry_header_top', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show tags', 'basho' ), ) ); /** * Add setting/control to display post date tags in 'entry-header-top' location on single post page. */ $wp_customize->add_setting( 'basho_show_post_date_in_entry_header_top', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_post_date_in_entry_header_top', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show post date', 'basho' ), ) ); /** * Add setting/control to display post author in 'entry-header-top' location on single post page. */ $wp_customize->add_setting( 'basho_show_author_in_entry_header_top', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_author_in_entry_header_top', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show author', 'basho' ), ) ); /** * Add setting/control to display comments link in 'entry-header-top' location on single post page. */ $wp_customize->add_setting( 'basho_show_comments_in_entry_header_top', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_comments_in_entry_header_top', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show comments', 'basho' ), ) ); /** * Add setting/control to display sticky text in 'entry-header-top' location on single post page. */ $wp_customize->add_setting( 'basho_show_sticky_in_entry_header_top', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_sticky_in_entry_header_top', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show that post is sticky', 'basho' ), ) ); /** * Add custom control to display section title and description. */ $wp_customize->add_setting( 'basho_post_post_excerpt_intro', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => '__return_true', ) ); $wp_customize->add_control( new Basho_Section_Intro_Control( $wp_customize, 'basho_post_post_excerpt_intro', array( 'label' => __( 'Post excerpt', 'basho' ), 'section' => 'basho_single_post_options', ) ) ); /** * Add setting/control to display excerpt on single post page. */ $wp_customize->add_setting( 'basho_show_post_excerpt', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_post_excerpt', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show post excerpt', 'basho' ), ) ); /** * Add custom control to display section title and description. */ $wp_customize->add_setting( 'basho_post_entry_header_bottom_intro', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => '__return_true', ) ); $wp_customize->add_control( new Basho_Section_Intro_Control( $wp_customize, 'basho_post_entry_header_bottom_intro', array( 'label' => __( 'Post meta after title', 'basho' ), 'section' => 'basho_single_post_options', ) ) ); /** * Add setting/control to display categoreis in 'entry-header-bottom' location on single post page. */ $wp_customize->add_setting( 'basho_show_categories_in_entry_header_bottom', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_categories_in_entry_header_bottom', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show categories', 'basho' ), ) ); /** * Add setting/control to display tags in 'entry-header-bottom' location on single post page. */ $wp_customize->add_setting( 'basho_show_tags_in_entry_header_bottom', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_tags_in_entry_header_bottom', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show tags', 'basho' ), ) ); /** * Add setting/control to display post date tags in 'entry-header-bottom' location on single post page. */ $wp_customize->add_setting( 'basho_show_post_date_in_entry_header_bottom', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_post_date_in_entry_header_bottom', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show post date', 'basho' ), ) ); /** * Add setting/control to display post author in 'entry-header-bottom' location on single post page. */ $wp_customize->add_setting( 'basho_show_author_in_entry_header_bottom', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_author_in_entry_header_bottom', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show author', 'basho' ), ) ); /** * Add setting/control to display comments link in 'entry-header-bottom' location on single post page. */ $wp_customize->add_setting( 'basho_show_comments_in_entry_header_bottom', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_comments_in_entry_header_bottom', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show comments', 'basho' ), ) ); /** * Add setting/control to display sticky text in 'entry-header-bottom' location on single post page. */ $wp_customize->add_setting( 'basho_show_sticky_in_entry_header_bottom', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_sticky_in_entry_header_bottom', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show that post is sticky', 'basho' ), ) ); /** * Add custom control to display section title and description. */ $wp_customize->add_setting( 'basho_post_entry_footer_intro', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => '__return_true', ) ); $wp_customize->add_control( new Basho_Section_Intro_Control( $wp_customize, 'basho_post_entry_footer_intro', array( 'label' => __( 'Post meta after content', 'basho' ), 'section' => 'basho_single_post_options', ) ) ); /** * Add setting/control to display categoreis in 'entry-footer' location on single post page. */ $wp_customize->add_setting( 'basho_show_categories_in_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_categories_in_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show categories', 'basho' ), ) ); /** * Add setting/control to display tags in 'entry-footer' location on single post page. */ $wp_customize->add_setting( 'basho_show_tags_in_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_tags_in_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show tags', 'basho' ), ) ); /** * Add setting/control to display post date tags in 'entry-footer' location on single post page. */ $wp_customize->add_setting( 'basho_show_post_date_in_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_post_date_in_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show post date', 'basho' ), ) ); /** * Add setting/control to display post author in 'entry-footer' location on single post page. */ $wp_customize->add_setting( 'basho_show_author_in_entry_footer', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_author_in_entry_footer', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show author', 'basho' ), ) ); /** * Add setting/control to display post navigation after post content. */ $wp_customize->add_setting( 'basho_show_post_navigation', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); $wp_customize->add_control( 'basho_show_post_navigation', array( 'type' => 'checkbox', 'section' => 'basho_single_post_options', 'priority' => 10, 'label' => __( 'Show post navigation', 'basho' ), ) ); } /** * Site footer Settings section. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ private function add_site_footer_settings_section( $wp_customize ) { /** * Add section for the site footer settings (footer width, padding, background color, etc.). */ $wp_customize->add_section( 'basho_site_footer_settings', array( 'title' => __( 'Site Footer Settings', 'basho' ), 'priority' => 130, 'capability' => 'edit_theme_options', 'panel' => 'basho_panel', ) ); /** * Add setting/control to select site footer width. */ $wp_customize->add_setting( 'basho_site_footer_width', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => array( __CLASS__, 'sanitize_select_field' ), 'default' => 'wide', ) ); $wp_customize->add_control( 'basho_site_footer_width', array( 'type' => 'select', 'section' => 'basho_site_footer_settings', 'label' => __( 'Width', 'basho' ), 'description' => __( 'Select site footer width:', 'basho' ), 'choices' => array( 'small' => __( 'Small', 'basho' ), 'medium' => __( 'Medium', 'basho' ), 'wide' => __( 'Wide', 'basho' ), 'full-width' => __( 'Full Width', 'basho' ), ), ) ); /** * Site footer background color. */ $wp_customize->add_setting( 'basho_site_footer_background_color', array( 'default' => '#ffffff', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basho_site_footer_background_color', array( 'label' => __( 'Background Color', 'basho' ), 'description' => __( 'Make sure that the contrast is high enough so that the text is readable', 'basho' ), 'section' => 'basho_site_footer_settings', ) ) ); /** * Site footer text color. */ $wp_customize->add_setting( 'basho_site_footer_text_color', array( 'default' => '#3d3d3c', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basho_site_footer_text_color', array( 'label' => __( 'Text Color', 'basho' ), 'description' => __( 'Make sure that the contrast is high enough and text is readable', 'basho' ), 'section' => 'basho_site_footer_settings', ) ) ); /** * Site footer links color. */ $wp_customize->add_setting( 'basho_site_footer_links_color', array( 'default' => '#3d3d3c', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basho_site_footer_links_color', array( 'label' => __( 'Links Color', 'basho' ), 'description' => __( 'Make sure that the contrast is high enough and links are readable', 'basho' ), 'section' => 'basho_site_footer_settings', ) ) ); } /** * Enqueue scripts for the Customizer preview. */ public function customize_preview() { global $basho_version; $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; wp_enqueue_script( 'basho-customize-preview', get_theme_file_uri( '/assets/js/basho-customize-preview' . $suffix . '.js' ), array( 'customize-preview', 'jquery' ), $basho_version, true ); } /** * Scripts to improve Customizer user experience. */ public function customize_controls_scripts() { ?> section of the website. */ public function customizer_css() { wp_add_inline_style( 'basho-style', $this->get_customizer_css( 'front-end' ) ); } /** * Add Customizer options CSS to to the section of the website to style Gutenberg blocks. */ public function block_editor_customizer_css() { wp_add_inline_style( 'basho-block-editor-style', $this->get_customizer_css( 'block-editor' ) ); } /** * Sanitize boolean for checkbox. * * @param bool $checked Whether or not a box is checked. * * @return bool */ public static function sanitize_checkbox( $checked ) { return ( ( isset( $checked ) && true === $checked ) ? true : false ); } /** * Sanitize boolean for radio. * * @return bool */ public static function sanitize_radio_field( $input, $setting ) { // Input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only. $input = sanitize_key( $input ); // Get the list of possible radio box options. $choices = $setting->manager->get_control( $setting->id )->choices; // Return input if valid or return default option. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } /** * Sanitize select field value. * * @return string */ public static function sanitize_select_field( $input, $setting ) { // Ensure input is a slug. $input = sanitize_key( $input ); // Get list of choices from the control associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } /** * Get CSS Built from Customizer Options. This function I took from TwentyTwenty WordPress theme. * Build CSS reflecting colors, fonts and other options set in the Customizer, and return them for output. * * @param string $type Whether to return CSS for the "front-end", "block-editor" or "classic-editor". */ public function get_customizer_css( $type = 'front-end' ) { // Site background. $body_bg = sanitize_hex_color( get_theme_mod( 'basho_site_background_color' ) ); $body_bg_default = '#ffffff'; // Links Color. $links_color = sanitize_hex_color( get_theme_mod( 'basho_site_links_color' ) ); $links_default_color = '#3d3d3c'; // Site footer background. $site_footer_bg = sanitize_hex_color( get_theme_mod( 'basho_site_footer_background_color' ) ); $site_footer_bg_default = '#ffffff'; // Site footer text color. $site_footer_color = sanitize_hex_color( get_theme_mod( 'basho_site_footer_text_color' ) ); $site_footer_color_default = '#3d3d3c'; // Site footer links color. $site_footer_links_color = sanitize_hex_color( get_theme_mod( 'basho_site_footer_links_color' ) ); $site_footer_links_color_default = '#3d3d3c'; ob_start(); // Front-End Styles. if ( 'front-end' === $type ) { // Site, primary navigation and .comments-wrapper background. if ( $body_bg && ($body_bg !== $body_bg_default) ) { basho_generate_css( 'html, body', 'background-color', $body_bg ); basho_generate_css( '#offcanvas-navigation .uk-offcanvas-bar', 'background-color', $body_bg ); basho_generate_css( '#site-header.uk-background-default', 'background-color', $body_bg ); basho_generate_css( '.uk-navbar-dropdown', 'background-color', $body_bg ); basho_generate_css( '.uk-modal .uk-modal-dialog', 'background-color', $body_bg ); basho_generate_css( '.comments-wrapper', 'background-color', $body_bg ); basho_generate_css( '.search-query', 'background-color', basho_adjust_color_brightness( $body_bg, 20 ) ); basho_generate_css( '.uk-background-default', 'background-color', $body_bg ); basho_generate_css( 'form input', 'background-color', basho_adjust_color_brightness( $body_bg, 20 ), '', '!important' ); basho_generate_css( '.footer-social-menu a', 'background-color', $body_bg ); } // Links color. if ( $links_color && ($links_color !== $links_default_color) ) { // Links color. basho_generate_css( 'a, .uk-link', 'color', $links_color ); basho_generate_css( 'a:hover, a:focus, .uk-link:hover, .uk-link:focus', 'color', basho_adjust_color_brightness( $links_color, -50 ) ); basho_generate_css( '.wp-block-button__link:not(.has-text-color)', 'color', $links_color ); basho_generate_css( '.wp-block-button__link:not(.has-text-color):hover, .wp-block-button__link:not(.has-text-color):focus', 'color', basho_adjust_color_brightness( $links_color, -50 ) ); } // Site footer background. if ( $site_footer_bg && ($site_footer_bg !== $site_footer_bg_default) ) { basho_generate_css( '.footer-widgets-area, #site-footer, .footer-social-menu a', 'background-color', $site_footer_bg ); } // Site footer text color. if ( $site_footer_color && ($site_footer_color !== $site_footer_color_default) ) { basho_generate_css( '.footer-widgets-area, .footer-widgets-area .widget-title, #site-footer', 'color', $site_footer_color ); } // Site footer links color. if ( $site_footer_links_color && ($site_footer_links_color !== $site_footer_links_color_default) ) { basho_generate_css( '.footer-widgets-area a, #site-footer a', 'color', $site_footer_links_color ); } // Block Editor Styles. } elseif ( 'block-editor' === $type ) { // Background color. if ( $body_bg && ($body_bg !== $body_bg_default) ) { basho_generate_css( '.editor-styles-wrapper', 'background-color', $body_bg ); } // Links color. if ( $links_color && ($links_color !== $links_default_color) ) { // Links color. basho_generate_css( '.editor-styles-wrapper a', 'color', $links_color ); basho_generate_css( '.editor-styles-wrapper a:hover, .editor-styles-wrapper a:focus', 'color', basho_adjust_color_brightness( $links_color, -50 ) ); basho_generate_css( '.wp-block-freeform.block-library-rich-text__tinymce a', 'color', $links_color ); basho_generate_css( '.wp-block-freeform.block-library-rich-text__tinymce a:hover, .wp-block-freeform.block-library-rich-text__tinymce a:focus', 'color', basho_adjust_color_brightness( $links_color, -50 ) ); } } // Return the results. return ob_get_clean(); } } } return new Basho_Customizer();