choices as $value => $args ) $this->choices[ $value ]['url'] = esc_url( sprintf( $args['url'], get_template_directory_uri(), get_stylesheet_directory_uri() ) ); $this->json['choices'] = $this->choices; $this->json['link'] = $this->get_link(); $this->json['value'] = $this->value(); $this->json['id'] = $this->id; } public function content_template() { ?> <# if ( ! data.choices ) { return; } #> <# if ( data.label ) { #> {{ data.label }} <# } #> <# if ( data.description ) { #> {{{ data.description }}} <# } #> <# _.each( data.choices, function( args, choice ) { #> <# } ) #> register_control_type('Barista_Control_Radio_Image'); } add_action('customize_register', 'barista_custom_classes_setup'); /* ================================================================================================ 2.0 - Customize Register (Setup) ================================================================================================ */ function barista_customize_register_setup($wp_customize) { $wp_customize->get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; $wp_customize->get_setting('header_textcolor')->transport = 'postMessage'; $wp_customize->get_setting('background_color')->transport = 'postMessage'; // Enable and activate Post Layout for Barista. $wp_customize->add_panel('general_layouts', array( 'title' => esc_html__('General Layouts', 'barista'), 'priority' => 5 )); $wp_customize->add_section('post_layout', array( 'title' => esc_html__('Post Layout', 'barista'), 'panel' => 'general_layouts', 'priority' => 5 )); $wp_customize->add_setting('post_layout', array( 'default' => 'default', 'sanitize_callback' => 'barista_sanitize_layout', 'transport' => 'refresh', )); $wp_customize->add_control(new Barista_Control_Radio_Image($wp_customize, 'post_layout', array( 'label' => __('Post Layout', 'barista'), 'section' => 'post_layout', 'settings' => 'post_layout', 'type' => 'radio-image', 'choices' => array( 'default' => array( 'label' => esc_html__('Default (No Sidebar)', 'barista'), 'url' => '%s/images/1col.png', ), 'sidebar-right' => array( 'label' => esc_html__('Right Sidebar (Default)', 'barista'), 'url' => '%s/images/2cr.png', ), 'sidebar-left' => array( 'label' => esc_html__('Left Sidebar', 'barista'), 'url' => '%s/images/2cl.png', ), ), ))); // Enable and activate Page Layout for Barista. $wp_customize->add_section('page_layout', array( 'title' => esc_html__('Page Layout', 'barista'), 'panel' => 'general_layouts', 'priority' => 5 )); $wp_customize->add_setting('page_layout', array( 'default' => 'default', 'sanitize_callback' => 'barista_sanitize_layout', 'transport' => 'refresh', )); $wp_customize->add_control(new Barista_Control_Radio_Image($wp_customize, 'page_layout', array( 'label' => __('Page Layout', 'barista'), 'section' => 'page_layout', 'settings' => 'page_layout', 'type' => 'radio-image', 'choices' => array( 'default' => array( 'label' => esc_html__('Default (No Sidebar)', 'barista'), 'url' => '%s/images/1col.png', ), 'sidebar-right' => array( 'label' => esc_html__('Right Sidebar (Default)', 'barista'), 'url' => '%s/images/2cr.png', ), 'sidebar-left' => array( 'label' => esc_html__('Left Sidebar', 'barista'), 'url' => '%s/images/2cl.png', ), ), ))); // Enable and activate Custom Layout for Barista. $wp_customize->add_section('custom_layout', array( 'title' => esc_html__('Custom Layout', 'barista'), 'panel' => 'general_layouts', 'priority' => 5 )); $wp_customize->add_setting('custom_layout', array( 'default' => 'default', 'sanitize_callback' => 'barista_sanitize_layout', 'transport' => 'refresh', )); $wp_customize->add_control(new Barista_Control_Radio_Image($wp_customize, 'custom_layout', array( 'label' => __('Custom Layout', 'barista'), 'section' => 'custom_layout', 'settings' => 'custom_layout', 'type' => 'radio-image', 'choices' => array( 'default' => array( 'label' => esc_html__('Default (No Sidebar)', 'barista'), 'url' => '%s/images/1col.png', ), 'sidebar-right' => array( 'label' => esc_html__('Right Sidebar (Default)', 'barista'), 'url' => '%s/images/2cr.png', ), 'sidebar-left' => array( 'label' => esc_html__('Left Sidebar', 'barista'), 'url' => '%s/images/2cl.png', ), ), ))); // Enable and activate extra colors for Barista. $wp_customize->add_setting('body_text_color', array( 'default' => '#000000', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', )); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'body_text_color', array( 'label' => __( 'Body Color', 'barista' ), 'section' => 'colors', 'settings' => 'body_text_color', ))); // Enable and activate extra colors for Barista. $wp_customize->add_setting('body_link_color', array( 'default' => '#1d1d1d', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', )); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'body_link_color', array( 'label' => __( 'Body Link Color', 'barista' ), 'section' => 'colors', 'settings' => 'body_link_color', ))); // Enable and activate extra colors for Barista. $wp_customize->add_setting('body_link_color_hover', array( 'default' => '#1d1d1d', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', )); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'body_link_color_hover', array( 'label' => __( 'Body Link Color Hover', 'barista' ), 'section' => 'colors', 'settings' => 'body_link_color_hover', ))); } add_action('customize_register', 'barista_customize_register_setup'); /* ================================================================================================ 3.0 - Customize Register (Validation) ================================================================================================ */ function barista_sanitize_checkbox($checked) { return((isset($checked) && true == $checked) ? true : false); } function barista_sanitize_layout($value) { if (!in_array($value, array('default', 'sidebar-right', 'sidebar-left'))) { $value = 'sidebar-right'; } return $value; } function barista_custom_colors_css() { ?>