add_section( 'auto_mechanic_services_section', array( 'panel' => 'auto_mechanic_front_page_options', 'title' => esc_html__( 'Car Services Section', 'auto-mechanic' ), 'priority' => 10, ) ); // Services Section - Enable Section. $wp_customize->add_setting( 'auto_mechanic_enable_services_section', array( 'default' => false, 'sanitize_callback' => 'auto_mechanic_sanitize_switch', ) ); $wp_customize->add_control( new Auto_Mechanic_Toggle_Switch_Custom_Control( $wp_customize, 'auto_mechanic_enable_services_section', array( 'label' => esc_html__( 'Enable Services Section', 'auto-mechanic' ), 'section' => 'auto_mechanic_services_section', 'settings' => 'auto_mechanic_enable_services_section', ) ) ); if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'auto_mechanic_enable_services_section', array( 'selector' => '#auto_mechanic_menus_section .section-link', 'settings' => 'auto_mechanic_enable_services_section', ) ); } // Car Services Section $wp_customize->add_setting( 'auto_mechanic_heading_services_section', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'auto_mechanic_heading_services_section', array( 'label' => esc_html__( 'Heading', 'auto-mechanic' ), 'section' => 'auto_mechanic_services_section', 'settings' => 'auto_mechanic_heading_services_section', 'type' => 'text', 'active_callback' => 'auto_mechanic_is_services_section_enabled', ) ); $wp_customize->add_setting( 'auto_mechanic_services_number', array( 'default'=> '', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_control( 'auto_mechanic_services_number', array( 'label' => esc_html__('No of Tabs to show','auto-mechanic'), 'section'=> 'auto_mechanic_services_section', 'type' => 'number', 'input_attrs' => array( 'step' => 1, 'min' => 0, 'max' => 4, ), 'active_callback' => 'auto_mechanic_is_services_section_enabled', ) ); $auto_mechanic_featured_post = get_theme_mod('auto_mechanic_services_number'); for ( $auto_mechanic_j = 1; $auto_mechanic_j <= $auto_mechanic_featured_post; $auto_mechanic_j++ ) { $wp_customize->add_setting( 'auto_mechanic_services_text' . $auto_mechanic_j, array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'auto_mechanic_services_text' . $auto_mechanic_j, array( 'label' => esc_html__('Tab ', 'auto-mechanic') . $auto_mechanic_j, 'section' => 'auto_mechanic_services_section', 'type' => 'text', 'active_callback' => 'auto_mechanic_is_services_section_enabled', ) ); $auto_mechanic_categories = get_categories(); $auto_mechanic_cat_posts = array(); $auto_mechanic_i = 0; $auto_mechanic_cat_posts[]='Select'; foreach($auto_mechanic_categories as $auto_mechanic_category){ if($auto_mechanic_i==0){ $auto_mechanic_default = $auto_mechanic_category->slug; $auto_mechanic_i++; } $auto_mechanic_cat_posts[$auto_mechanic_category->slug] = $auto_mechanic_category->name; } $wp_customize->add_setting( 'auto_mechanic_services_category'.$auto_mechanic_j, array( 'default' => 'services', 'sanitize_callback' => 'auto_mechanic_sanitize_choices', ) ); $wp_customize->add_control( 'auto_mechanic_services_category'.$auto_mechanic_j, array( 'type' => 'select', 'choices' => $auto_mechanic_cat_posts, 'label' => __('Select Category to display Services','auto-mechanic'), 'section' => 'auto_mechanic_services_section', 'active_callback' => 'auto_mechanic_is_services_section_enabled', ) ); }