or just a text. * * @param string $input The text prior to being sanitized. * @return string (maybe) only a text or a text that only contain . */ function buildx_sanitize_title_text( $input ){ return wp_kses( $input, array( 'span' => array() ) ); } /** * sanitize file input to only accept image file with extention jpg, jpeg, jpe and png. * * @param object $file The file prior to being sanitized. * @return object (maybe) only return the file that has extention jpg, jpeg, jpe and png. */ function buildx_sanitize_file( $file ) { //allowed file types $mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'png' => 'image/png' ); $file_ext = wp_check_filetype( $file, $mimes ); //check file type from file name return ( $file_ext['ext'] ? $file : null ); //if file has a valid mime type return it, otherwise return default } /** * sanitize phone number to only accept plus minus symbol, number [0-9], and space. * * @param string $input the text prior to being sanitized. * @return string (maybe) the text only contain plus minus symbol, number [0-9], and space. */ function buildx_sanitize_phonenumb( $input ){ return preg_replace( '/[^0-9\s+]/', '', $input ); } /** * sanitize a text to only has a string with element html or or just a text. * * @param string $input The text prior to being sanitized. * @return string (maybe) only a text or a text that only contain or . */ function buildx_sanitize_text_contact( $input ){ return wp_kses( $input, array( 'i' => array(), 'em' => array() ) ); } /* ================================================== CUSTOMIZER PANEL ================================================== */ // add home page customizer panel $wp_customize-> add_panel( 'home-page-customizer-panel', array( 'title' => 'Home Page Customizer', 'description' => 'Configure your home page here', 'priority' => 30, // Mixed with top-level-section hierarchy. 'capability' => 'edit_theme_options' ) ); /* ================================================== TOP-BAR CONTACT SECTION ================================================== */ // top-bar contact section $wp_customize-> add_section( 'sec-top-bar', array( 'title' => 'Top-Bar Contact', 'description' => 'You can setup email and phone number on top-bar here', 'panel' => 'home-page-customizer-panel' ) ); // email customizer $wp_customize-> add_setting( 'set-email', array( 'type' => 'theme_mod', 'default' => 'support@domain.com', 'sanitize_callback' => 'sanitize_email' ) ); $wp_customize-> add_control( 'ctrl-email', array( 'label' => 'Email', 'description' => 'please, type your email here.', 'section' => 'sec-top-bar', 'settings' => 'set-email', 'type' => 'text' ) ); // phone number customizer $wp_customize-> add_setting( 'set-phone-number', array( 'type' => 'theme_mod', 'default' => '+080 0444 333 444', 'sanitize_callback' => 'buildx_sanitize_phonenumb' ) ); $wp_customize-> add_control( 'ctrl-phone-number', array( 'label' => 'Phone Number', 'description' => 'please, type your phone number here.', 'section' => 'sec-top-bar', 'settings' => 'set-phone-number', 'type' => 'text' ) ); /* ================================================== FEATURED IMAGE SECTION ================================================== */ // header image section $wp_customize-> add_section( 'sec-featured-image', array( 'title' => 'Header Image', 'description' => 'You can choose your featured image here', 'panel' => 'home-page-customizer-panel' ) ); // featured image customizer $wp_customize-> add_setting( 'set-featured-image', array( 'type' => 'theme_mod', 'default' => get_template_directory_uri() . '/assets/img/construction.jpg', 'sanitize_callback' => 'buildx_sanitize_file' ) ); $wp_customize-> add_control( new WP_Customize_Upload_Control( $wp_customize, 'ctrl-featured-image', array( 'label' => 'Header Image (Parallax)', 'description' => 'please, select an image.', 'section' => 'sec-featured-image', 'settings' => 'set-featured-image', ) ) ); // title featured image customizer $wp_customize-> add_setting( 'set-title-featured-image', array( 'type' => 'theme_mod', 'default' => 'WE DO BIG THINGS WITH BIG IDEAS', 'sanitize_callback' => 'buildx_sanitize_title_text' ) ); $wp_customize-> add_control( 'ctrl-title-featured-image', array( 'label' => 'Title', 'description' => 'please, type your title header here.', 'section' => 'sec-featured-image', 'settings' => 'set-title-featured-image', 'type' => 'text' ) ); // desctiption header image customizer $wp_customize-> add_setting( 'set-desctiption-featured-image', array( 'type' => 'theme_mod', 'default' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-desctiption-featured-image', array( 'label' => 'Description', 'description' => 'please, type your desctiption header here.', 'section' => 'sec-featured-image', 'settings' => 'set-desctiption-featured-image', 'type' => 'textarea' ) ); // button text featured image customizer $wp_customize-> add_setting( 'set-button-text-featured-image', array( 'type' => 'theme_mod', 'default' => 'Explore Now', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-button-text-featured-image', array( 'label' => 'Button Text', 'description' => 'please, type your button text here.', 'section' => 'sec-featured-image', 'settings' => 'set-button-text-featured-image', 'type' => 'text' ) ); // button's href customizer $wp_customize-> add_setting( 'set-button-href-featured-image', array( 'type' => 'theme_mod', 'default' => '#', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize-> add_control( 'ctrl-button-href-header-image', array( 'label' => 'Button Url', 'description' => 'please, type your button text here.', 'section' => 'sec-featured-image', 'settings' => 'set-button-href-featured-image', 'type' => 'url' ) ); /* ================================================== CONTACT SECTION ================================================== */ // contact section $wp_customize-> add_section( 'sec-contact', array( 'title' => 'Contact', 'description' => 'You can setup contact text, button text and button url here', 'panel' => 'home-page-customizer-panel' ) ); // contact description customizer $wp_customize-> add_setting( 'set-contact-description', array( 'type' => 'theme_mod', 'default' => 'Consulting And Estimating For Your Project, Contact Us Today', 'sanitize_callback' => 'buildx_sanitize_text_contact' ) ); $wp_customize-> add_control( 'ctrl-contact-description', array( 'label' => 'Text', 'description' => 'Please, type your text here. To make your text blod, italic and underline, please put the text between <i> your text </i> or <em> your text </em>', 'section' => 'sec-contact', 'settings' => 'set-contact-description', 'type' => 'textarea' ) ); // button text contact customizer $wp_customize-> add_setting( 'set-contact-button-text', array( 'type' => 'theme_mod', 'default' => 'Get in Touch', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-contact-button-text', array( 'label' => 'Text', 'description' => 'please, type your text here.', 'section' => 'sec-contact', 'settings' => 'set-contact-button-text', 'type' => 'text' ) ); // button url customizer $wp_customize-> add_setting( 'set-contact-button-url', array( 'type' => 'theme_mod', 'default' => '#', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize-> add_control( 'ctrl-contact-button-url', array( 'label' => 'Url', 'description' => 'please, type your url here.', 'section' => 'sec-contact', 'settings' => 'set-contact-button-url', 'type' => 'url' ) ); /* ================================================== SERVICE SECTION ================================================== */ // service section $wp_customize-> add_section( 'sec-service', array( 'title' => 'Services', 'description' => 'You can setup service title and description here, but, to add and remove services items, you have to move to widgets section', 'panel' => 'home-page-customizer-panel' ) ); // service title customizer $wp_customize-> add_setting( 'set-service-title', array( 'type' => 'theme_mod', 'default' => 'OUR SERVICES', 'sanitize_callback' => 'buildx_sanitize_title_text' ) ); $wp_customize-> add_control( 'ctrl-service-title', array( 'label' => 'Title', 'description' => 'please, type your text.', 'section' => 'sec-service', 'settings' => 'set-service-title', 'type' => 'text' ) ); // service description customizer $wp_customize-> add_setting( 'set-service-description', array( 'type' => 'theme_mod', 'default' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-service-description', array( 'label' => 'Description', 'description' => 'please, type your description here.', 'section' => 'sec-service', 'settings' => 'set-service-description', 'type' => 'textarea' ) ); /* ================================================== ABOUT US SECTION ================================================== */ // about us image section $wp_customize-> add_section( 'sec-about-us', array( 'title' => 'About Us', 'description' => 'You can configure "About Us" here.', 'panel' => 'home-page-customizer-panel' ) ); $wp_customize-> add_setting( 'set-about-us-image', array( 'type' => 'theme_mod', 'default' => get_template_directory_uri() . '/assets/img/about-us.jpg', 'sanitize_callback' => 'buildx_sanitize_file' ) ); $wp_customize-> add_control( new WP_Customize_Upload_Control( $wp_customize, 'ctrl-about-us-image', array( 'label' => 'Header Image (Parallax)', 'description' => 'please, select an image.', 'section' => 'sec-about-us', 'settings' => 'set-about-us-image', ) ) ); // about us title customizer $wp_customize-> add_setting( 'set-about-us-title', array( 'type' => 'theme_mod', 'default' => 'WHY YOU CHOOSE US', 'sanitize_callback' => 'buildx_sanitize_title_text' ) ); $wp_customize-> add_control( 'ctrl-about-us-title', array( 'label' => 'Title', 'description' => 'please, type your title header here.', 'section' => 'sec-about-us', 'settings' => 'set-about-us-title', 'type' => 'text' ) ); // about us description customizer $wp_customize-> add_setting( 'set-about-us-description', array( 'type' => 'theme_mod', 'default' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-about-us-description', array( 'label' => 'Description', 'description' => 'please, type your desctiption header here.', 'section' => 'sec-about-us', 'settings' => 'set-about-us-description', 'type' => 'textarea' ) ); // shortcode accodion customizer $wp_customize-> add_setting( 'set-about-us-shortcode-id', array( 'type' => 'theme_mod', 'default' => '', 'sanitize_callback' => 'absint' ) ); $wp_customize-> add_control( 'ctrl-about-us-shortcode', array( 'label' => 'Button Text', 'description' => 'If you have made an Accordion content with plugin named "Accordions", please click here and write down the the ID ([accordions id="THIS_ID"]) below', 'section' => 'sec-about-us', 'settings' => 'set-about-us-shortcode-id', 'type' => 'text' ) ); /* ================================================== THE TEAM SECTION ================================================== */ // service section $wp_customize-> add_section( 'sec-the-team', array( 'title' => 'The Team', 'description' => 'You can setup the team title and description here, but, to "add and remove" the team members, you have to use Teams menu in your WordPress Dashboard', 'panel' => 'home-page-customizer-panel' ) ); // service title customizer $wp_customize-> add_setting( 'set-team-title', array( 'type' => 'theme_mod', 'default' => 'MET OUR TEAM', 'sanitize_callback' => 'buildx_sanitize_title_text' ) ); $wp_customize-> add_control( 'ctrl-team-title', array( 'label' => 'Title', 'description' => 'please, type your text.', 'section' => 'sec-the-team', 'settings' => 'set-team-title', 'type' => 'text' ) ); // service description customizer $wp_customize-> add_setting( 'set-team-description', array( 'type' => 'theme_mod', 'default' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-team-description', array( 'label' => 'Description', 'description' => 'please, type your description here.', 'section' => 'sec-the-team', 'settings' => 'set-team-description', 'type' => 'textarea' ) ); // the team shortcode $wp_customize-> add_setting( 'set-team-shortcode', array( 'type' => 'theme_mod', 'default' => '', 'sanitize_callback' => 'wp_kses_post' ) ); $wp_customize-> add_control( 'ctrl-team-id', array( 'label' => 'Smart Logo Shortcodes', 'description' => 'If you have made a Team with plugin named "Team Members", please click here and write down the Shortcodes below', 'section' => 'sec-the-team', 'settings' => 'set-team-shortcode', 'type' => 'textarea' ) ); /* ================================================== FEATURED WORKS SECTION ================================================== */ // Featured works section $wp_customize-> add_section( 'sec-work', array( 'title' => 'Featured Work', 'description' => 'You can setup featured work title, featured description and choose what categories you want to display on Featured Work', 'panel' => 'home-page-customizer-panel' ) ); // Featured works title customizer $wp_customize-> add_setting( 'set-work-title', array( 'type' => 'theme_mod', 'default' => 'FEATURED WORKS', 'sanitize_callback' => 'buildx_sanitize_title_text' ) ); $wp_customize-> add_control( 'ctrl-work-title', array( 'label' => 'Title', 'description' => 'please, type your text here.', 'section' => 'sec-work', 'settings' => 'set-work-title', 'type' => 'text' ) ); // Featured works description customizer $wp_customize-> add_setting( 'set-work-description', array( 'type' => 'theme_mod', 'default' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-work-description', array( 'label' => 'Description', 'description' => 'please, type your description here.', 'section' => 'sec-work', 'settings' => 'set-work-description', 'type' => 'textarea' ) ); //featured works select categories customizer $wp_customize-> add_setting( 'set-work-categories', array( 'type' => 'theme_mod', 'default' => '', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-work-select', array( 'label' => 'Categories', 'description' => 'please, copy your category slug here. Click Here to open Categories Dashboard -> click "quick edit" the category -> copy the slug and paste here. To use more than one category, please sparate with comma, exp. category-1,category-2,category-3', 'section' => 'sec-work', 'settings' => 'set-work-categories', 'type' => 'textarea' ) ); /* ================================================== TESTIMONIAL SECTION ================================================== */ // testimonial section $wp_customize-> add_section( 'sec-testimonial', array( 'title' => 'Testimonial', 'description' => 'You can setup testimonial title and description here, but, to "add and remove" custumer\'s testimonial, you have to use Testimonial menu in your WordPress Dashboard', 'panel' => 'home-page-customizer-panel' ) ); // testimonial title customizer $wp_customize-> add_setting( 'set-testimonial-title', array( 'type' => 'theme_mod', 'default' => 'CUSTOMER FEEDBACK', 'sanitize_callback' => 'buildx_sanitize_title_text' ) ); $wp_customize-> add_control( 'ctrl-testimonial-title', array( 'label' => 'Title', 'description' => 'please, type your text.', 'section' => 'sec-testimonial', 'settings' => 'set-testimonial-title', 'type' => 'text' ) ); // testimonial description customizer $wp_customize-> add_setting( 'set-testimonial-description', array( 'type' => 'theme_mod', 'default' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-testimonial-description', array( 'label' => 'Description', 'description' => 'please, type your description here.', 'section' => 'sec-testimonial', 'settings' => 'set-testimonial-description', 'type' => 'textarea' ) ); // testimonial id $wp_customize-> add_setting( 'set-testimonial-id', array( 'type' => 'theme_mod', 'default' => '', 'sanitize_callback' => 'absint' ) ); $wp_customize-> add_control( 'ctrl-testimonial-id', array( 'label' => 'Strong Testimonials ID', 'description' => 'If you have made a testimonial\'s view with plugin named "Strong Testimonials", please click here and write down the ID below', 'section' => 'sec-testimonial', 'settings' => 'set-testimonial-id', 'type' => 'text' ) ); // smart logo shortcode $wp_customize-> add_setting( 'set-client-shortcode', array( 'type' => 'theme_mod', 'default' => '', 'sanitize_callback' => 'wp_kses_post' ) ); $wp_customize-> add_control( 'ctrl-client-id', array( 'label' => 'Smart Logo Shortcodes', 'description' => 'If you have made a Smart Logo with plugin named "Smart Logo Showcase Lite", please click here and write down the Shortcodes below', 'section' => 'sec-testimonial', 'settings' => 'set-client-shortcode', 'type' => 'textarea' ) ); /* ================================================== FEATURED NEWS SECTION ================================================== */ // Featured news section $wp_customize-> add_section( 'sec-news', array( 'title' => 'Featured News', 'description' => 'You can setup featured news title, featured description and choose what categories you want to display on Featured news', 'panel' => 'home-page-customizer-panel' ) ); // Featured news title customizer $wp_customize-> add_setting( 'set-news-title', array( 'type' => 'theme_mod', 'default' => 'FEATURED NEWS', 'sanitize_callback' => 'buildx_sanitize_title_text' ) ); $wp_customize-> add_control( 'ctrl-news-title', array( 'label' => 'Title', 'description' => 'please, type your text.', 'section' => 'sec-news', 'settings' => 'set-news-title', 'type' => 'text' ) ); // Featured news description customizer $wp_customize-> add_setting( 'set-news-description', array( 'type' => 'theme_mod', 'default' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-news-description', array( 'label' => 'Description', 'description' => 'please, type your description here.', 'section' => 'sec-news', 'settings' => 'set-news-description', 'type' => 'textarea' ) ); //featured news select categories customizer $wp_customize-> add_setting( 'set-news-categories', array( 'type' => 'theme_mod', 'default' => '', 'sanitize_callback' => 'esc_attr' ) ); $wp_customize-> add_control( 'ctrl-news-categories', array( 'label' => 'Categories', 'description' => 'please, copy your category slug. Click Here to open WordPress Dashboard Categories -> click "quick edit" the category -> copy the slug and paste here. To use more than one category, please sparate with comma, exp. category1,category2,category3', 'section' => 'sec-news', 'settings' => 'set-news-categories', 'type' => 'textarea' ) ); } add_action( 'customize_register', 'buildx_customizer' );