get_section( 'static_front_page' )->priority = '10'; // Add postMessage support for site title and description for the Theme Customizer. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; // Add Selective refresh support for site title and description. if( class_exists( 'WP_Customize_Selective_Refresh' ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title > a', 'container_inclusive' => false, 'render_callback' => function() { bloginfo( 'name' ); }, ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'container_inclusive' => false, 'render_callback' => function() { bloginfo( 'description' ); }, ) ); } $wp_customize->remove_control( 'display_header_text' ); $wp_customize->remove_control( 'header_textcolor' ); $wp_customize->add_setting( 'brand_settings[show_site_title]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['show_site_title'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_checkbox', ) ); $wp_customize->add_control( 'brand_settings[show_site_title]', array( 'type' => 'checkbox', 'section' => 'title_tagline', 'description' => __( 'Display Site Title and Tagline ', 'brand' ), 'priority' => 10, ) ); // Add logo settings and control to site identity section $wp_customize->add_setting( 'brand_settings[logo]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['logo'], 'transport' => 'refresh', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'brand_settings[logo]', array( 'label' => __( 'Logo', 'brand' ), 'section' => 'title_tagline', 'mime_type' => 'image', 'priority' => '100' ) ) ); $wp_customize->add_setting( 'brand_settings[logo_mobile]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['logo_mobile'], 'transport' => 'refresh', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'brand_settings[logo_mobile]', array( 'label' => __( 'Mobile logo', 'brand' ), 'section' => 'title_tagline', 'mime_type' => 'image', 'priority' => '115' ) ) ); // Adds layout panel $wp_customize->add_panel( 'brand_layout', array( 'priority' => 25, 'capability' => 'edit_theme_options', 'title' => __( 'Layout', 'brand' ), ) ); // Adds general section $wp_customize->add_section( 'brand_general', array( 'title' => __( 'General', 'brand' ), 'priority' => 10, 'capability' => 'edit_theme_options', 'panel' => 'brand_layout', ) ); $wp_customize->add_setting( 'brand_settings[container_width]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['container_width'], 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new Brand_Customize_Width_Slider_Control( $wp_customize, 'brand_settings[container_width]', array( 'label' => __('Container width','brand'), 'section' => 'brand_general', 'settings' => 'brand_settings[container_width]', 'priority' => 0 ) ) ); $wp_customize->add_setting( 'brand_settings[sidebar_layout]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'theme_supports' => '', // Rarely needed. 'default' => $defaults['sidebar_layout'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_sidebar_array', ) ); $wp_customize->add_control( 'brand_settings[sidebar_layout]', array( 'type' => 'select', 'section' => 'brand_general', 'label' => __( 'Show sidebar', 'brand' ), 'priority' => 10, 'choices' => array( 'no' => __( 'No sidebar', 'brand' ), 'left' => __( 'Left sidebar', 'brand' ), 'right' => __( 'Right sidebar', 'brand' ), ), ) ); $wp_customize->add_setting( 'brand_settings[featured_position]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'theme_supports' => '', // Rarely needed. 'default' => $defaults['featured_position'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_featured_position', ) ); $wp_customize->add_control( 'brand_settings[featured_position]', array( 'type' => 'select', 'section' => 'brand_general', 'label' => __( 'Featured image position', 'brand' ), 'description' => __( 'Choose the position where featured image will be displayed in single post or page.', 'brand' ), 'priority' => 15, 'choices' => array( 'inside' => __( 'Inside content', 'brand' ), 'before' => __( 'Before content', 'brand' ), ), ) ); $wp_customize->add_setting( 'brand_settings[content_layout]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'theme_supports' => '', // Rarely needed. 'default' => $defaults['content_layout'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_content_layout_array', ) ); $wp_customize->add_control( 'brand_settings[content_layout]', array( 'type' => 'select', 'section' => 'brand_general', 'label' => __( 'Content layout', 'brand' ), 'priority' => 20, 'choices' => array( 'one_block' => 'One block', 'separated_blocks' => 'Separated blocks', ), ) ); // Add Navigation section in the Layout panel $wp_customize->add_section( 'brand_navigation_layout', array( 'title' => __( 'Navigation', 'brand' ), 'priority' => 20, 'capability' => 'edit_theme_options', 'panel' => 'brand_layout', ) ); $wp_customize->add_setting( 'brand_settings[nav_width]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['nav_width'], 'transport' => 'postMessage', 'sanitize_callback' => 'brand_sanitize_width' ) ); $wp_customize->add_control( 'brand_settings[nav_width]', array( 'type' => 'select', 'section' => 'brand_navigation_layout', 'label' => __( 'Navigation width', 'brand' ), 'priority' => 10, 'choices' => array( 'fullwidth' => 'Full width', 'boxed' => 'Boxed' ), ) ); $wp_customize->add_setting( 'brand_settings[nav_position]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['nav_position'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_nav_position', ) ); $wp_customize->add_control( 'brand_settings[nav_position]', array( 'type' => 'select', 'section' => 'brand_navigation_layout', 'label' => __( 'Navigation position', 'brand' ), 'priority' => 15, 'choices' => array( 'above' => 'Above header', 'below' => 'Below header', 'inside_above' => 'Inside header above', 'inside_below' => 'Inside header below', 'float_right' => 'Float right', 'float_left' => 'Float left', ) ) ); $wp_customize->add_setting( 'brand_settings[nav_alignment]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['nav_alignment'], 'transport' => 'postMessage', 'sanitize_callback' => 'brand_sanitize_alignment_array', ) ); $wp_customize->add_control( 'brand_settings[nav_alignment]', array( 'type' => 'select', 'section' => 'brand_navigation_layout', 'label' => __( 'Navigation alignment', 'brand' ), 'priority' => 20, 'choices' => array( 'left' => 'Left', 'center' => 'Center', 'right' => 'Right', ) ) ); $wp_customize->add_setting( 'brand_settings[nav_orientation]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['nav_orientation'], 'transport' => 'postMessage', 'sanitize_callback' => 'brand_sanitize_nav_orientation', ) ); $wp_customize->add_control( 'brand_settings[nav_orientation]', array( 'type' => 'select', 'section' => 'brand_navigation_layout', 'label' => __( 'Navigation orientation', 'brand' ), 'priority' => 25, 'choices' => array( 'horizontal' => 'Horizontal', 'vertical' => 'Vertical', ) ) ); $wp_customize->add_setting( 'brand_settings[nav_search]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['nav_search'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_nav_search' ) ); $wp_customize->add_control( 'brand_settings[nav_search]', array( 'type' => 'select', 'section' => 'brand_navigation_layout', 'label' => __( 'Search icon', 'brand' ), 'priority' => 30, 'choices' => array( 'enabled' => 'Enabled', 'disabled' => 'Disabled', ), ) ); // Add Header section in the Layout panel $wp_customize->add_section( 'brand_header_layout', array( 'title' => __( 'Header', 'brand' ), 'priority' => 30, 'capability' => 'edit_theme_options', 'panel' => 'brand_layout', ) ); $wp_customize->add_setting( 'brand_settings[header_width]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['header_width'], 'transport' => 'postMessage', 'sanitize_callback' => 'brand_sanitize_width' ) ); $wp_customize->add_control( 'brand_settings[header_width]', array( 'type' => 'select', 'section' => 'brand_header_layout', 'label' => __( 'Header width', 'brand' ), 'priority' => 10, 'choices' => array( 'fullwidth' => 'Full width', 'boxed' => 'Boxed' ), ) ); $wp_customize->add_setting( 'brand_settings[header_alignment]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['header_alignment'], 'transport' => 'postMessage', 'sanitize_callback' => 'brand_sanitize_alignment_array' ) ); $wp_customize->add_control( 'brand_settings[header_alignment]', array( 'type' => 'select', 'section' => 'brand_header_layout', 'label' => __( 'Header alignment', 'brand' ), 'priority' => 15, 'choices' => array( 'left' => 'Left', 'center' => 'Center', 'right' => 'Right', ), ) ); // Add Page Title section in the Layout panel $wp_customize->add_section( 'brand_page_title_layout', array( 'title' => __( 'Page Title', 'brand' ), 'priority' => 40, 'capability' => 'edit_theme_options', 'panel' => 'brand_layout', ) ); $wp_customize->add_setting( 'brand_settings[page_title_alignment]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['page_title_alignment'], 'transport' => 'postMessage', 'sanitize_callback' => 'brand_sanitize_alignment_array' ) ); $wp_customize->add_control( 'brand_settings[page_title_alignment]', array( 'type' => 'select', 'section' => 'brand_page_title_layout', 'label' => __( 'Alignment', 'brand' ), 'priority' => 10, 'choices' => array( 'left' => 'Left', 'center' => 'Center', 'right' => 'Right', ), ) ); // Add Content section in the Layout panel $wp_customize->add_section( 'brand_content_layout', array( 'title' => __( 'Content', 'brand' ), 'priority' => 50, 'capability' => 'edit_theme_options', 'panel' => 'brand_layout', ) ); // Add Sidebar section in the Layout panel $wp_customize->add_section( 'brand_sidebar_layout', array( 'title' => __( 'Sidebar', 'brand' ), 'priority' => 60, 'capability' => 'edit_theme_options', 'panel' => 'brand_layout', ) ); // Add Footer widgets section in the Layout panel $wp_customize->add_section( 'brand_footer_widgets_layout', array( 'title' => __( 'Footer widgets', 'brand' ), 'priority' => 70, 'capability' => 'edit_theme_options', 'panel' => 'brand_layout', ) ); $wp_customize->add_setting( 'brand_settings[footer_widgets_width]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['footer_widgets_width'], 'transport' => 'postMessage', 'sanitize_callback' => 'brand_sanitize_width' ) ); $wp_customize->add_control( 'brand_settings[footer_widgets_width]', array( 'type' => 'select', 'section' => 'brand_footer_widgets_layout', 'label' => __( 'Footer widgets width', 'brand' ), 'priority' => 10, 'choices' => array( 'fullwidth' => 'Full width', 'boxed' => 'Boxed' ), ) ); $wp_customize->add_setting( 'brand_settings[footer_widgets]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'theme_supports' => '', // Rarely needed. 'default' => $defaults['footer_widgets'], 'transport' => 'refresh', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'brand_settings[footer_widgets]', array( 'type' => 'select', 'section' => 'brand_footer_widgets_layout', 'label' => __( 'Footer widgets', 'brand' ), 'priority' => 15, 'choices' => array( '0' => 'None', '1' => 'One', '2' => 'Two', '3' => 'Three', '4' => 'Four', ), ) ); // Add Footer section in the Layout panel $wp_customize->add_section( 'brand_footer_layout', array( 'title' => __( 'Footer', 'brand' ), 'priority' => 80, 'capability' => 'edit_theme_options', 'panel' => 'brand_layout', ) ); $wp_customize->add_setting( 'brand_settings[footer_width]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['footer_width'], 'transport' => 'postMessage', 'sanitize_callback' => 'brand_sanitize_width' ) ); $wp_customize->add_control( 'brand_settings[footer_width]', array( 'type' => 'select', 'section' => 'brand_footer_layout', 'label' => __( 'Footer width', 'brand' ), 'priority' => 10, 'choices' => array( 'fullwidth' => 'Full width', 'boxed' => 'Boxed' ), ) ); // Remove default color section $wp_customize->remove_section( 'colors' ); // Add custom color panel $wp_customize->add_panel( 'brand_colors', array( 'priority' => 30, 'capability' => 'edit_theme_options', 'title' => __( 'Colors', 'brand' ), ) ); // Add Base colors section in the Colors panel $wp_customize->add_section( 'brand_base_colors', array( 'title' => __( 'Base colors', 'brand' ), 'priority' => 10, 'capability' => 'edit_theme_options', 'panel' => 'brand_colors' ) ); // Put core background color feature in Base Colors section $wp_customize->get_control( 'background_color' )->section = 'brand_base_colors'; $wp_customize->get_setting( 'background_color' )->default = $defaults['body_bg_color']; // Add base colors options $base_colors = array(); $base_colors[] = array( 'id'=>'body_text_color', 'default' => $defaults['body_text_color'], 'label' => __('Text color', 'brand'), 'transport' => 'postMessage' ); $base_colors[] = array( 'id'=>'link_color', 'default' => $defaults['link_color'], 'label' => __('Link color', 'brand'), 'transport' => 'postMessage' ); $base_colors[] = array( 'id'=>'link_hover_color', 'default' => $defaults['link_hover_color'], 'label' => __('Link color on hover', 'brand'), 'transport' => 'postMessage' ); foreach( $base_colors as $color ) { $wp_customize->add_setting( 'brand_settings[' . $color['id'] . ']', array( 'default' => $color['default'], 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => $color['transport'] ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $color['id'], array( 'label' => $color['label'], 'section' => 'brand_base_colors', 'settings' => 'brand_settings[' . $color['id'] . ']' ) ) ); } if ( ! brand_addons_installed() ) { $wp_customize->add_control( new Brand_Customize_Misc_Control( $wp_customize, 'colors_get_addon_desc', array( 'section' => 'brand_base_colors', 'type' => 'addon', 'label' => __( 'More Settings','brand' ), 'url' => 'https://www.wp-brandtheme.com/add-ons/', 'description' => sprintf( __( 'Need more color settings?
%s.', 'brand' ), sprintf( '%2$s', esc_url( 'https://www.wp-brandtheme.com/add-ons/' ), __( 'Take a look at our premium plugin', 'brand' ) ) ), 'priority' => 50 ) ) ); } $wp_customize->remove_section( 'background_image' ); $wp_customize->get_control( 'background_image' )->section = 'brand_body_image'; $wp_customize->get_control( 'background_image' )->priority = 10; // Add Backgrounds panel $wp_customize->add_panel( 'brand_backgrounds', array( 'priority' => 35, 'capability' => 'edit_theme_options', 'title' => __( 'Backgrounds', 'brand' ), ) ); $wp_customize->get_section( 'header_image' )->panel = 'brand_backgrounds'; $wp_customize->get_section( 'header_image' )->priority = 15; $wp_customize->get_control( 'header_image' )->priority = 10; // Add Blog panel $wp_customize->add_panel( 'brand_blog', array( 'priority' => 40, 'capability' => 'edit_theme_options', 'title' => __( 'Blog', 'brand' ), ) ); // Add General section $wp_customize->add_section( 'brand_blog_general', array( 'title' => __( 'General', 'brand' ), 'priority' => 10, 'capability' => 'edit_theme_options', 'panel' => 'brand_blog', ) ); $wp_customize->add_setting( 'brand_settings[show_excerpt]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['show_excerpt'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_show_excerpt_array', ) ); $wp_customize->add_control( 'brand_settings[show_excerpt]', array( 'type' => 'select', 'section' => 'brand_blog_general', 'label' => __( 'Show excerpt', 'brand' ), 'priority' => 10, 'choices' => array( 'yes' => 'Yes', 'no' => 'No', 'only_title' => 'Only title', ), ) ); $wp_customize->add_setting( 'brand_settings[excerpt_length]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['excerpt_length'], 'transport' => 'refresh', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'brand_settings[excerpt_length]', array( 'type' => 'input', 'section' => 'brand_blog_general', 'label' => __( 'Excerpt lenght', 'brand' ), 'priority' => 15, ) ); $wp_customize->add_setting( 'brand_settings[show_thumb_index]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['show_thumb_index'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_show_thumb_index', ) ); $wp_customize->add_control( 'brand_settings[show_thumb_index]', array( 'type' => 'select', 'section' => 'brand_blog_general', 'label' => __( 'Show featured image in index', 'brand' ), 'priority' => 20, 'choices' => array( 'yes' => 'Yes', 'no' => 'No' ), ) ); $wp_customize->add_setting( 'brand_settings[show_thumb_single]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['show_thumb_single'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_show_thumb_single', ) ); $wp_customize->add_control( 'brand_settings[show_thumb_single]', array( 'type' => 'select', 'section' => 'brand_blog_general', 'label' => __( 'Show featured image on single post or page', 'brand' ), 'priority' => 40, 'choices' => array( 'yes' => 'Yes', 'no' => 'No' ), ) ); $wp_customize->add_setting( 'brand_settings[post_image_no_padding]', array( 'type' => 'option', 'capability' => 'edit_theme_options', 'default' => $defaults['post_image_no_padding'], 'transport' => 'refresh', 'sanitize_callback' => 'brand_sanitize_checkbox', ) ); $wp_customize->add_control( 'brand_settings[post_image_no_padding]', array( 'type' => 'checkbox', 'section' => 'brand_blog_general', 'description' => __( 'Show featured image without padding on index', 'brand' ), 'priority' => 30, ) ); if ( ! brand_addons_installed() ) { $wp_customize->add_control( new Brand_Customize_Misc_Control( $wp_customize, 'blog_get_addon_desc', array( 'section' => 'brand_blog_general', 'type' => 'addon', 'label' => __( 'More Settings','brand' ), 'url' => 'https://www.wp-brandtheme.com/add-ons/', 'description' => sprintf( __( 'Need more blog settings?
%s.', 'brand' ), sprintf( '%2$s', esc_url( 'https://www.wp-brandtheme.com/add-ons/' ), __( 'Take a look at our premium plugin', 'brand' ) ) ), 'priority' => 50 ) ) ); } } add_action( 'customize_register', 'brand_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function brand_customize_preview_js() { wp_enqueue_script( 'brand_customizer', get_template_directory_uri() . '/assets/javascripts/admin/customizer.js', array( 'customize-preview' ), BRAND_VER, true ); } add_action( 'customize_preview_init', 'brand_customize_preview_js' ); add_action('customize_controls_print_styles', 'brand_customize_preview_css'); function brand_customize_preview_css() { ?> tag. */ function brand_custom_styles() { // Get brand options. $brand_settings = wp_parse_args( get_option( 'brand_settings', array() ), brand_get_defaults() ); if ( !brand_addons_installed() ) { $header_image_url = get_header_image(); } ?>