add_section( 'aster_vlogger_service_section', array( 'panel' => 'aster_vlogger_front_page_options', 'title' => esc_html__( 'Popular Video Section', 'aster-vlogger' ), 'priority' => 10, ) ); // Service Section - Enable Section. $wp_customize->add_setting( 'aster_vlogger_enable_service_section', array( 'default' => false, 'sanitize_callback' => 'aster_vlogger_sanitize_switch', ) ); $wp_customize->add_control( new Aster_Vlogger_Toggle_Switch_Custom_Control( $wp_customize, 'aster_vlogger_enable_service_section', array( 'label' => esc_html__( 'Enable Popular Video Section', 'aster-vlogger' ), 'section' => 'aster_vlogger_service_section', 'settings' => 'aster_vlogger_enable_service_section', ) ) ); if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'aster_vlogger_enable_service_section', array( 'selector' => '#aster_vlogger_service_section .section-link', 'settings' => 'aster_vlogger_enable_service_section', ) ); } // Popular Video Section - Title. $wp_customize->add_setting( 'aster_vlogger_video_section_title', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'aster_vlogger_video_section_title', array( 'label' => esc_html__( 'Section Title', 'aster-vlogger' ), 'section' => 'aster_vlogger_service_section', 'settings' => 'aster_vlogger_video_section_title', 'type' => 'text', 'active_callback' => 'aster_vlogger_is_service_section_enabled', ) ); // Popular Video Section - Text. $wp_customize->add_setting( 'aster_vlogger_video_section_text', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'aster_vlogger_video_section_text', array( 'label' => esc_html__( 'Section Text', 'aster-vlogger' ), 'section' => 'aster_vlogger_service_section', 'settings' => 'aster_vlogger_video_section_text', 'type' => 'text', 'active_callback' => 'aster_vlogger_is_service_section_enabled', ) ); // Popular Video Section - Content Type. $wp_customize->add_setting( 'aster_vlogger_service_content_type', array( 'default' => 'post', 'sanitize_callback' => 'aster_vlogger_sanitize_select', ) ); $wp_customize->add_control( 'aster_vlogger_service_content_type', array( 'label' => esc_html__( 'Select Content Type', 'aster-vlogger' ), 'section' => 'aster_vlogger_service_section', 'settings' => 'aster_vlogger_service_content_type', 'type' => 'select', 'active_callback' => 'aster_vlogger_is_service_section_enabled', 'choices' => array( 'page' => esc_html__( 'Page', 'aster-vlogger' ), 'post' => esc_html__( 'Post', 'aster-vlogger' ), ), ) ); // Services Category Setting. $wp_customize->add_setting('aster_vlogger_services_category', array( 'default' => 'services', 'sanitize_callback' => 'sanitize_text_field', )); // Add custom control for Services Category with conditional visibility. $wp_customize->add_control(new Aster_Vlogger_Customize_Category_Dropdown_Control($wp_customize, 'aster_vlogger_services_category', array( 'label' => __('Select Services Category', 'aster-vlogger'), 'section' => 'aster_vlogger_service_section', 'settings' => 'aster_vlogger_services_category', 'active_callback' => function() use ($wp_customize) { return $wp_customize->get_setting('aster_vlogger_service_content_type')->value() === 'post'; }, ))); for ( $aster_vlogger_i = 1; $aster_vlogger_i <= 3; $aster_vlogger_i++ ) { // Service Section - Select Post. $wp_customize->add_setting( 'aster_vlogger_service_content_post_' . $aster_vlogger_i, array( 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'aster_vlogger_service_content_post_' . $aster_vlogger_i, array( 'label' => esc_html__( 'Select Post ', 'aster-vlogger' ) . $aster_vlogger_i, 'description' => sprintf( esc_html__( 'Kindly :- Select a Post based on the category selected in the upper settings', 'aster-vlogger' ), $aster_vlogger_i ), 'section' => 'aster_vlogger_service_section', 'settings' => 'aster_vlogger_service_content_post_' . $aster_vlogger_i, 'active_callback' => 'aster_vlogger_is_service_section_and_content_type_post_enabled', 'type' => 'select', 'choices' => aster_vlogger_get_post_choices(), ) ); // Service Section - Select Page. $wp_customize->add_setting( 'aster_vlogger_service_content_page_' . $aster_vlogger_i, array( 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'aster_vlogger_service_content_page_' . $aster_vlogger_i, array( 'label' => esc_html__( 'Select Page ', 'aster-vlogger' ) . $aster_vlogger_i, 'section' => 'aster_vlogger_service_section', 'settings' => 'aster_vlogger_service_content_page_' . $aster_vlogger_i, 'active_callback' => 'aster_vlogger_is_service_section_and_content_type_page_enabled', 'type' => 'select', 'choices' => aster_vlogger_get_page_choices(), ) ); }