remove_control( 'display_header_text' ); // Add postMessage support for site title and description. $transport = ( $wp_customize->selective_refresh) ? 'postMessage' : 'refresh'; $wp_customize->get_setting( 'blogname' )->transport = $transport; $wp_customize->get_setting( 'blogdescription' )->transport = $transport; // Selective refresh for previewing the site title and tagline. $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'jgtbloginn_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'jgtbloginn_customize_partial_blogdescription', ) ); /** * Site Identity Section. */ // Double size logo for Retina devices. $wp_customize->add_setting( 'jgtbloginn_logo_retina', array( 'sanitize_callback' => 'jgtbloginn_sanitize_checkbox' ) ); $wp_customize->add_control( 'jgtbloginn_logo_retina', array( 'label' => esc_html__( 'Check if you use double sized logo.', 'bloginn' ), 'section' => 'title_tagline', 'settings' => 'jgtbloginn_logo_retina', 'type' => 'checkbox', 'priority' => 9 ) ); // Hide site title. $wp_customize->add_setting( 'jgtbloginn_hide_site_title', array( 'sanitize_callback' => 'jgtbloginn_sanitize_checkbox' ) ); $wp_customize->add_control( 'jgtbloginn_hide_site_title', array( 'label' => esc_html__( 'Hide Site Title.', 'bloginn' ), 'section' => 'title_tagline', 'settings' => 'jgtbloginn_hide_site_title', 'type' => 'checkbox' ) ); // Hide tagline. $wp_customize->add_setting( 'jgtbloginn_hide_tagline', array( 'sanitize_callback' => 'jgtbloginn_sanitize_checkbox' ) ); $wp_customize->add_control( 'jgtbloginn_hide_tagline', array( 'label' => esc_html__( 'Hide Tagline.', 'bloginn' ), 'section' => 'title_tagline', 'settings' => 'jgtbloginn_hide_tagline', 'type' => 'checkbox' ) ); /** * Colors Section. */ // Theme accent colors. $wp_customize->add_setting( 'jgtbloginn_primary_color', array( 'default' => '#22b3eb', 'sanitize_callback' => 'sanitize_hex_color' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'jgtbloginn_primary_color', array( 'label' => esc_html__( 'Primary Color', 'bloginn' ), 'section' => 'colors', 'settings' => 'jgtbloginn_primary_color' ) ) ); $wp_customize->add_setting( 'jgtbloginn_secondary_color', array( 'default' => '#5ec5f0', 'sanitize_callback' => 'sanitize_hex_color' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'jgtbloginn_secondary_color', array( 'label' => esc_html__( 'Secondary Color', 'bloginn' ), 'section' => 'colors', 'settings' => 'jgtbloginn_secondary_color' ) ) ); /** * Theme Options Section. */ $wp_customize->add_section( 'jgtbloginn_theme_options', array( 'title' => esc_html__( 'Theme Options', 'bloginn' ), 'priority' => 200 ) ); // Logo and content animation $wp_customize->add_setting( 'jgtbloginn_content_fadein', array( 'sanitize_callback' => 'jgtbloginn_sanitize_checkbox' ) ); $wp_customize->add_control( 'jgtbloginn_content_fadein', array( 'label' => esc_html__( 'Enable logo and content animation on page load.', 'bloginn' ), 'section' => 'jgtbloginn_theme_options', 'settings' => 'jgtbloginn_content_fadein', 'type' => 'checkbox' ) ); // Show automatically generated excerpts. $wp_customize->add_setting( 'jgtbloginn_auto_excerpt', array( 'sanitize_callback' => 'jgtbloginn_sanitize_checkbox' ) ); $wp_customize->add_control( 'jgtbloginn_auto_excerpt', array( 'label' => esc_html__( 'Generate excerpts automatically.', 'bloginn' ), 'section' => 'jgtbloginn_theme_options', 'settings' => 'jgtbloginn_auto_excerpt', 'type' => 'checkbox' ) ); // Excerpts length. $wp_customize->add_setting( 'jgtbloginn_excerpt_length', array( 'default' => '55', 'sanitize_callback' => 'jgtbloginn_sanitize_integer' ) ); $wp_customize->add_control( 'jgtbloginn_excerpt_length', array( 'label' => esc_html__( 'Excerpt Length', 'bloginn' ), 'description' => esc_html__( 'The default length is 55 words.', 'bloginn' ), 'section' => 'jgtbloginn_theme_options', 'settings' => 'jgtbloginn_excerpt_length', 'type' => 'text' ) ); // Author box $wp_customize->add_setting( 'jgtbloginn_author_box', array( 'sanitize_callback' => 'jgtbloginn_sanitize_checkbox' ) ); $wp_customize->add_control( 'jgtbloginn_author_box', array( 'label' => esc_html__( 'Display an author box below the post content.', 'bloginn' ), 'section' => 'jgtbloginn_theme_options', 'settings' => 'jgtbloginn_author_box', 'type' => 'checkbox' ) ); // Footer text $wp_customize->add_setting( 'jgtbloginn_footer_text', array( 'default' => '', 'sanitize_callback' => 'jgtbloginn_sanitize_html' ) ); $wp_customize->add_control( 'jgtbloginn_footer_text', array( 'label' => esc_html__( 'Footer Text', 'bloginn' ), 'section' => 'jgtbloginn_theme_options', 'settings' => 'jgtbloginn_footer_text', 'type' => 'textarea' ) ); // Selective refresh for previewing the footer text. $wp_customize->selective_refresh->add_partial( 'jgtbloginn_footer_text', array( 'selector' => '.site-info', 'container_inclusive' => false, 'render_callback' => 'jgtbloginn_customize_partial_footertext' ) ); // 404 page image $wp_customize->add_setting( 'jgtbloginn_404_image', array( 'default' => get_template_directory_uri() . '/images/404.jpg', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'jgtbloginn_404_image', array( 'label' => esc_html__( 'Error 404 Page Image', 'bloginn' ), 'section' => 'jgtbloginn_theme_options', 'settings' => 'jgtbloginn_404_image', ) ) ); } add_action( 'customize_register', 'jgtbloginn_customize_register' ); /** * Render the site title for the selective refresh partial. */ function jgtbloginn_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. */ function jgtbloginn_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Render the footer text for the selective refresh partial. */ function jgtbloginn_customize_partial_footertext() { return get_theme_mod( 'jgtbloginn_footer_text' ); } /** * Checkbox sanitization callback. */ function jgtbloginn_sanitize_checkbox( $input ) { return ( ( isset( $input ) && true == $input ) ? true : false ); } /** * HTML sanitization callback. */ function jgtbloginn_sanitize_html( $input ) { return wp_filter_post_kses( $input ); } /** * Integer sanitization callback. */ function jgtbloginn_sanitize_integer( $input, $setting ) { $input = absint( $input ); return ( $input ? $input : $setting->default ); }