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' => 'brucke_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'brucke_customize_partial_blogdescription', ) ); } $wp_customize->add_section( 'slider', array( 'title' => __('Slider', 'brucke'), 'description' => __('Enter le titre, les url et les images.', 'brucke') )); /* // activation/desactivation du slider $wp_customize->add_setting( 'slider_settings' , array( 'default' => true, 'transport' => 'refresh', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control( 'slider_control', array( 'label' => 'Activation du slider', 'section' => 'slider', 'settings' => 'slider_settings', 'type' => 'radio', 'choices' => array( 'show' => 'Afficher le slider', 'hide' => 'Masquer le slider', ), 'priority' => 1, )); // Add the slider setting and control $wp_customize->add_setting( 'slider_setting', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw' )); */ // déclaration du Slide#1 $wp_customize->add_setting( 'slide_1_title_setting', array( 'default' => '', 'sanitize_callback' => 'wp_kses_post' ) ); $wp_customize->add_setting( 'slide_1_url_setting', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'slide_1_title_control', array( 'label' => 'Titre - slide 1', 'section' => 'slider', 'settings' => 'slide_1_title_setting', 'type' => 'text', 'priority' => 1, ) ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'slide_1_url_control', array( 'label' => 'Lien - slide 1', 'section' => 'slider', 'settings' => 'slide_1_url_setting', 'type' => 'text', 'priority' => 2 ) ) ); // déclaration du Slide#2 $wp_customize->add_setting( 'slide_2_title_setting', array( 'default' => '', 'sanitize_callback' => 'wp_kses_post' ) ); $wp_customize->add_setting( 'slide_2_url_setting', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'slide_2_title_control', array( 'label' => 'Lien - slide 2', 'section' => 'slider', 'settings' => 'slide_2_title_setting', 'type' => 'text', 'priority' => 4 ) ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'slide_2_url_control', array( 'label' => 'Slide 2 URL', 'section' => 'slider', 'settings' => 'slide_2_url_setting', 'type' => 'text', 'priority' => 5 ) ) ); // declaration du Slide#3 $wp_customize->add_setting( 'slide_3_title_setting', array( 'default' => '', 'sanitize_callback' => 'wp_kses_post' ) ); $wp_customize->add_setting( 'slide_3_url_setting', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'slide_3_title_control', array( 'label' => 'Titre - slide 3', 'section' => 'slider', 'settings' => 'slide_3_title_setting', 'type' => 'text', 'priority' => 7 ) ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'slide_3_url_control', array( 'label' => 'Lien - slide 3', 'section' => 'slider', 'settings' => 'slide_3_url_setting', 'type' => 'text', 'priority' => 8 ) ) ); $wp_customize->add_setting( 'slide_image_#1', array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'absint' ) ); $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'slide_image_#1', array( 'label' => ( 'Image - slide 1' ), 'section' => 'slider', 'flex_width' => false, // Optional. Default: false 'flex_height' => true, // Optional. Default: false 'width' => 1600, // Optional. Default: 150 'height' => 550, // Optional. Default: 150 'priority' => 3 ) ) ); $wp_customize->add_setting( 'slide_image_#2', array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'absint' ) ); $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'slide_image_#2', array( 'label' => ( 'Image - slide 2' ), 'section' => 'slider', 'flex_width' => false, // Optional. Default: false 'flex_height' => true, // Optional. Default: false 'width' => 1600, // Optional. Default: 150 'height' => 550, // Optional. Default: 150 'priority' => 6 ) ) ); $wp_customize->add_setting( 'slide_image_#3', array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'absint' ) ); $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'slide_image_#3', array( 'label' => ( 'Image - slide 3' ), 'section' => 'slider', 'flex_width' => false, // Optional. Default: false 'flex_height' => true, // Optional. Default: false 'width' => 1600, // Optional. Default: 150 'height' => 550, // Optional. Default: 150 'priority' => 9 ) ) ); ///////////////////////////////////////////////// ///////////////////////////////////////////////// ///////////////////////////////////////////////// ///////////////////////////////////////////////// } add_action( 'customize_register', 'brucke_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function brucke_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function brucke_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function brucke_customize_preview_js() { wp_enqueue_script( 'brucke-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'brucke_customize_preview_js' );