esc_html__('Show', 'hostby'), 'hide' => esc_html__('Hide', 'hostby') ); return apply_filters('hostby_section_choice_option', $hostby_section_choice_option); } endif; /** * Sanitizing the select callback example * */ if ( !function_exists('hostby_sanitize_select') ) : function hostby_sanitize_select( $input, $setting ) { // Ensure input is a slug. $input = sanitize_text_field( $input ); // Get list of choices from the control associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } endif; /** * Drop-down Pages sanitization callback example. * * - Sanitization: dropdown-pages * - Control: dropdown-pages * * Sanitization callback for 'dropdown-pages' type controls. This callback sanitizes `$page_id` * as an absolute integer, and then validates that $input is the ID of a published page. * * @see absint() https://developer.wordpress.org/reference/functions/absint/ * @see get_post_status() https://developer.wordpress.org/reference/functions/get_post_status/ * * @param int $page Page ID. * @param WP_Customize_Setting $setting Setting instance. * @return int|string Page ID if the page is published; otherwise, the setting default. */ function hostby_sanitize_dropdown_pages( $page_id, $setting ) { // Ensure $input is an absolute integer. $page_id = absint( $page_id ); // If $page_id is an ID of a published page, return it; otherwise, return the default. return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default ); } /** Front Page Section Settings starts **/ $wp_customize->add_panel('frontpage', array( 'title' => esc_html__('hostby Options', 'hostby'), 'description' => '', 'priority' => 3, ) ); // Header info $wp_customize->add_section('hostby_header_section', array( 'title' => esc_html__('Top Header Info Section', 'hostby'), 'description' => '', 'panel' => 'frontpage', 'priority' => 130 ) ); $wp_customize->add_setting('hostby_header_phone_value', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('hostby_header_phone_value', array( 'label' => esc_html__('Contact Number', 'hostby'), 'section' => 'hostby_header_section', 'priority' => 3 ) ); $wp_customize->add_setting('hostby_header_social_link_1', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control('hostby_header_social_link_1', array( 'label' => esc_html__('Facebook URL', 'hostby'), 'section' => 'hostby_header_section', 'priority' => 7 ) ); $wp_customize->add_setting('hostby_header_social_link_2', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control('hostby_header_social_link_2', array( 'label' => esc_html__('Twitter URL', 'hostby'), 'section' => 'hostby_header_section', 'priority' => 9 ) ); $wp_customize->add_setting('hostby_header_social_link_3', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control('hostby_header_social_link_3', array( 'label' => esc_html__('Linkedin URL', 'hostby'), 'section' => 'hostby_header_section', 'priority' => 11 ) ); $wp_customize->add_setting('hostby_header_social_link_4', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control('hostby_header_social_link_4', array( 'label' => esc_html__('Instagram URL', 'hostby'), 'section' => 'hostby_header_section', 'priority' => 11 ) ); /** Slider Section Settings starts **/ // Panel - Slider Section 1 $wp_customize->add_section('sliderinfo', array( 'title' => esc_html__('Home Slider Section', 'hostby'), 'description' => '', 'panel' => 'frontpage', 'priority' => 140 ) ); $slider_no = 3; for( $i = 1; $i <= $slider_no; $i++ ) { $hostby_slider_page = 'hostby_slider_page_' .$i; $hostby_slider_btntxt = 'hostby_slider_btntxt_' . $i; $hostby_slider_btnurl = 'hostby_slider_btnurl_' .$i; $wp_customize->add_setting( $hostby_slider_page, array( 'default' => 1, 'sanitize_callback' => 'hostby_sanitize_dropdown_pages', ) ); $wp_customize->add_control( $hostby_slider_page, array( 'label' => esc_html__( 'Slider Page ', 'hostby' ) .$i, 'section' => 'sliderinfo', 'type' => 'dropdown-pages', 'priority' => 100, ) ); $wp_customize->add_setting( $hostby_slider_btntxt, array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( $hostby_slider_btntxt, array( 'label' => esc_html__( 'Slider Button Text','hostby' ), 'section' => 'sliderinfo', 'type' => 'text', 'priority' => 100, ) ); $wp_customize->add_setting( $hostby_slider_btnurl, array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( $hostby_slider_btnurl, array( 'label' => esc_html__( 'Button URL', 'hostby' ), 'section' => 'sliderinfo', 'type' => 'text', 'priority' => 100, ) ); } /** Slider Section Settings end **/ // Services section $wp_customize->add_section('services', array( 'title' => esc_html__('Home service Section', 'hostby'), 'description' => '', 'panel' => 'frontpage', 'priority' => 150, ) ); $wp_customize->add_setting('hostby_services_section_hideshow', array( 'default' => 'hide', 'sanitize_callback' => 'hostby_sanitize_select', ) ); $hostby_services_section_hide_show_option = hostby_section_choice_option(); $wp_customize->add_control('hostby_services_section_hideshow', array( 'type' => 'radio', 'label' => esc_html__('Services Option', 'hostby'), 'description' => esc_html__('Show/hide option Section.', 'hostby'), 'section' => 'services', 'choices' => $hostby_services_section_hide_show_option, 'priority' => 1 ) ); // services title $wp_customize->add_setting('hostby-services_title', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('hostby-services_title', array( 'label' => esc_html__('Service Section Title', 'hostby'), 'section' => 'services', 'priority' => 3 ) ); $wp_customize->add_setting( 'hostby-services_subtitle', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control( 'hostby-services_subtitle', array( 'label' => esc_html__('Service Section Subtitle', 'hostby'), 'section' => 'services', 'priority' => 4 ) ); $services_no = 6; for( $i = 1; $i <= $services_no; $i++ ) { $hostby_servicespage = 'hostby_services_page_' . $i; $wp_customize->add_setting( $hostby_servicespage, array( 'default' => 1, 'sanitize_callback' => 'hostby_sanitize_dropdown_pages', ) ); $wp_customize->add_control( $hostby_servicespage, array( 'label' => esc_html__( 'Services Page ', 'hostby' ) .$i, 'section' => 'services', 'type' => 'dropdown-pages', 'priority' => 100, ) ); } // Projects section $wp_customize->add_section('projects', array( 'title' => esc_html__('Project Section', 'hostby'), 'description' => '', 'panel' => 'frontpage', 'priority' => 160, ) ); $wp_customize->add_setting('hostby_projects_section_hideshow', array( 'default' => 'hide', 'sanitize_callback' => 'hostby_sanitize_select', ) ); $hostby_projects_section_hide_show_option = hostby_section_choice_option(); $wp_customize->add_control('hostby_projects_section_hideshow', array( 'type' => 'radio', 'label' => esc_html__('Projects Option', 'hostby'), 'description' => esc_html__('Show/hide option Section.', 'hostby'), 'section' => 'projects', 'choices' => $hostby_projects_section_hide_show_option, 'priority' => 1 ) ); // projects title $wp_customize->add_setting('hostby-projects_title', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('hostby-projects_title', array( 'label' => esc_html__('Projects Section Title', 'hostby'), 'section' => 'projects', 'priority' => 3 ) ); $projects_no = 6; for( $i = 1; $i <= $projects_no; $i++ ) { $hostby_projectspage = 'hostby_projects_page_' . $i; $wp_customize->add_setting( $hostby_projectspage, array( 'default' => 1, 'sanitize_callback' => 'hostby_sanitize_dropdown_pages', ) ); $wp_customize->add_control( $hostby_projectspage, array( 'label' => esc_html__( 'Projects Page ', 'hostby' ) .$i, 'section' => 'projects', 'type' => 'dropdown-pages', 'priority' => 100, ) ); } // Blog section $wp_customize->add_section('hostby-blog_info', array( 'title' => esc_html__('Home Blog Section', 'hostby'), 'description' => '', 'panel' => 'frontpage', 'priority' => 170 ) ); $wp_customize->add_setting('hostby_blog_section_hideshow', array( 'default' => 'show', 'sanitize_callback' => 'hostby_sanitize_select', ) ); $hostby_blog_section_hide_show_option = hostby_section_choice_option(); $wp_customize->add_control('hostby_blog_section_hideshow', array( 'type' => 'radio', 'label' => esc_html__('Blog Option', 'hostby'), 'description' => esc_html__('Show/hide option for Blog Section.', 'hostby'), 'section' => 'hostby-blog_info', 'choices' => $hostby_blog_section_hide_show_option, 'priority' => 1 ) ); $wp_customize->add_setting('hostby_blog_title', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('hostby_blog_title', array( 'label' => esc_html__('Blog Title', 'hostby'), 'section' => 'hostby-blog_info', 'priority' => 1 ) ); // clients logo info $wp_customize->add_section( 'clients_logo', array( 'title' => esc_html__('Clients logo Section', 'hostby'), 'description' => '', 'panel' => 'frontpage', 'priority' => 170 ) ); $wp_customize->add_setting( 'hostby_clients_section_hideshow', array( 'default' => 'hide', 'sanitize_callback' => 'hostby_sanitize_select', ) ); $hostby_section_choice_option = hostby_section_choice_option(); $wp_customize->add_control( 'hostby_clients_section_hideshow', array( 'type' => 'radio', 'label' => esc_html__('Clients-logo', 'hostby'), 'description' => esc_html__('Show/hide option for Clients-logo Section.', 'hostby'), 'section' => 'clients_logo', 'choices' => $hostby_section_choice_option, 'priority' => 5 ) ); $client_no = 6; for( $i = 1; $i <= $client_no; $i++ ) { $hostby_client_logo = 'hostby_client_logo_' . $i; $wp_customize->add_setting( $hostby_client_logo, array( 'default' => 1, 'sanitize_callback' => 'hostby_sanitize_dropdown_pages', ) ); $wp_customize->add_control( $hostby_client_logo, array( 'label' => esc_html__( 'Client Page ', 'hostby' ) .$i, 'section' => 'clients_logo', 'type' => 'dropdown-pages', 'priority' => 100, ) ); } //callout $wp_customize->add_section('hostby_footer_contact', array( 'title' => esc_html__('Callout Section', 'hostby'), 'description' => '', 'panel' => 'frontpage', 'priority' => 170 ) ); $wp_customize->add_setting('hostby_contact_section_hideshow', array( 'default' => 'hide', 'sanitize_callback' => 'hostby_sanitize_select', ) ); $hostby_contact_s_hideshow = hostby_section_choice_option(); $wp_customize->add_control('hostby_contact_section_hideshow', array( 'type' => 'radio', 'label' => esc_html__('Footer Callout', 'hostby'), 'description' => esc_html__('Show/hide option for Footer Callout Section.', 'hostby'), 'section' => 'hostby_footer_contact', 'choices' => $hostby_contact_s_hideshow, 'priority' => 5 ) ); $wp_customize->add_setting('ctah_heading', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('ctah_heading', array( 'label' => esc_html__('Callout Text', 'hostby'), 'section' => 'hostby_footer_contact', 'priority' => 8 ) ); $wp_customize->add_setting('ctah_btn_url', array( 'default' =>'', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw' ) ); $wp_customize->add_control('ctah_btn_url', array( 'label' => esc_html__('Button URL', 'hostby'), 'section' => 'hostby_footer_contact', 'priority' => 10 ) ); $wp_customize->add_setting('ctah_btn_text', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('ctah_btn_text', array( 'label' => esc_html__('Button Text', 'hostby'), 'section' => 'hostby_footer_contact', 'priority' => 12 ) ); // Footer Section $wp_customize->add_section('hostby-footer_info', array( 'title' => esc_html__('Footer Section', 'hostby'), 'description' => '', 'panel' => 'frontpage', 'priority' => 170 ) ); $wp_customize->add_setting('hostby_footer_section_hideshow', array( 'default' => 'show', 'sanitize_callback' => 'hostby_sanitize_select', ) ); $hostby_footer_section_hide_show_option = hostby_section_choice_option(); $wp_customize->add_control('hostby_footer_section_hideshow', array( 'type' => 'radio', 'label' => esc_html__('Footer Option', 'hostby'), 'description' => esc_html__('Show/hide option for Footer Section.', 'hostby'), 'section' => 'hostby-footer_info', 'choices' => $hostby_footer_section_hide_show_option, 'priority' => 1 ) ); $wp_customize->add_setting('hostby-footer_title', array( 'default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'wp_kses_post' ) ); $wp_customize->add_control('hostby-footer_title', array( 'label' => esc_html__('Copyright', 'hostby'), 'section' => 'hostby-footer_info', 'type' => 'textarea', 'priority' => 1 ) ); /** Front Page Section Settings end **/ } add_action( 'customize_register', 'hostby_customize_register' );