get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->add_section( 'rad-layout', array( 'title' => __('Layout Settings','rad'), 'description' => __('Manage the Layout Settings of your site.','rad'), 'priority' => 1, ) ); $wp_customize-> add_setting( 'rad-f-img', array( 'sanitize_callback' => 'rad_sanitize_checkbox', ) ); $wp_customize-> add_control( 'rad-f-img', array( 'type' => 'checkbox', 'label' => __('Show Featured Image in the Post.','rad'), 'section' => 'rad-layout', 'priority' => 1, ) ); $wp_customize-> add_setting( 'rad-sidebar', array( 'default' => 'right', 'sanitize_callback' => 'rad_sanitize_select' ) ); $wp_customize-> add_control( 'rad-sidebar', array( 'type' => 'select', 'label' => __('Select the Sidebar orientation for the site','rad'), 'section' => 'rad-layout', 'priority' => 2, 'choices' => array( 'left' => __('Left', 'rad'), 'right' => __('Right', 'rad') ), ) ); $wp_customize-> add_setting( 'rad-home-layout', array( 'default' => 'alt', 'sanitize_callback' => 'rad_sanitize_select_3' ) ); $wp_customize-> add_control( 'rad-home-layout', array( 'type' => 'select', 'label' => __('Select the Sidebar orientation for the site','rad'), 'section' => 'rad-layout', 'priority' => 5, 'choices' => array( 'alt' => __('Alternate View', 'rad'), 'list' => __('List View', 'rad') ), ) ); $wp_customize->add_section( 'rad-social', array( 'title' => __('Social Settings','rad'), 'description' => __('Manage the Social Icon Settings of your site.','rad'), 'priority' => 2, ) ); $wp_customize-> add_setting( 'social', array( 'sanitize_callback' => 'rad_sanitize_checkbox', ) ); $wp_customize-> add_control( 'social', array( 'type' => 'checkbox', 'label' => __('Enable Social Icons','rad'), 'section' => 'rad-social', 'priority' => 1, ) ); $wp_customize->add_setting( 'social-select', array( 'default' => 'default', 'sanitize_callback' => 'rad_sanitize_select_2', ) ); $wp_customize->add_control( 'social-select', array( 'type' => 'select', 'label' => __('Select the icons to be displayed','rad'), 'section' => 'rad-social', 'priority' => 2, 'choices' => array( 'default' => __('Default', 'rad'), 'boxicons' => __('Boxicons', 'rad') ), ) ); $wp_customize-> add_setting( 'rad-facebook', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-facebook', array( 'label' => __('Facebook URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-twitter', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-twitter', array( 'label' => __('Twitter URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-gplus', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-gplus', array( 'label' => __('Google+ URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-instagram', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-instagram', array( 'label' => __('Instagram URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-pinterest', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-pinterest', array( 'label' => __('Pinterest URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-youtube', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-youtube', array( 'label' => __('YouTube URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-rss', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-rss', array( 'label' => __('RSS URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-linkedin', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-linkedin', array( 'label' => __('LinkedIn URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-mail', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-mail', array( 'label' => __('Contact Page URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize-> add_setting( 'rad-vimeo', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize-> add_control( 'rad-vimeo', array( 'label' => __('Vimeo URL','rad'), 'section' => 'rad-social', 'type' => 'text', ) ); $wp_customize->add_panel( 'rad-showcase', array( 'priority' => 12, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Showcase Settings', 'rad'), ) ); //*----Featured Posts Section----*// class Rad_Featured_Post_Control extends WP_Customize_Control { private $posts = false; public function __construct($manager, $id, $args = array(), $options = array()) { $postargs = wp_parse_args($options, array('numberposts' => '-1')); $this->posts = get_posts($postargs); parent::__construct( $manager, $id, $args ); } /** * Render the content on the theme customizer page */ public function render_content() { if(!empty($this->posts)) { ?> add_panel( 'rad-featured-post', array( 'priority' => 3, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Featured Posts Area', 'rad'), 'description' => '', ) ); $wp_customize-> add_section( 'rad-fp-enable', array( 'title' => __('Enable Featured Posts','rad'), 'panel' => 'rad-featured-post', 'priority' => 1 ) ); $wp_customize-> add_setting( 'rad-fp-enable', array( 'default' => false, 'sanitize_callback' => 'rad_sanitize_checkbox', ) ); $wp_customize-> add_control( 'rad-fp-enable', array( 'type' => 'checkbox', 'label' => __('Enable the Featured Posts Area','rad'), 'section' => 'rad-fp-enable', 'priority' => 1, ) ); $wp_customize-> add_section( 'rad-fp-select', array( 'title' => __('Choose your featured Posts','rad'), 'panel' => 'rad-featured-post', 'priority' => 2 ) ); $wp_customize-> add_setting( 'rad-fp-1', array( 'default' => '' ) ); $wp_customize-> add_control( new Rad_Featured_Post_Control( $wp_customize, 'rad-fp-1', array( 'label' => __('Post 1','rad'), 'section' => 'rad-fp-select', 'settings' => 'rad-fp-1' ) ) ); $wp_customize-> add_setting( 'rad-fp-2', array( 'default' => '', 'sanitize_callback' => 'rad_sanitize_text', 'transport' => 'refresh' ) ); $wp_customize-> add_control( new Rad_Featured_Post_Control( $wp_customize, 'rad-fp-2', array( 'label' => __('Post 2','rad'), 'section' => 'rad-fp-select', 'settings' => 'rad-fp-2' ) ) ); $wp_customize-> add_setting( 'rad-fp-3', array( 'default' => '', 'sanitize_callback' => 'rad_sanitize_text', 'transport' => 'refresh' ) ); $wp_customize-> add_control( new Rad_Featured_Post_Control( $wp_customize, 'rad-fp-3', array( 'label' => __('Post 3','rad'), 'section' => 'rad-fp-select', 'settings' => 'rad-fp-3' ) ) ); $wp_customize->add_setting( 'rad-title', array( 'default' => '#55be9d', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'rad-title', array( 'label' => __('Title Color','rad'), 'section' => 'colors', 'settings' => 'rad-title', 'priority' => 2, ) ) ); $wp_customize->add_setting( 'rad-desc', array( 'default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'rad-desc', array( 'label' => __('Description Color','rad'), 'section' => 'colors', 'settings' => 'rad-desc', 'priority' => 3, ) ) ); $wp_customize-> add_section( 'rad_custom', array( 'title' => __('Custom Settings','rad'), 'description' => __('Add some custom CSS code to edit your theme.','rad'), 'priority' => 20, ) ); $wp_customize->add_setting( 'rad-custom-css', array( 'default' => '', 'sanitize_callback' => 'rad_sanitize_text' ) ); $wp_customize->add_control( 'rad-custom-css', array( 'type' => 'textarea', 'label' => __('Custom CSS','rad'), 'section' => 'rad_custom', 'settings' => 'rad-custom-css' ) ); function rad_sanitize_text( $t ) { return wp_kses_post( force_balance_tags( $t ) ); } if ( $wp_customize->is_preview() && ! is_admin() ) { add_action( 'wp_footer', 'rad_customize_preview',21); } function rad_sanitize_checkbox( $i ) { if ( $i == 1 ) { return 1; } else { return ''; } } function rad_sanitize_select_2( $input ) { $valid = array( 'default' => __('Default','rad'), 'boxicons' => __('Boxicons','rad') ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } function rad_sanitize_select_3( $input ) { $valid = array( 'alt' => __('Alternate View','rad'), 'list' => __('List View','rad') ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } function rad_sanitize_select( $input ) { $valid = array( 'left' => __('Left','rad'), 'right' => __('Right','rad') ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } } add_action( 'customize_register', 'rad_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function rad_customize_preview_js() { wp_enqueue_script( 'rad_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true ); } add_action( 'customize_preview_init', 'rad_customize_preview_js' );