get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; $wp_customize->selective_refresh->add_partial( 'amathambo_prepend_custom_logo_setting', array( 'render_callback' => 'amathambo_title_background_image();', ) ); /** * Add section for use by theme miscellaneous settings */ $wp_customize->add_section( 'amathambo_options_section', array( 'title' => __( 'amaThambo Options', 'amathambo' ), ) ); $wp_customize->add_setting( 'amathambo_pagination_navigation_setting', array( 'default' => 'pagination', 'transport' => 'refresh', 'sanitize_callback' => 'amathambo_radio_text_sanitization', ) ); $wp_customize->add_control( new Amathambo_Text_Radio_Button_Control( $wp_customize, 'amathambo_pagination_navigation', array( 'settings' => 'amathambo_pagination_navigation_setting', 'section' => 'amathambo_options_section', 'type' => 'text_radio_button', 'label' => __( 'Posts Navigation/Pagination', 'amathambo' ), 'choices' => array( 'pagination' => __( 'Pagination', 'amathambo' ), 'navigation' => __( 'Navigation', 'amathambo' ), ), ) ) ); $wp_customize->add_setting( 'amathambo_post_style_setting', array( 'default' => 'excerpt', 'transport' => 'refresh', 'sanitize_callback' => 'amathambo_radio_text_sanitization', ) ); $wp_customize->add_control( new Amathambo_Text_Radio_Button_Control( $wp_customize, 'amathambo_post_style', array( 'settings' => 'amathambo_post_style_setting', 'section' => 'amathambo_options_section', 'type' => 'text_radio_button', 'label' => __( 'Post Style', 'amathambo' ), 'choices' => array( 'excerpt' => __( 'Excerpt', 'amathambo' ), 'content' => __( 'Content', 'amathambo' ), ), ) ) ); $wp_customize->add_setting( 'amathambo_author_name_setting', array( 'default' => 'yes', 'transport' => 'refresh', 'sanitize_callback' => 'amathambo_radio_text_sanitization', ) ); $wp_customize->add_control( new Amathambo_Text_Radio_Button_Control( $wp_customize, 'amathambo_author_name', array( 'settings' => 'amathambo_author_name_setting', 'section' => 'amathambo_options_section', 'type' => 'text_radio_button', 'label' => __( 'Display Author Name', 'amathambo' ), 'choices' => array( 'yes' => __( 'Yes', 'amathambo' ), 'no' => __( 'No', 'amathambo' ), ), ) ) ); $wp_customize->add_setting( 'amathambo_featured_images_setting', array( 'default' => 'yes', 'transport' => 'refresh', 'sanitize_callback' => 'amathambo_radio_text_sanitization', ) ); $wp_customize->add_control( new Amathambo_Text_Radio_Button_Control( $wp_customize, 'amathambo_featured_images', array( 'settings' => 'amathambo_featured_images_setting', 'section' => 'amathambo_options_section', 'type' => 'text_radio_button', 'label' => __( 'Display Featured Images', 'amathambo' ), 'choices' => array( 'yes' => __( 'Yes', 'amathambo' ), 'no' => __( 'No', 'amathambo' ), ), ) ) ); } add_action( 'customize_register', 'amathambo_customize_register' ); } // End if(). /** * Sanitize Callbacks */ if ( ! function_exists( 'amathambo_text_sanitization' ) ) { /** * Radio Text sanitization. * * @param string $input Text to be sanitized. * @return string $input Sanitized text. */ function amathambo_radio_text_sanitization( $input ) { if ( strpos( $input, ',' ) !== false ) { $input = explode( ',', $input ); } if ( is_array( $input ) ) { foreach ( $input as $key => $value ) { $input[ $key ] = sanitize_text_field( $value ); } $input = implode( ',', $input ); } else { $input = sanitize_text_field( $input ); } return $input; } } /** * Binds JS handler to make Theme Customizer preview reload changes asynchronously. */ function amathambo_customizer_preview() { wp_enqueue_script( 'amathambo-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'jquery', 'customize-preview' ) ); } add_action( 'customize_preview_init', 'amathambo_customizer_preview' ); /** * Custom Control Styling. */ function amathambo_customizer_custom_control_css() { ?>