get_setting( 'header_textcolor' )->transport = 'postMessage'; } add_action( 'customize_register', 'artists_customize_register' ); /** * Options for WordPress Theme Customizer. */ function artists_customizer( $wp_customize ) { // logo $wp_customize->add_setting( 'header_logo', array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'artists_sanitize_number' ) ); $wp_customize->add_control(new WP_Customize_Media_Control( $wp_customize, 'header_logo', array( 'label' => __( 'Logo', 'artists' ), 'section' => 'title_tagline', 'mime_type' => 'image', 'priority' => 10, ) ) ); global $header_show; $wp_customize->add_setting('header_show', array( 'default' => 'logo-text', 'sanitize_callback' => 'artists_sanitize_radio_header' )); $wp_customize->add_control('header_show', array( 'type' => 'radio', 'label' => __('Show', 'artists'), 'section' => 'title_tagline', 'choices' => $header_show )); /* Main option Settings Panel */ $wp_customize->add_panel('artists_main_options', array( 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Artists Options', 'artists'), 'description' => __('Panel to update artists theme options', 'artists'), // Include html tags such as

. 'priority' => 10 // Mixed with top-level-section hierarchy. )); // add "Content Options" section $wp_customize->add_section( 'artists_content_section' , array( 'title' => esc_html__( 'Content Options', 'artists' ), 'priority' => 50, 'panel' => 'artists_main_options' ) ); // add setting for excerpts/full posts toggle $wp_customize->add_setting( 'artists_excerpts', array( 'default' => 1, 'sanitize_callback' => 'artists_sanitize_checkbox', ) ); // add checkbox control for excerpts/full posts toggle $wp_customize->add_control( 'artists_excerpts', array( 'label' => esc_html__( 'Show post excerpts?', 'artists' ), 'section' => 'artists_content_section', 'priority' => 10, 'type' => 'checkbox' ) ); $wp_customize->add_setting( 'artists_page_comments', array( 'default' => 1, 'sanitize_callback' => 'artists_sanitize_checkbox', ) ); $wp_customize->add_control( 'artists_page_comments', array( 'label' => esc_html__( 'Display Comments on Static Pages?', 'artists' ), 'section' => 'artists_content_section', 'priority' => 20, 'type' => 'checkbox', ) ); // add "Featured Posts" section $wp_customize->add_section( 'artists_featured_section' , array( 'title' => esc_html__( 'Slider Option', 'artists' ), 'priority' => 60, 'panel' => 'artists_main_options' ) ); $wp_customize->add_setting( 'artists_featured_cat', array( 'default' => 0, 'transport' => 'refresh', 'sanitize_callback' => 'artists_sanitize_slidecat' ) ); $wp_customize->add_control( 'artists_featured_cat', array( 'type' => 'select', 'label' => 'Choose a category', 'choices' => artists_cats(), 'section' => 'artists_featured_section', ) ); $wp_customize->add_setting( 'artists_featured_hide', array( 'default' => 0, 'transport' => 'refresh', 'sanitize_callback' => 'artists_sanitize_checkbox' ) ); $wp_customize->add_control( 'artists_featured_hide', array( 'type' => 'checkbox', 'label' => 'Show Slider', 'section' => 'artists_featured_section', ) ); // add "Sidebar" section $wp_customize->add_section('artists_layout_section', array( 'title' => __('Layout options', 'artists'), 'priority' => 31, 'panel' => 'artists_main_options' )); // Layout options global $site_layout; $wp_customize->add_setting('artists_sidebar_position', array( 'default' => 'side-right', 'sanitize_callback' => 'artists_sanitize_layout' )); $wp_customize->add_control('artists_sidebar_position', array( 'label' => __('Website Layout Options', 'artists'), 'section' => 'artists_layout_section', 'type' => 'select', 'description' => __('Choose between different layout options to be used as default', 'artists'), 'choices' => $site_layout )); $wp_customize->add_setting('accent_color', array( 'default' => '', 'sanitize_callback' => 'artists_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'accent_color', array( 'label' => __('Accent Color', 'artists'), 'description' => __('Default used if no color is selected','artists'), 'section' => 'artists_layout_section', ))); $wp_customize->add_setting('social_color', array( 'default' => '', 'sanitize_callback' => 'artists_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'social_color', array( 'label' => __('Social icon color', 'artists'), 'description' => sprintf(__('Default used if no color is selected', 'artists')), 'section' => 'artists_layout_section', ))); $wp_customize->add_setting('social_hover_color', array( 'default' => '', 'sanitize_callback' => 'artists_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'social_hover_color', array( 'label' => __('Social Icon:hover Color', 'artists'), 'description' => sprintf(__('Default used if no color is selected', 'artists')), 'section' => 'artists_layout_section', ))); /* Menu Layout Options */ $wp_customize->add_section('artists_menulayout_section', array( 'title' => __('Menu layout options', 'artists'), 'priority' => 32, 'panel' => 'artists_main_options' )); // add to control sticky menu $wp_customize->add_setting( 'artists_menu_sticky', array( 'default' => 1, 'sanitize_callback' => 'artists_sanitize_checkbox', ) ); $wp_customize->add_control( 'artists_menu_sticky', array( 'label' => esc_html__( 'Make menu stick to top?', 'artists' ), 'section' => 'artists_menulayout_section', 'type' => 'checkbox' ) ); // add to top $wp_customize->add_setting( 'artists_navbar_below', array( 'default' => 1, 'sanitize_callback' => 'artists_sanitize_checkbox', ) ); $wp_customize->add_control( 'artists_navbar_below', array( 'label' => esc_html__( 'Menu below title?', 'artists' ), 'section' => 'artists_menulayout_section', 'type' => 'checkbox' ) ); /*Customize Colors Options */ $wp_customize->add_setting('artists_masthead_color', array( 'default' => '', 'sanitize_callback' => 'artists_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'artists_masthead_color', array( 'label' => __('Masthead Color', 'artists'), 'description' => __('Default used if no color is selected','artists'), 'section' => 'colors' ))); $wp_customize->add_setting('artists_navbar_color', array( 'default' => '', 'sanitize_callback' => 'artists_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'artists_navbar_color', array( 'label' => __('Navigation Bar Color', 'artists'), 'description' => __('Default used if no color is selected','artists'), 'section' => 'colors' ))); $wp_customize->add_setting('artists_post_color', array( 'default' => '', 'sanitize_callback' => 'artists_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'artists_post_color', array( 'label' => __('Post Body Color', 'artists'), 'description' => __('Default used if no color is selected','artists'), 'section' => 'colors', ))); $wp_customize->add_setting('artists_footer_color', array( 'default' => '', 'sanitize_callback' => 'artists_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'artists_footer_color', array( 'label' => __('Footer Color', 'artists'), 'description' => __('Default used if no color is selected','artists'), 'section' => 'colors', ))); // add "Footer" section $wp_customize->add_section( 'artists_footer_section' , array( 'title' => esc_html__( 'Footer', 'artists' ), 'priority' => 90, )); $wp_customize->add_setting( 'artists_footer_copyright', array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'artists_sanitize_strip_slashes' )); $wp_customize->add_control( 'artists_footer_copyright', array( 'type' => 'textarea', 'label' => 'Copyright Text', 'section' => 'artists_footer_section', )); /* Artists Other Options */ $wp_customize->add_section('artists_other_options', array( 'title' => __('Other', 'artists'), 'priority' => 70, 'panel' => 'artists_main_options' )); $wp_customize->add_setting('custom_css', array( 'default' => '', 'sanitize_callback' => 'artists_sanitize_strip_slashes' )); $wp_customize->add_control('custom_css', array( 'label' => __('Custom CSS', 'artists'), 'description' => sprintf(__('Additional CSS', 'artists')), 'section' => 'artists_other_options', 'type' => 'textarea' )); } add_action( 'customize_register', 'artists_customizer' ); /** * Adds sanitization callback function: Strip Slashes * @package Artists */ function artists_sanitize_strip_slashes($input) { return wp_kses_stripslashes($input); } /** * Sanitzie checkbox for WordPress customizer */ function artists_sanitize_checkbox( $input ) { if ( $input == 1 ) { return 1; } else { return ''; } } /** * Adds sanitization callback function: Sidebar Layout * @package Artists */ function artists_sanitize_layout( $input ) { global $site_layout; if ( array_key_exists( $input, $site_layout ) ) { return $input; } else { return ''; } } /** * Adds sanitization callback function: colors * @package Artists */ function artists_sanitize_hexcolor($color) { if ($unhashed = sanitize_hex_color_no_hash($color)) return '#' . $unhashed; return $color; } /** * Adds sanitization callback function: Slider Category * @package Artists */ function artists_sanitize_slidecat( $input ) { if ( array_key_exists( $input, artists_cats()) ) { return $input; } else { return ''; } } /** * Adds sanitization callback function: Radio Header * @package Artists */ function artists_sanitize_radio_header( $input ) { global $header_show; if ( array_key_exists( $input, $header_show ) ) { return $input; } else { return ''; } } /** * Adds sanitization callback function: Number * @package Artists */ function artists_sanitize_number($input) { if ( isset( $input ) && is_numeric( $input ) ) { return $input; } } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function artists_customize_preview_js() { wp_enqueue_script( 'artists_customizer', get_template_directory_uri() . '/inc/js/customizer.js', array( 'customize-preview' ), '20160217', true ); } add_action( 'customize_preview_init', 'artists_customize_preview_js' ); /** * Add CSS for custom controls */ function artists_customizer_custom_control_css() { ?>