get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_section( 'background_image' )->priority = 41; $wp_customize->get_section( 'colors' )->priority = 35; $wp_customize->get_section( 'colors' )->title = __( 'Background Color', 'good' ); $wp_customize->get_setting( 'background_color' )->priority = 1; /* Panel : Color Settings ---------------------------------*/ $wp_customize->add_panel( 'color_settings', array( 'title' => __( 'Colors', 'good' ), 'priority' => 41, ) ); $wp_customize->get_section( 'colors' )->panel = 'color_settings'; /* Section : Layout Setting ---------------------------------*/ $wp_customize->add_section( 'layout', array( 'title' => __( 'Layout Setting', 'good' ), 'priority' => 34, ) ); /* Section : Header Colors ---------------------------------*/ $wp_customize->add_section( 'main_sidebar_colors', array( 'title' => __( 'Header Colors', 'good' ), 'priority' => 37, 'panel' => 'color_settings', ) ); /* Section : Main Content Colors ---------------------------------*/ $wp_customize->add_section( 'content_colors', array( 'title' => __( 'Main Content Colors', 'good' ), 'priority' => 39, 'panel' => 'color_settings', ) ); $wp_customize->add_section( 'secondary_sidebar_colors', array( 'title' => __( 'Secondary Sidebar Colors', 'good' ), 'priority' => 40, 'panel' => 'color_settings', ) ); /* Section : Typography setting ---------------------------------*/ $wp_customize->add_section( 'typography', array( 'title' => __( 'Typography Setting', 'good' ), 'priority' => 42, ) ); /* Section : Post Setting ---------------------------------*/ $wp_customize->add_section( 'post_setting', array( 'title' => __( 'Post Setting', 'good' ), 'priority' => 42, ) ); /* Section : Footer setting ---------------------------------*/ $wp_customize->add_section( 'footer', array( 'title' => __( 'Footer Setting', 'good' ), 'priority' => 43, ) ); } add_action( 'customize_register', 'good_customize_register' ); /** * List of customizer settings */ function good_customize_items( $settings ) { $default_color_options = array( 'main_sidebar_background_color' => '#ffffff', 'main_sidebar_color' => '#000000', 'main_sidebar_link_color' => '#ff0000', //'main_sidebar_link_hover' => '#222222', 'main_sidebar_border_color' => '#dddddd', 'main_sidebar_container_border_color' => '#dddddd', 'main_sidebar_search_border_color' => '#dddddd', 'content_background_color' => '#ffffff', 'content_color' => '#222222', 'content_link_color' => '#ff0000', 'content_meta_color' => '#bbbbbb', 'content_border_color' => '#dddddd', 'content_container_border_color' => '#ffffff', 'content_widget_title_color' => '#bbbbbb', 'content_widget_title_border_color' => '#dddddd', 'secondary_sidebar_background_color' => '#000000', 'secondary_sidebar_color' => '#ffffff', 'secondary_sidebar_meta_color' => '#666666', 'secondary_sidebar_link_color' => '#ffffff', 'secondary_sidebar_link_hover_color' => '#ffffff', 'secondary_sidebar_border_color' => '#222222', 'container_border_color' => '#dddddd', 'heading_font' => 'Source_Sans_Pro__400', 'heading_font_style' => 'normal', 'heading_font_weight' => '400', 'heading_font_transform' => 'none', 'body_font' => 'Lora__400,700', 'meta_font' => 'Lora__400,700', 'meta_font_style' => 'normal', 'meta_font_weight' => '400', 'meta_font_transform' => 'none', 'menu_font' => 'Lora__400,700', 'menu_font_style' => 'normal', 'menu_font_weight' => '400', 'menu_font_transform' => 'none', 'widget_title_font' => 'Source_Sans_Pro__400', 'widget_title_font_style' => 'normal', 'widget_title_font_weight' => '400', 'widget_title_font_transform' => 'uppercase', ); /* Section : Post Setting ---------------------------------*/ $settings[] = array( 'default' => false, 'id' => 'recent_posts_hide', 'label' => __( 'Hide the default recent posts on homepage', 'good' ), 'section' => 'post_setting', 'priority' => 1, 'control' => 'checkbox', 'sanitize_callback' => 'good_sanitize_checkbox', 'sanitize_js_callback' => 'good_sanitize_checkbox_js', ); $settings[] = array( 'default' => '', 'id' => 'exclude_categories', 'label' => __( 'Do not show posts if home with these categories', 'good' ), 'section' => 'post_setting', 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => good_choice_taxonomy(), ); /* Section : Footer setting ---------------------------------*/ /* Credit text on footer */ $settings[] = array( 'default' => '', 'transport' => 'postMessage', 'id' => 'footer_credit', 'control' => 'textarea', 'sanitize_callback' => 'esc_html', 'label' => __( 'Credit text on footer', 'good' ), 'section' => 'footer', ); /* Section : Layout Setting ---------------------------------*/ $settings[] = array( 'default' => false, 'id' => 'sticky_navigation', 'label' => __( 'Sticky navigation', 'good' ), 'section' => 'layout', 'priority' => 1, 'control' => 'checkbox', 'sanitize_callback' => 'good_sanitize_checkbox', 'sanitize_js_callback' => 'good_sanitize_checkbox_js', ); $settings[] = array( 'default' => false, 'id' => 'layout_text_align', 'label' => __( 'Center aligned content text', 'good' ), 'section' => 'layout', 'priority' => 2, 'control' => 'checkbox', 'sanitize_callback' => 'good_sanitize_checkbox', 'sanitize_js_callback' => 'good_sanitize_checkbox_js', ); /* Section : Main Sidebar Colors ---------------------------------*/ $settings[] = array( 'default' => $default_color_options['main_sidebar_background_color'], 'transport' => 'postMessage', 'id' => 'main_sidebar_background_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main sidebar background color', 'good' ), 'section' => 'main_sidebar_colors', 'priority' => 4, 'apply_css' => array( array( 'selector' => '#page:before, #main-sidebar, #main-navigation, #main-navigation ul li:hover > .sub-menu', 'property' => 'background-color', ), ), ); $settings[] = array( 'default' => $default_color_options['main_sidebar_color'], 'transport' => 'postMessage', 'id' => 'main_sidebar_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main sidebar color', 'good' ), 'section' => 'main_sidebar_colors', 'priority' => 5, 'apply_css' => array( array( 'selector' => '#main-sidebar, #main-sidebar a:hover, #main-navigation ul li a, #main-sidebar #searchform #s, #main-navigation .expand-button', 'property' => 'color', ), array( 'selector' => '#main-search ::-webkit-input-placeholder', 'property' => 'color', ), array( 'selector' => '#main-search :-moz-placeholder', 'property' => 'color', ), array( 'selector' => '#main-search ::-moz-placeholder', 'property' => 'color', ), array( 'selector' => '#main-search :-ms-input-placeholder', 'property' => 'color', ), ), ); $settings[] = array( 'default' => $default_color_options['main_sidebar_link_color'], 'transport' => 'postMessage', 'id' => 'main_sidebar_link_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main sidebar link color', 'good' ), 'section' => 'main_sidebar_colors', 'priority' => 5, 'apply_css' => array( array( 'selector' => '#main-sidebar a', 'property' => 'color', ), array( 'selector' => '#main-navigation .current-menu-item a:after', 'property' => 'background-color', ), ), ); $settings[] = array( 'default' => $default_color_options['main_sidebar_border_color'], 'transport' => 'postMessage', 'id' => 'main_sidebar_border_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main sidebar borders color', 'good' ), 'section' => 'main_sidebar_colors', 'priority' => 6, 'apply_css' => array( array( 'selector' => '#main-search, #main-navigation .sub-menu li a', 'property' => 'border-bottom-color', ), array( 'selector' => '#main-navigation .sub-menu', 'property' => 'border-color', ), ), ); $settings[] = array( 'default' => $default_color_options['main_sidebar_container_border_color'], 'transport' => 'postMessage', 'id' => 'main_sidebar_container_border_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main sidebar container borders color', 'good' ), 'section' => 'main_sidebar_colors', 'priority' => 6, 'apply_css' => array( array( 'selector' => '#page:before, #main-navigation', 'property' => 'border-color', ), array( 'selector' => '#site-footer', 'property' => 'border-left-color', ), ), ); $settings[] = array( 'default' => $default_color_options['main_sidebar_search_border_color'], 'transport' => 'postMessage', 'id' => 'main_sidebar_search_border_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main sidebar search box borders color', 'good' ), 'section' => 'main_sidebar_colors', 'priority' => 6, 'apply_css' => array( array( 'selector' => '#main-search', 'property' => 'border-top-color', ), ), ); /* Section : Main Content Colors ---------------------------------*/ $settings[] = array( 'default' => $default_color_options['content_background_color'], 'transport' => 'postMessage', 'id' => 'content_background_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main content background color', 'good' ), 'section' => 'content_colors', 'priority' => 1, 'apply_css' => array( array( 'selector' => '#primary, .page-navigation, #breadcrumbs, #primary .nav-meta, #primary .category-meta, #comments, #primary .widget-title span, #reply-title span, #site-footer, #main-content:before, #share-post li a', 'property' => 'background-color', ), array( 'selector' => '.single-meta div div:before, #primary input[type="button"], #primary input[type="reset"], #primary input[type="submit"], #primary button, #primary .button, #primary .load-more a, #primary input[type="button"]:hover, #primary input[type="reset"]:hover, #primary input[type="submit"]:hover, #primary button:hover, #primary .button:hover, #primary .load-more a:hover', 'property' => 'color', ), ), ); $settings[] = array( 'default' => $default_color_options['content_color'], 'transport' => 'postMessage', 'id' => 'content_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main content text color', 'good' ), 'section' => 'content_colors', 'priority' => 2, 'apply_css' => array( array( 'selector' => 'a:hover, #primary, #primary .entry-title a, .popular-posts article .home-thumb:after, #primary input, #primary select, #primary textarea, #site-footer, #share-post li a', 'property' => 'color', ), array( 'selector' => '#primary input[type="button"]:hover, #primary input[type="reset"]:hover, #primary input[type="submit"]:hover, #primary button:hover, #primary .button:hover, #primary .load-more a:hover', 'property' => 'background-color', ), array( 'selector' => '.load-more a:hover, .load-more a:focus, #respond #submit:hover', 'property' => 'border-color', ), ), ); $settings[] = array( 'default' => $default_color_options['content_link_color'], 'transport' => 'postMessage', 'id' => 'content_link_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main content link color', 'good' ), 'section' => 'content_colors', 'priority' => 3, 'apply_css' => array( array( 'selector' => 'a, #primary .entry-title a:hover, #primary .nav-meta, #site-footer a', 'property' => 'color', ), array( 'selector' => '#primary input[type="button"], #primary input[type="reset"], #primary input[type="submit"], #primary button, #primary .button, #primary .load-more a', 'property' => 'background-color', ), ), ); $settings[] = array( 'default' => $default_color_options['content_meta_color'], 'transport' => 'postMessage', 'id' => 'content_meta_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main content meta color', 'good' ), 'section' => 'content_colors', 'priority' => 4, 'apply_css' => array( array( 'selector' => '#primary .meta, #breadcrumbs, #respond .required-attr, #reply-title, #comments .commentlist li .meta, #comments .commentlist li .meta a, #breadcrumbs a:after', 'property' => 'color', ), array( 'selector' => '.widget_nav_menu [class^="icon-"] a', 'property' => 'border-color', ), ), ); $settings[] = array( 'default' => $default_color_options['content_widget_title_color'], 'transport' => 'postMessage', 'id' => 'content_widget_title_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main content widget title color', 'good' ), 'section' => 'content_colors', 'priority' => 5, 'apply_css' => array( array( 'selector' => '#primary .widget-title, #reply-title', 'property' => 'color', ), ), ); $settings[] = array( 'default' => $default_color_options['content_widget_title_border_color'], 'transport' => 'postMessage', 'id' => 'content_widget_title_border_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main content widget title border color', 'good' ), 'section' => 'content_colors', 'priority' => 6, 'apply_css' => array( array( 'selector' => '#primary .widget-title:before, #reply-title:before', 'property' => 'border-color', ), array( 'selector' => '#breadcrumbs, #site-footer:before', 'property' => 'border-top-color', ), array( 'selector' => '.no-title', 'property' => 'background-color', ), ), ); $settings[] = array( 'default' => $default_color_options['content_border_color'], 'transport' => 'postMessage', 'id' => 'content_border_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main content border color', 'good' ), 'section' => 'content_colors', 'priority' => 7, 'apply_css' => array( array( 'selector' => '#breadcrumbs', 'property' => 'border-bottom-color', ), array( 'selector' => '.page-navigation, .single-meta, .single-meta > div:nth-child(1), .single-meta > div:nth-child(2), #primary blockquote, #primary #searchform, #primary .posts-block .post .meta:before, #share-post li a, input[type=text], select, textarea, tr, th, td, table caption', 'property' => 'border-color', ), array( 'selector' => '.single-meta div div:before', 'property' => 'background-color', ), ), ); $settings[] = array( 'default' => $default_color_options['content_container_border_color'], 'transport' => 'postMessage', 'id' => 'content_container_border_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Main content container border color', 'good' ), 'section' => 'content_colors', 'priority' => 8, 'apply_css' => array( array( 'selector' => '#main-content:before', 'property' => 'border-color', ), ), ); /* Section : Secondary Sidebar Colors ---------------------------------*/ $settings[] = array( 'default' => $default_color_options['secondary_sidebar_background_color'], 'transport' => 'postMessage', 'id' => 'secondary_sidebar_background_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Secondary sidebar background color', 'good' ), 'section' => 'secondary_sidebar_colors', 'priority' => 1, 'apply_css' => array( array( 'selector' => '#secondary', 'property' => 'background-color', ), ), ); $settings[] = array( 'default' => $default_color_options['secondary_sidebar_color'], 'transport' => 'postMessage', 'id' => 'secondary_sidebar_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Secondary sidebar color', 'good' ), 'section' => 'secondary_sidebar_colors', 'priority' => 2, 'apply_css' => array( array( 'selector' => '#secondary, #secondary .entry-title, #secondary input[type=text], #secondary select, #secondary textarea', 'property' => 'color', ), ), ); $settings[] = array( 'default' => $default_color_options['secondary_sidebar_link_color'], 'transport' => 'postMessage', 'id' => 'secondary_sidebar_link_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Secondary sidebar link color', 'good' ), 'section' => 'secondary_sidebar_colors', 'priority' => 3, 'apply_css' => array( array( 'selector' => '#secondary a, #secondary .entry-title a:hover', 'property' => 'color', ), ), ); $settings[] = array( 'default' => $default_color_options['secondary_sidebar_meta_color'], 'transport' => 'postMessage', 'id' => 'secondary_sidebar_meta_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Secondary sidebar meta color', 'good' ), 'section' => 'secondary_sidebar_colors', 'priority' => 4, 'apply_css' => array( array( 'selector' => '#secondary .meta, #secondary .meta a, #secondary .widget-title', 'property' => 'color', ), ), ); $settings[] = array( 'default' => $default_color_options['secondary_sidebar_border_color'], 'transport' => 'postMessage', 'id' => 'secondary_sidebar_border_color', 'control' => 'color', 'sanitize_callback' => 'sanitize_hex_color', 'label' => __( 'Secondary sidebar border color', 'good' ), 'section' => 'secondary_sidebar_colors', 'priority' => 45, 'apply_css' => array( array( 'selector' => '#secondary .widget, #secondary input[type=text], #secondary select, #secondary textarea, #secondary tr, #secondary th, #secondary td, #secondary table caption', 'property' => 'border-color', ), ), ); /* Section : Typography setting ---------------------------------*/ $settings[] = array( 'default' => $default_color_options['heading_font'], 'id' => 'heading_font', 'label' => __( 'Heading font', 'good' ), 'section' => 'typography', 'priority' => 1, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => good_choice_fonts(), ); $settings[] = array( 'default' => $default_color_options['heading_font_style'], 'transport' => 'postMessage', 'id' => 'heading_font_style', 'section' => 'typography', 'priority' => 2, 'control' => 'radio', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( 'italic' => 'Italic', 'normal' => 'Normal' ), 'apply_css' => array( array( 'selector' => 'h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6, button, html input[type="button"], input[type="reset"], input[type="submit"], .page-navigation', 'property' => 'font-style', ), ), ); $settings[] = array( 'default' => $default_color_options['heading_font_weight'], 'transport' => 'postMessage', 'id' => 'heading_font_weight', 'section' => 'typography', 'priority' => 3, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( '100' => '100', '200' => '200', '300' => '300', '400' => '400 (Normal)', '500' => '500', '600' => '600', '700' => '700 (Bold)', '800' => '800', '900' => '900', ), 'apply_css' => array( array( 'selector' => 'h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6, button, html input[type="button"], input[type="reset"], input[type="submit"], .page-navigation', 'property' => 'font-weight', ), ), ); $settings[] = array( 'default' => $default_color_options['heading_font_transform'], 'transport' => 'postMessage', 'id' => 'heading_font_transform', 'section' => 'typography', 'priority' => 4, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( 'none' => 'Text Transform', 'uppercase' => 'Uppercase', 'lowercase' => 'Lowercase', 'capitalize' => 'Capitalize' ), 'apply_css' => array( array( 'selector' => 'h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6, button, html input[type="button"], input[type="reset"], input[type="submit"], .page-navigation', 'property' => 'text-transform', ), ), ); $settings[] = array( 'default' => $default_color_options['body_font'], 'id' => 'body_font', 'label' => __( 'Body font', 'good' ), 'section' => 'typography', 'priority' => 5, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => good_choice_fonts(), ); $settings[] = array( 'default' => $default_color_options['meta_font'], 'transport' => 'postMessage', 'id' => 'meta_font', 'label' => __( 'Meta font', 'good' ), 'section' => 'typography', 'priority' => 7, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => good_choice_fonts(), ); $settings[] = array( 'default' => $default_color_options['meta_font_style'], 'transport' => 'postMessage', 'id' => 'meta_font_style', 'section' => 'typography', 'priority' => 8, 'control' => 'radio', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( 'italic' => 'Italic', 'normal' => 'Normal' ), 'apply_css' => array( array( 'selector' => '.meta, .category-meta, #breadcrumbs, .comment-meta, .slider-view .nav-meta', 'property' => 'font-style', ), ), ); $settings[] = array( 'default' => $default_color_options['meta_font_weight'], 'transport' => 'postMessage', 'id' => 'meta_font_weight', 'section' => 'typography', 'priority' => 9, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( '100' => '100', '200' => '200', '300' => '300', '400' => '400 (Normal)', '500' => '500', '600' => '600', '700' => '700 (Bold)', '800' => '800', '900' => '900', ), 'apply_css' => array( array( 'selector' => '.meta, .category-meta, #breadcrumbs, .comment-meta, .slider-view .nav-meta', 'property' => 'font-weight', ), ), ); $settings[] = array( 'default' => $default_color_options['menu_font'], 'id' => 'menu_font', 'label' => __( 'Menu font', 'good' ), 'section' => 'typography', 'priority' => 11, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => good_choice_fonts(), ); $settings[] = array( 'default' => $default_color_options['menu_font_style'], 'transport' => 'postMessage', 'id' => 'menu_font_style', 'section' => 'typography', 'priority' => 12, 'control' => 'radio', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( 'italic' => 'Italic', 'normal' => 'Normal' ), 'apply_css' => array( array( 'selector' => '#main-navigation > div > ul > li > a', 'property' => 'font-style', ), ), ); $settings[] = array( 'default' => $default_color_options['menu_font_weight'], 'transport' => 'postMessage', 'id' => 'menu_font_weight', 'section' => 'typography', 'priority' => 13, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( '100' => '100', '200' => '200', '300' => '300', '400' => '400 (Normal)', '500' => '500', '600' => '600', '700' => '700 (Bold)', '800' => '800', '900' => '900', ), 'apply_css' => array( array( 'selector' => '#main-navigation > div > ul > li > a', 'property' => 'font-weight', ), ), ); $settings[] = array( 'default' => $default_color_options['menu_font_transform'], 'transport' => 'postMessage', 'id' => 'menu_font_transform', 'section' => 'typography', 'priority' => 14, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( 'none' => 'Text Transform', 'uppercase' => 'Uppercase', 'lowercase' => 'Lowercase', 'capitalize' => 'Capitalize' ), 'apply_css' => array( array( 'selector' => '#main-navigation > div > ul > li > a', 'property' => 'text-transform', ), ), ); $settings[] = array( 'default' => $default_color_options['widget_title_font'], 'id' => 'widget_title_font', 'label' => __( 'Wigdet title font', 'good' ), 'section' => 'typography', 'priority' => 15, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => good_choice_fonts(), ); $settings[] = array( 'default' => $default_color_options['widget_title_font_style'], 'transport' => 'postMessage', 'id' => 'widget_title_font_style', 'section' => 'typography', 'priority' => 16, 'control' => 'radio', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( 'italic' => 'Italic', 'normal' => 'Normal' ), 'apply_css' => array( array( 'selector' => '#primary .widget-title, #secondary .widget-title, #reply-title', 'property' => 'font-style', ), ), ); $settings[] = array( 'default' => $default_color_options['widget_title_font_weight'], 'transport' => 'postMessage', 'id' => 'widget_title_font_weight', 'section' => 'typography', 'priority' => 17, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( '100' => '100', '200' => '200', '300' => '300', '400' => '400 (Normal)', '500' => '500', '600' => '600', '700' => '700 (Bold)', '800' => '800', '900' => '900', ), 'apply_css' => array( array( 'selector' => '#primary .widget-title, #secondary .widget-title, #reply-title', 'property' => 'font-weight', ), ), ); $settings[] = array( 'default' => $default_color_options['widget_title_font_transform'], 'transport' => 'postMessage', 'id' => 'widget_title_font_transform', 'section' => 'typography', 'priority' => 18, 'control' => 'select', 'sanitize_callback' => 'good_sanitize_choice', 'choices' => array( 'none' => 'Text Transform', 'uppercase' => 'Uppercase', 'lowercase' => 'Lowercase', 'capitalize' => 'Capitalize' ), 'apply_css' => array( array( 'selector' => '#primary .widget-title, #secondary .widget-title, #reply-title', 'property' => 'text-transform', ), ), ); // Adding additional setting navigation option, the sticky menu. $settings[] = array( 'default' => false, 'id' => 'primary_navigation_sticky', 'label' => __( 'Primary navigation sticky', 'good' ), 'section' => 'nav', 'priority' => 20, 'control' => 'checkbox', 'sanitize_callback' => 'good_sanitize_checkbox', 'sanitize_js_callback' => 'good_sanitize_checkbox_js', ); $settings[] = array( 'default' => false, 'id' => 'secondary_navigation_sticky', 'label' => __( 'Secondary navigation sticky', 'good' ), 'section' => 'nav', 'priority' => 21, 'control' => 'checkbox', 'sanitize_callback' => 'good_sanitize_checkbox', 'sanitize_js_callback' => 'good_sanitize_checkbox_js', ); return $settings; } add_filter( 'good_customizer_settings', 'good_customize_items' ); add_filter( 'good_customizer_css', 'good_customize_items' ); /** * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ function good_customizer_settings( $wp_customize ) { $settings = apply_filters( 'good_customizer_settings', array() ); $i = 1; foreach ( $settings as $setting ) { $wp_customize->add_setting( $setting['id'], array( 'default' => empty( $setting['default'] ) ? null : $setting['default'], 'transport' => empty( $setting['transport'] ) ? null : $setting['transport'], 'capability' => empty( $setting['capability'] ) ? 'edit_theme_options' : $setting['capability'], 'theme_supports' => empty( $setting['theme_supports'] ) ? null : $setting['theme_supports'], 'sanitize_callback' => empty( $setting['sanitize_callback'] ) ? 'sanitize_text_field' : $setting['sanitize_callback'], 'sanitize_js_callback' => empty( $setting['sanitize_js_callback'] ) ? 'sanitize_text_field' : $setting['sanitize_js_callback'], 'type' => empty( $setting['type'] ) ? null : $setting['type'], ) ); $setting['control_id'] = empty( $setting['control_id'] ) ? $setting['id'] : $setting['control_id']; if ( 'image' === $setting['control'] ) { $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, $setting['control_id'], array( 'label' => empty( $setting['label'] ) ? null : $setting['label'], 'section' => empty( $setting['section'] ) ? null : $setting['section'], 'settings' => $setting['id'], 'priority' => empty( $setting['priority'] ) ? $i : $setting['priority'], 'active_callback' => empty( $setting['active_callback'] ) ? null : $setting['active_callback'], 'description' => empty( $setting['description'] ) ? null : $setting['description'], ) ) ); } else if ( 'color' === $setting['control'] ) { $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $setting['control_id'], array( 'label' => empty( $setting['label'] ) ? null : $setting['label'], 'section' => empty( $setting['section'] ) ? null : $setting['section'], 'settings' => $setting['id'], 'priority' => empty( $setting['priority'] ) ? $i : $setting['priority'], 'active_callback' => empty( $setting['active_callback'] ) ? null : $setting['active_callback'], 'description' => empty( $setting['description'] ) ? null : $setting['description'], ) ) ); } else { $wp_customize->add_control( $setting['control_id'], array( 'settings' => $setting['id'], 'label' => empty( $setting['label'] ) ? null : $setting['label'], 'section' => empty( $setting['section'] ) ? null : $setting['section'], 'type' => empty( $setting['control'] ) ? null : $setting['control'], 'choices' => empty( $setting['choices'] ) ? null : $setting['choices'], 'input_attrs' => empty( $setting['input_attrs'] ) ? null : $setting['input_attrs'], 'priority' => empty( $setting['priority'] ) ? $i : $setting['priority'], 'active_callback' => empty( $setting['active_callback'] ) ? null : $setting['active_callback'], 'description' => empty( $setting['description'] ) ? null : $setting['description'], ) ); } $i ++; } } add_action( 'customize_register', 'good_customizer_settings', 100, 1 ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function good_customize_preview_js() { wp_enqueue_script( 'good-customizer-preview', get_template_directory_uri() . '/js/customizer-preview.js', array( 'customize-preview' ), '20130508', true ); } add_action( 'customize_preview_init', 'good_customize_preview_js' ); /** * Binds JS handlers for the helper in the customizer admin. */ function good_customize_controls_js() { wp_enqueue_script( 'good-customizer-controls', get_template_directory_uri() . '/js/customizer-controls.js', array(), '20141114', true ); } add_action( 'customize_controls_enqueue_scripts', 'good_customize_controls_js' ); function good_customizer_css() { $css = ''; $customize_js_var = array(); $media_queries = array(); $settings = apply_filters( 'good_customizer_css', array() ); foreach ( $settings as $setting ) { if ( isset( $setting['type'] ) && $setting['type'] == 'option' ) { $value = get_option( $setting['id'] ); } else { $value = get_theme_mod( $setting['id'] ); } if ( ! empty( $setting['apply_css'] ) && is_array( $setting['apply_css'] ) ) { foreach ( $setting['apply_css'] as $apply_css ) { $mq = empty( $apply_css['media_query'] ) ? 'global' : $apply_css['media_query']; $selector = empty( $apply_css['selector'] ) ? '' : $apply_css['selector']; $property = empty( $apply_css['property'] ) ? '' : $apply_css['property']; $unit = empty( $apply_css['unit'] ) ? '' : $apply_css['unit']; $value_in_text = empty( $apply_css['value_in_text'] ) ? '' : $apply_css['value_in_text']; if ( $value && ( $value !== $setting['default'] ) ) { if ( ! isset( $media_queries[ $mq ][ $selector ] ) ) { $media_queries[ $mq ][ $selector ] = ''; } if ( isset( $apply_css['value_in_text'] ) ) { $media_queries[ $mq ][ $selector ] .= $property . ': ' . str_replace( '%value%', $value, $value_in_text ) . ' ;'; } else { $media_queries[ $mq ][ $selector ] .= $property . ': ' . $value . $unit . ' ;'; } } if ( $setting['transport'] == 'postMessage' ) { $customize_js_var[] = array( 'id' => $setting['id'], 'default' => isset( $setting['default'] ) ? $setting['default'] : null, 'selector' => $selector, 'property' => $property, 'unit' => $unit, 'value_in_text' => $value_in_text, 'mq' => $mq, ); } } } } foreach ( $media_queries as $mq => $selectors ) { if ( $mq !== 'global' ) { $css .= $mq . " {\n"; } foreach ( $selectors as $selector => $value ) { $css .= $selector . " { " . $value . "}\n"; } if ( $mq !== 'global' ) { $css .= "}\n"; } } $_css = ' /* Customize CSS */ %1$s '; wp_add_inline_style( 'good-style', sprintf( $_css, strip_tags( $css ) ) ); if ( $customize_js_var && is_customize_preview() ) { wp_localize_script( 'good-customizer-preview', '_customizerCSS', $customize_js_var ); } } add_action( 'customize_preview_init', 'good_customizer_css' ); add_action( 'wp_enqueue_scripts', 'good_customizer_css' );