get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; // Customize Logo and Home info// // =============================== // = Logo = // =============================== $wp_customize->add_section( 'aurestaurant_logo_section' , array( 'title' => __( 'Logo', 'aurestaurant' ), 'priority' => 30, 'description' => 'Upload a logo to replace it here. (jpg, png allowed)', ) ); $wp_customize->add_setting( 'aurestaurant_logo', array( 'default' => '', 'sanitize_callback' => 'aurestaurant_sanitize_file' )); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'aurestaurant_logo', array( 'label' => __( 'Logo', 'aurestaurant' ), 'section' => 'aurestaurant_logo_section', 'settings' => 'aurestaurant_logo', ) ) ); // =============================== // = Home Text Titles section = // =============================== $wp_customize->add_section( 'aurestaurant_home_section' , array( 'title' => __('Customize Home Text','aurestaurant'), 'priority' => 35, 'description' => 'Customize Highlights titles', ) ); // Title1 $wp_customize->add_setting('aurestaurant_setting_home_title1', array( 'default' => 'The best food', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', // option 'sanitize_callback' => 'wp_filter_nohtml_kses' )); $wp_customize->add_control('aurestaurant_control_home_title1', array( 'label' => __('Title1', 'aurestaurant'), 'section' => 'aurestaurant_home_section', 'settings' => 'aurestaurant_setting_home_title1', )); // add color picker Title1 $wp_customize->add_setting( 'color_title1', array( 'default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color' ) ); // add color picker control color title1 $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'color_title1', array( 'label' => __('Color Title1', 'aurestaurant'), 'section' => 'aurestaurant_home_section', 'settings' => 'color_title1', ) ) ); // Title2 $wp_customize->add_setting('aurestaurant_setting_home_title2', array( 'default' => 'Art of asian gastronomy', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', // option 'sanitize_callback' => 'wp_filter_nohtml_kses' )); $wp_customize->add_control('aurestaurant_control_home_title2', array( 'label' => __('Title2', 'aurestaurant'), 'section' => 'aurestaurant_home_section', 'settings' => 'aurestaurant_setting_home_title2', )); // add color picker Title1 $wp_customize->add_setting( 'color_title2', array( 'default' => '#e2e3dd', 'sanitize_callback' => 'sanitize_hex_color' ) ); // add color picker control color title1 $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'color_title2', array( 'label' => __('Color Title2', 'aurestaurant'), 'section' => 'aurestaurant_home_section', 'settings' => 'color_title2', ) ) ); ///////////// // header image position /* $wp_customize->add_setting('aurestaurant_setting_header_image_position', array( 'default' => 'bottom', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'aurestaurant_sanitize_select' )); $wp_customize->add_control('aurestaurant_control_header_image_position', array( 'label' => __('Header Image position', 'aurestaurant'), 'section' => 'header_image',//'aurestaurant_home_section', 'settings' => 'aurestaurant_setting_header_image_position', 'type' => 'select', 'choices' => array( 'bottom' => esc_html__('bottom','restautheme'), 'center' => esc_html__('center','restautheme'), 'top' => esc_html__('top','restautheme'), ), ));*/ // ============================= // = Color Picker2 link color = // ============================= // add color picker setting $wp_customize->add_setting( 'link_color2', array( 'default' => '#980316', 'sanitize_callback' => 'sanitize_hex_color' ) ); // add color picker control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color2', array( 'label' => __('Link Color', 'aurestaurant'), 'section' => 'colors',// 'settings' => 'link_color2', ) ) ); // ============================= // = Color Picker footerlink color = // ============================= // add color picker setting $wp_customize->add_setting( 'link_color_footer', array( 'default' => '#f5596b', 'sanitize_callback' => 'sanitize_hex_color' ) ); // add color picker control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color_footer', array( 'label' => __('Link Color Footer', 'aurestaurant'), 'section' => 'colors', 'settings' => 'link_color_footer', ) ) ); // ============================= // = Header line bottom = // ============================= // header_line_color $wp_customize->add_setting( 'header_line_color', array( 'default' => '#391f24', 'sanitize_callback' => 'sanitize_hex_color' ) ); // add color picker control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_line_color', array( 'label' => __('Header Line bottom Color', 'aurestaurant'), 'section' => 'colors', 'settings' => 'header_line_color', ) ) ); // ============================= // = Text menu color = // ============================= // add color picker setting menu text color $wp_customize->add_setting( 'menu_link_text_color', array( 'default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color' ) ); // add color picker control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'menu_link_text_color', array( 'label' => __('Menu Text Color', 'aurestaurant'), 'section' => 'colors', 'settings' => 'menu_link_text_color', ) ) ); // ============================= // = Color background submenu = // ============================= // add color picker setting background submenu color $wp_customize->add_setting( 'background_submenu', array( 'default' => '#7a1227', 'sanitize_callback' => 'sanitize_hex_color' ) ); // add color picker control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'background_submenu', array( 'label' => __('Submenu background Color', 'aurestaurant'), 'section' => 'colors', 'settings' => 'background_submenu', ) ) ); } add_action( 'customize_register', 'aurestaurant_customize_register' ); /* * Sanitize functions */ //file input sanitization function function aurestaurant_sanitize_file( $file, $setting ) { //allowed file types $mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'png' => 'image/png' ); //check file type from file name $file_ext = wp_check_filetype( $file, $mimes ); //if file has a valid mime type return it, otherwise return default return ( $file_ext['ext'] ? $file : $setting->default ); } /*function aurestaurant_sanitize_select( $input, $setting ){ //input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only $input = sanitize_key($input); //get the list of possible select options $choices = $setting->manager->get_control( $setting->id )->choices; //return input if valid or return default option return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); }*/ /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function aurestaurant_customize_preview_js() { wp_enqueue_script( 'aurestaurant_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'aurestaurant_customize_preview_js' );