get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; /*------------------------------------------------------------------------*/ //Logo Settings $wp_customize->add_section( 'title_tagline' , array( 'title' => __( 'Title, Tagline & Logo', 'blogyy' ), 'priority' => 30, ) ); // Header Area $wp_customize->add_section('heder_sec',array( 'title' => __('Top Bar Contact','blogyy'), 'description' => '', 'priority' => 31, )); $wp_customize->add_setting('head_email',array( 'default' => 'info@blogyy.com', 'sanitize_callback' => 'sanitize_email' )); $wp_customize->add_control('head_email',array( 'label' => __('Add header email here','blogyy'), 'section' => 'heder_sec', 'setting' => 'head_email' )); $wp_customize->add_setting('head_number',array( 'default' => '0978 456 321', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_control('head_number',array( 'label' => __('Add header phone number here','blogyy'), 'section' => 'heder_sec', 'setting' => 'head_number' )); // Social Icons $wp_customize->add_section('blogyy_social_section', array( 'title' => __('Social Icons','blogyy'), 'priority' => 32 , )); $social_networks = array( //Redefinied in Sanitization Function. 'none' => __('-','blogyy'), 'facebook-alt' => __('Facebook','blogyy'), 'twitter' => __('Twitter','blogyy'), 'googleplus' => __('Google Plus','blogyy'), 'instagram' => __('Instagram','blogyy'), 'feed' => __('RSS Feeds','blogyy'), 'vimeo' => __('Vimeo','blogyy'), 'youtube' => __('Youtube','blogyy'), 'flickr' => __('Flickr','blogyy'), ); $social_count = count($social_networks); for ($x = 1 ; $x <= ($social_count - 1) ; $x++) : $wp_customize->add_setting( 'blogyy_social_'.$x, array( 'sanitize_callback' => 'blogyy_sanitize_social', 'default' => 'none' )); $wp_customize->add_control( 'blogyy_social_'.$x, array( 'settings' => 'blogyy_social_'.$x, 'label' => __('Icon ','blogyy').$x, 'section' => 'blogyy_social_section', 'type' => 'select', 'choices' => $social_networks, )); $wp_customize->add_setting( 'blogyy_social_url'.$x, array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control( 'blogyy_social_url'.$x, array( 'settings' => 'blogyy_social_url'.$x, 'description' => __('Icon ','blogyy').$x.__(' Url','blogyy'), 'section' => 'blogyy_social_section', 'type' => 'url', 'choices' => $social_networks, )); endfor; function blogyy_sanitize_social( $input ) { $social_networks = array( 'none' , 'facebook-alt', 'twitter', 'googleplus', 'instagram', 'feed', 'vimeo', 'youtube', 'flickr' ); if ( in_array($input, $social_networks) ) return $input; else return ''; } // Primary color setting and control. $wp_customize->add_setting( 'primary_color', array( 'default' => '#00b9ed', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_color', array( 'label' => __( 'Primary Color', 'blogyy' ), 'section' => 'colors', ) ) ); // Add main text color setting and control. $wp_customize->add_setting( 'main_text_color', array( 'default' => '#3e3e3e', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'main_text_color', array( 'label' => __( 'Main Text Color', 'blogyy' ), 'section' => 'colors', ) ) ); // Featured Post Slider $wp_customize->add_section( 'blogyy_postslider', array( 'title' => __('Featured Posts Slider','blogyy'), 'priority' => 35, ) ); $wp_customize->add_setting( 'blogyy_postslider_enable', array( 'sanitize_callback' => 'blogyy_sanitize_checkbox' ) ); $wp_customize->add_control( 'blogyy_postslider_enable', array( 'settings' => 'blogyy_postslider_enable', 'label' => __( 'Enable', 'blogyy' ), 'section' => 'blogyy_postslider', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'blogyy_postslider_cat', array( 'sanitize_callback' => 'blogyy_sanitize_category' ) ); $wp_customize->add_control( new blogyy_WP_Customize_Category_Control( $wp_customize, 'blogyy_postslider_cat', array( 'label' => __('Category For Featured Posts Slider','blogyy'), 'settings' => 'blogyy_postslider_cat', 'section' => 'blogyy_postslider' ) ) ); function blogyy_sanitize_checkbox( $input ){ if ( $input == 1 || $input == 'true' || $input === true ) { return 1; } else { return 0; } } function blogyy_sanitize_category( $input ) { if ( term_exists(get_cat_name( $input ), 'category') ) return $input; else return ''; } } add_action( 'customize_register', 'blogyy_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function blogyy_customize_preview_js() { wp_enqueue_script( 'blogyy_customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20161025', true ); } add_action( 'customize_preview_init', 'blogyy_customize_preview_js' );