add_panel( 'napoli_options_panel', array( 'priority' => 180, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => esc_html__( 'Theme Options', 'napoli' ), 'description' => napoli_customize_theme_links(), ) ); // Change default background section. $wp_customize->get_control( 'background_color' )->section = 'background_image'; $wp_customize->get_section( 'background_image' )->title = esc_html__( 'Background', 'napoli' ); // Add postMessage support for site title and description. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; // Add selective refresh for site title and description. $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'napoli_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'napoli_customize_partial_blogdescription', ) ); // Add Display Site Title Setting. $wp_customize->add_setting( 'napoli_theme_options[site_title]', array( 'default' => true, 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'napoli_sanitize_checkbox', ) ); $wp_customize->add_control( 'napoli_theme_options[site_title]', array( 'label' => esc_html__( 'Display Site Title', 'napoli' ), 'section' => 'title_tagline', 'settings' => 'napoli_theme_options[site_title]', 'type' => 'checkbox', 'priority' => 10, ) ); // Add Display Tagline Setting. $wp_customize->add_setting( 'napoli_theme_options[site_description]', array( 'default' => false, 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'napoli_sanitize_checkbox', ) ); $wp_customize->add_control( 'napoli_theme_options[site_description]', array( 'label' => esc_html__( 'Display Tagline', 'napoli' ), 'section' => 'title_tagline', 'settings' => 'napoli_theme_options[site_description]', 'type' => 'checkbox', 'priority' => 11, ) ); } // napoli_customize_register_options() add_action( 'customize_register', 'napoli_customize_register_options' ); /** * Render the site title for the selective refresh partial. */ function napoli_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. */ function napoli_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Embed JS file to make Theme Customizer preview reload changes asynchronously. */ function napoli_customize_preview_js() { wp_enqueue_script( 'napoli-customizer-preview', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20161214', true ); } add_action( 'customize_preview_init', 'napoli_customize_preview_js' ); /** * Embed CSS styles for the theme options in the Customizer */ function napoli_customize_preview_css() { wp_enqueue_style( 'napoli-customizer-css', get_template_directory_uri() . '/css/customizer.css', array(), '20161214' ); } add_action( 'customize_controls_print_styles', 'napoli_customize_preview_css' ); /** * Returns Theme Links */ function napoli_customize_theme_links() { ob_start(); ?>