get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'adventeqa_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'adventeqa_customize_partial_blogdescription', ) ); } $wp_customize->add_panel( 'adventeqa_general_settings', array( 'title' => __('General Settings', 'adventeqa'), 'priority' => 20, 'active_callback' => '', ) ); $wp_customize->get_section( 'title_tagline' )->panel = 'adventeqa_general_settings'; $wp_customize->get_section( 'colors' )->panel = 'adventeqa_general_settings'; $wp_customize->get_section( 'background_image' )->panel = 'adventeqa_general_settings'; $wp_customize->get_section( 'custom_css' )->panel = 'adventeqa_general_settings'; $wp_customize->add_panel( 'adventeqa_settings', array( 'title' => __('Homepage Settings', 'adventeqa'), 'priority' => 20, 'active_callback' => '', ) ); $wp_customize->get_section( 'static_front_page' )->panel = 'adventeqa_general_settings'; $wp_customize->get_section( 'static_front_page' )->priority = 10; $wp_customize->get_section( 'static_front_page' )->title = 'FrontPage Settings'; /* Slider/Header */ $wp_customize->add_section( 'adventeqa_slider_settings', array( 'title' => __('Header Settings', 'adventeqa'), 'description' => __('This header is used when frontpage is not set to show WooCommerce layout', 'adventeqa'), 'priority' => 20, 'panel' => 'adventeqa_general_settings', 'active_callback' => '', ) ); $wp_customize->add_setting( 'adventeqa_show_slider', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_yes_no', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, //Pass the $wp_customize object (required) 'adventeqa_show_slider', //Set a unique ID for the control array( 'label' => __( 'Show Header', 'adventeqa' ), 'settings' => 'adventeqa_show_slider', 'priority' => 10, 'section' => 'adventeqa_slider_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['yesno'], ) ) ); $wp_customize->add_setting( 'adventeqa_slider_id', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_post_select', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, //Pass the $wp_customize object (required) 'adventeqa_slider_id', //Set a unique ID for the control array( 'label' => __( 'Header Post', 'adventeqa' ), 'description' => __( 'This post will be shown as header.', 'adventeqa'), 'settings' => 'adventeqa_slider_id', 'priority' => 11, 'section' => 'adventeqa_slider_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['posts'], ) ) ); $wp_customize->add_panel( 'adventeqa_app_settings', array( 'title' => __('App Layout Settings', 'adventeqa'), 'priority' => 30, 'active_callback' => '', ) ); /* Product Slider */ $wp_customize->add_section( 'adventeqa_app_header_settings', array( 'title' => __('Header Settings', 'adventeqa'), 'priority' => 10, 'panel' => 'adventeqa_app_settings', 'active_callback' => '', ) ); $wp_customize->add_setting( 'adventeqa_show_app_header', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_yes_no', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'adventeqa_show_app_header', array( 'label' => __( 'Show header?', 'adventeqa' ), 'description' => __( 'Select if you want to show header area', 'adventeqa'), 'settings' => 'adventeqa_show_app_header', 'priority' => 10, 'section' => 'adventeqa_app_header_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['yesno'], ) ) ); $wp_customize->add_setting( 'adventeqa_app_header_post', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, //Pass the $wp_customize object (required) 'adventeqa_app_header_post', //Set a unique ID for the control array( 'label' => __( 'Header Post', 'adventeqa' ), 'description' => __( 'Select a post to show in Header.', 'adventeqa'), 'settings' => 'adventeqa_app_header_post', 'priority' => 20, 'section' => 'adventeqa_app_header_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['posts'], ) ) ); $wp_customize->add_setting( 'adventeqa_app_header_post_cta', array( 'default' => __( 'SignUp Now', 'adventeqa' ), 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, //Pass the $wp_customize object (required) 'adventeqa_app_header_post_cta', //Set a unique ID for the control array( 'label' => __( 'CTA', 'adventeqa' ), 'description' => __( 'Enter a cta for header.', 'adventeqa'), 'settings' => 'adventeqa_app_header_post_cta', 'priority' => 20, 'section' => 'adventeqa_app_header_settings', 'type' => 'text', ) ) ); /* Store Features */ $wp_customize->add_section( 'adventeqa_app_features_settings', array( 'title' => __('App features Settings', 'adventeqa'), 'priority' => 30, 'panel' => 'adventeqa_app_settings', 'active_callback' => '', ) ); $wp_customize->add_setting( 'adventeqa_show_app_features', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_yes_no', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'adventeqa_show_app_features', array( 'label' => __( 'Show App features?', 'adventeqa' ), 'description' => __( 'Select if you want to show features section', 'adventeqa'), 'settings' => 'adventeqa_show_app_features', 'priority' => 10, 'section' => 'adventeqa_app_features_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['yesno'], ) ) ); $wp_customize->add_setting( 'adventeqa_app_feature_heading_id', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_post_select', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'adventeqa_app_feature_heading_id', array( 'label' => __( 'Feature Heading', 'adventeqa' ), 'description' => __( 'This post will be shown as feature one, Post title as heading, post text as sub heading, featured image as image.', 'adventeqa'), 'settings' => 'adventeqa_app_feature_heading_id', 'priority' => 20, 'section' => 'adventeqa_app_features_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['posts'], ) ) ); $wp_customize->add_setting( 'adventeqa_app_feature_items', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_category_select', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'adventeqa_app_feature_items', array( 'label' => __( 'Select category?', 'adventeqa' ), 'description' => __( 'Posts from this category will show up as feature items.', 'adventeqa'), 'settings' => 'adventeqa_app_feature_items', 'priority' => 30, 'section' => 'adventeqa_app_features_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['categories'], ) ) ); /* About */ $wp_customize->add_section( 'adventeqa_app_about_settings', array( 'title' => __('About Settings', 'adventeqa'), 'priority' => 40, 'panel' => 'adventeqa_app_settings', 'active_callback' => '', ) ); $wp_customize->add_setting( 'adventeqa_show_app_about', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_yes_no', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'adventeqa_show_app_about', array( 'label' => __( 'Show about?', 'adventeqa' ), 'description' => __( 'Select if you want to show about section', 'adventeqa'), 'settings' => 'adventeqa_show_app_about', 'priority' => 10, 'section' => 'adventeqa_app_about_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['yesno'], ) ) ); $wp_customize->add_setting( 'adventeqa_app_about_heading_post', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_post_select', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'adventeqa_app_about_heading_post', array( 'label' => __( 'About Heading', 'adventeqa' ), 'description' => __( 'This post will be shown as about section text, Post title as heading, post text as sub heading.', 'adventeqa'), 'settings' => 'adventeqa_app_about_heading_post', 'priority' => 20, 'section' => 'adventeqa_app_about_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['posts'], ) ) ); $wp_customize->add_setting( 'adventeqa_app_about_video', array( //'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'adventeqa_app_about_video', #setting/option_id [ 'mime_type' => 'video', 'section' => 'adventeqa_app_about_settings', 'label' => __('About Video', 'adventeqa'), 'description' => __('Select a video to show in about section.', 'adventeqa'), 'priority' => 30, ] ) ); /* Testimonials */ $wp_customize->add_section( 'adventeqa_app_testimonials_settings', array( 'title' => __('Testimonials Settings', 'adventeqa'), 'priority' => 70, 'panel' => 'adventeqa_app_settings', 'active_callback' => '', ) ); $wp_customize->add_setting( 'adventeqa_show_app_testimonials', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_yes_no', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'adventeqa_show_app_testimonials', array( 'label' => __( 'Show testimonials?', 'adventeqa' ), 'description' => __( 'Select if you want to show testimonials section', 'adventeqa'), 'settings' => 'adventeqa_show_app_testimonials', 'priority' => 10, 'section' => 'adventeqa_app_testimonials_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['yesno'], ) ) ); $wp_customize->add_setting( 'adventeqa_app_testimonials_cat', array( 'default' => 'select', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'adventeqa_sanitize_category_select', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, //Pass the $wp_customize object (required) 'adventeqa_app_testimonials_cat', //Set a unique ID for the control array( 'label' => __( 'Testimonials Category', 'adventeqa' ), 'description' => __( 'Posts from this category will show up in testimonials.', 'adventeqa'), 'settings' => 'adventeqa_app_testimonials_cat', 'priority' => 20, 'section' => 'adventeqa_app_testimonials_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['categories'], ) ) ); $wp_customize->add_setting( 'adventeqa_app_testimonials_num', array( 'default' => '5', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, //Pass the $wp_customize object (required) 'adventeqa_app_testimonials_num', //Set a unique ID for the control array( 'label' => __( 'How many testimonials', 'adventeqa' ), 'description' => __( 'Select how many testimonials to show.', 'adventeqa'), 'settings' => 'adventeqa_app_testimonials_num', 'priority' => 20, 'section' => 'adventeqa_app_testimonials_settings', 'type' => 'select', 'choices' => $adventeqa_options_array['slides'], ) ) ); } add_action( 'customize_register', 'adventeqa_customize_register' ); $adventeqa_options_array = array(); $adventeqa_options_array['categories'] = array( 'select' => __( 'Select', 'adventeqa' ) ); $adventeqa_options_array['slides'] = array( '1' => __( '1', 'adventeqa' ), '2' => __( '2', 'adventeqa' ), '3' => __( '3', 'adventeqa' ), '4' => __( '4', 'adventeqa' ), '5' => __( '5', 'adventeqa' ), '6' => __( '6', 'adventeqa' ), '7' => __( '7', 'adventeqa' ), '8' => __( '8', 'adventeqa' ), '9' => __( '9', 'adventeqa' ), '10' => __( '10', 'adventeqa' ) ); $adventeqa_categories_raw = get_categories( array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, ) ); foreach( $adventeqa_categories_raw as $adventeqa_category ){ $adventeqa_options_array['categories'][$adventeqa_category->term_id] = $adventeqa_category->name; } $adventeqa_options_array['yesno'] = array( 'select' => __('Select', 'adventeqa'), 'yes' => __('Yes', 'adventeqa'), 'no' => __('No', 'adventeqa'), ); $adventeqa_options_array['posts'] = array( 'select' => __('Select a post/page', 'adventeqa'), ); $adventeqa_posts_args = array( // Change these category SLUGS to suit your use. 'ignore_sticky_posts' => 1, 'post_type' => array('post', 'page'), 'orderby' => 'date', 'posts_per_page' => -1, 'post_status' => 'publish', ); $adventeqa_posts_query = new WP_Query( $adventeqa_posts_args ); if ( $adventeqa_posts_query->have_posts() ) : while ( $adventeqa_posts_query->have_posts() ) : $adventeqa_posts_query->the_post(); $adventeqa_posts_id = get_the_ID(); if(get_the_title() != ''){ $adventeqa_posts_title = get_the_title(); }else{ $adventeqa_posts_title = get_the_ID(); } $adventeqa_options_array['posts'][$adventeqa_posts_id] = $adventeqa_posts_title; endwhile; wp_reset_postdata(); endif; /** * Render the site title for the selective refresh partial. * * @return void */ function adventeqa_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function adventeqa_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function adventeqa_customize_preview_js() { wp_enqueue_script( 'adventeqa-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'adventeqa_customize_preview_js' ); function adventeqa_sanitize_yes_no( $value ){ global $adventeqa_options_array; if( ! array_key_exists( $value, $adventeqa_options_array['yesno'] ) ){ $value = 'select'; } return $value; } function adventeqa_sanitize_category_select( $value ){ global $adventeqa_options_array; if( ! array_key_exists( $value, $adventeqa_options_array['categories'] ) ){ $value = 'select'; } return $value; } function adventeqa_sanitize_slider_slides( $value ){ global $adventeqa_options_array; if( ! array_key_exists( $value, $adventeqa_options_array['slides'] ) ){ $value = '5'; } return $value; } function adventeqa_sanitize_post_select( $value ){ global $adventeqa_options_array; if( ! array_key_exists( $value, $adventeqa_options_array['posts'] ) ){ $value = 'select'; } return $value; }