get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; // Add theme options panel. $wp_customize->add_panel( 'auto-dealer', array( 'title' => esc_html__( 'Theme Options', 'auto-dealer' ), ) ); /** * Homepage. */ $wp_customize->add_section( 'homepage', array( 'title' => esc_html__( 'Homepage', 'auto-dealer' ), 'panel' => 'auto-dealer', ) ); $wp_customize->add_setting( 'slider_speed', array( 'sanitize_callback' => 'absint', 'default' => 3000, ) ); $wp_customize->add_control( 'slider_speed', array( 'label' => esc_html__( 'Top slider speed', 'auto-dealer' ), 'section' => 'homepage', 'type' => 'number', 'active_callback' => 'is_front_page', 'description' => esc_html__( 'The animation speed in milliseconds. Enter 0 to disable the slider.', 'auto-dealer' ), ) ); /** * Seach form. */ $wp_customize->add_setting( 'search_section', array( 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'search_section', array( 'label' => esc_html__( 'Search', 'auto-dealer' ), 'section' => 'homepage', 'type' => 'dropdown-pages', 'description' => wp_kses_post( __( 'The content of this page will be displayed below the search on your static front page.', 'auto-dealer' ) ), ) ); $wp_customize->selective_refresh->add_partial( 'search_section', array( 'selector' => '.section--search', 'container_inclusive' => true, 'render_callback' => 'auto_dealer_refresh_search_section', ) ); /** * All car section. */ $wp_customize->add_setting( 'allcar_title', array( 'default' => esc_html__( 'Browse Cars By Make', 'auto-dealer' ), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'allcar_title', array( 'label' => esc_html__( 'All car title', 'auto-dealer' ), 'section' => 'homepage', 'type' => 'text', ) ); $wp_customize->add_setting( 'allcar_description', array( 'default' => esc_html__( 'cars available in different categories', 'auto-dealer' ), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'allcar_description', array( 'label' => esc_html__( 'All car description', 'auto-dealer' ), 'section' => 'homepage', 'type' => 'textarea', ) ); $wp_customize->add_setting( 'allcar_button_text', array( 'default' => esc_html__( 'see all cars', 'auto-dealer' ), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'allcar_button_text', array( 'label' => esc_html__( 'All Car Button Text', 'auto-dealer' ), 'section' => 'homepage', 'type' => 'text', ) ); $wp_customize->add_setting( 'allcar_button_url', array( 'default' => esc_url( 'https://gretathemes.com/' ), 'sanitize_callback' => 'esc_url_raw', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'allcar_button_url', array( 'label' => esc_html__( 'All Car Button URL', 'auto-dealer' ), 'section' => 'homepage', 'type' => 'text', ) ); $wp_customize->add_setting( 'allcar_image', array( 'sanitize_callback' => 'auto_dealer_sanitize_image', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'homepage', array( 'label' => esc_html__( 'All Car Image Right', 'auto-dealer' ), 'section' => 'homepage', 'settings' => 'allcar_image', ) ) ); /** * Footer. */ $wp_customize->add_section( 'footer', array( 'title' => esc_html__( 'Footer', 'auto-dealer' ), 'panel' => 'auto-dealer', ) ); /** * Cta section. */ $wp_customize->add_setting( 'cta_title', array( 'default' => wp_kses_post( __( 'You Want To Have Your Favorite Car?', 'auto-dealer' ) ), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'cta_title', array( 'label' => esc_html__( 'Footer Title', 'auto-dealer' ), 'section' => 'footer', 'type' => 'textarea', ) ); $wp_customize->add_setting( 'cta_description', array( 'default' => esc_html__( 'We have a big list of modern & classic cars in both used and new categories.', 'auto-dealer' ), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'cta_description', array( 'label' => esc_html__( 'Footer Description', 'auto-dealer' ), 'section' => 'footer', 'type' => 'textarea', ) ); $wp_customize->add_setting( 'cta_button_text', array( 'default' => esc_html__( 'go to car listings', 'auto-dealer' ), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'cta_button_text', array( 'label' => esc_html__( 'Footer Button Text', 'auto-dealer' ), 'section' => 'footer', 'type' => 'text', ) ); $wp_customize->add_setting( 'cta_button_url', array( 'default' => esc_url( 'https://gretathemes.com/' ), 'sanitize_callback' => 'esc_url_raw', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'cta_button_url', array( 'label' => esc_html__( 'Footer Button URL', 'auto-dealer' ), 'section' => 'footer', 'type' => 'text', ) ); // Cta background. $wp_customize->add_setting( 'cta_background', array( 'sanitize_callback' => 'auto_dealer_sanitize_image', 'default' => get_template_directory_uri() . '/images/cta.png', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'cta_background', array( 'label' => esc_html__( 'Footer Image', 'auto-dealer' ), 'section' => 'footer', 'settings' => 'cta_background', ) ) ); /** * Footer section. */ $wp_customize->add_setting( 'footer_logo', array( 'sanitize_callback' => 'auto_dealer_sanitize_image', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'footer-logo', array( 'label' => esc_html__( 'Footer Logo', 'auto-dealer' ), 'section' => 'footer', 'settings' => 'footer_logo', ) ) ); } add_action( 'customize_register', 'auto_dealer_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function auto_dealer_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function auto_dealer_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function auto_dealer_customize_preview_js() { wp_enqueue_script( 'auto-dealer-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20180702', true ); } add_action( 'customize_preview_init', 'auto_dealer_customize_preview_js' ); /** * Sanitizes Image Upload. * * @param string $input potentially dangerous data. * * @return string */ function auto_dealer_sanitize_image( $input ) { $filetype = wp_check_filetype( $input ); if ( $filetype['ext'] && wp_ext2type( $filetype['ext'] ) === 'image' ) { return esc_url( $input ); } return ''; } /** * Live refresh search section. */ function auto_dealer_refresh_search_section() { get_template_part( 'template-parts/home/search-form' ); }