get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; // Add search toggle setting. $wp_customize->add_setting( 'brevity_show_search', array( 'default' => false, 'sanitize_callback' => 'brevity_sanitize_checkbox', ) ); $wp_customize->add_control( 'brevity_show_search', array( 'label' => esc_html__( 'Show search icon in header', 'brevity' ), 'section' => 'title_tagline', 'type' => 'checkbox', 'priority' => 30, ) ); // Add footer columns setting. $wp_customize->add_section( 'brevity_footer', array( 'title' => esc_html__( 'Footer Settings', 'brevity' ), 'priority' => 160, ) ); $wp_customize->add_setting( 'brevity_footer_columns', array( 'default' => 4, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'brevity_footer_columns', array( 'label' => esc_html__( 'Footer columns', 'brevity' ), 'section' => 'brevity_footer', 'type' => 'select', 'choices' => array( '1' => esc_html__( '1 column', 'brevity' ), '2' => esc_html__( '2 columns', 'brevity' ), '3' => esc_html__( '3 columns', 'brevity' ), '4' => esc_html__( '4 columns', 'brevity' ), ), ) ); // Add Front Page Magazine Settings section. $wp_customize->add_section( 'brevity_front_page', array( 'title' => esc_html__( 'Front Page Settings', 'brevity' ), 'priority' => 150, ) ); // Get all categories for dropdown. $categories = get_categories( array( 'hide_empty' => false ) ); $category_choices = array( '0' => esc_html__( '— Select —', 'brevity' ) ); foreach ( $categories as $category ) { $category_choices[ $category->term_id ] = $category->name; } // Hero section category. $wp_customize->add_setting( 'brevity_front_page_hero_category', array( 'default' => 0, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'brevity_front_page_hero_category', array( 'label' => esc_html__( 'Hero Section Category', 'brevity' ), 'description' => esc_html__( 'Select the category to display in the hero section (mosaic grid).', 'brevity' ), 'section' => 'brevity_front_page', 'type' => 'select', 'choices' => $category_choices, ) ); // Category section 1. $wp_customize->add_setting( 'brevity_front_page_category_1', array( 'default' => 0, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'brevity_front_page_category_1', array( 'label' => esc_html__( 'Category Section 1', 'brevity' ), 'description' => esc_html__( 'Select the first category to display in a horizontal block.', 'brevity' ), 'section' => 'brevity_front_page', 'type' => 'select', 'choices' => $category_choices, ) ); // Category section 2. $wp_customize->add_setting( 'brevity_front_page_category_2', array( 'default' => 0, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'brevity_front_page_category_2', array( 'label' => esc_html__( 'Category Section 2', 'brevity' ), 'description' => esc_html__( 'Select the second category to display in a horizontal block.', 'brevity' ), 'section' => 'brevity_front_page', 'type' => 'select', 'choices' => $category_choices, ) ); if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'brevity_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'brevity_customize_partial_blogdescription', ) ); } } add_action( 'customize_register', 'brevity_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function brevity_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function brevity_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function brevity_customize_preview_js() { wp_enqueue_script( 'brevity-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), BREVITY_VERSION, true ); } add_action( 'customize_preview_init', 'brevity_customize_preview_js' );