add_setting( 'blog_stream_banner_content_type', array( 'default' => 'post', 'sanitize_callback' => 'nice_blog_sanitize_select', ) ); $wp_customize->add_control( 'blog_stream_banner_content_type', array( 'label' => esc_html__( 'Content type:', 'blog-stream' ), 'description' => esc_html__( 'Choose where you want to render the content from.', 'blog-stream' ), 'section' => 'nice_blog_banner_section', 'type' => 'select', 'active_callback' => 'nice_blog_if_banner_enabled', 'choices' => array( 'post' => esc_html__( 'Post', 'blog-stream' ), 'category' => esc_html__( 'Category', 'blog-stream' ), ), 'priority' => 50, ) ); for ( $i = 1; $i <= 3; $i++ ) { // Banner post setting. $wp_customize->add_setting( 'blog_stream_banner_post_' . $i, array( 'sanitize_callback' => 'nice_blog_sanitize_dropdown_pages', ) ); $wp_customize->add_control( 'blog_stream_banner_post_' . $i, array( 'label' => sprintf( esc_html__( 'Post %d', 'blog-stream' ), $i ), 'section' => 'nice_blog_banner_section', 'type' => 'select', 'choices' => nice_blog_get_post_choices(), 'active_callback' => 'blog_stream_banner_section_content_type_post_enabled', 'priority' => 60, ) ); } // Banner category setting. $wp_customize->add_setting( 'blog_stream_banner_category', array( 'sanitize_callback' => 'nice_blog_sanitize_select', ) ); $wp_customize->add_control( 'blog_stream_banner_category', array( 'label' => esc_html__( 'Category', 'blog-stream' ), 'section' => 'nice_blog_banner_section', 'type' => 'select', 'choices' => nice_blog_get_post_cat_choices(), 'active_callback' => 'blog_stream_banner_section_content_type_category_enabled', 'priority' => 70, ) ); /*========================Active Callback==============================*/ function blog_stream_banner_section_content_type_post_enabled( $control ) { $content_type = $control->manager->get_setting( 'blog_stream_banner_content_type' )->value(); return nice_blog_if_banner_enabled( $control ) && ( 'post' === $content_type ); } function blog_stream_banner_section_content_type_category_enabled( $control ) { $content_type = $control->manager->get_setting( 'blog_stream_banner_content_type' )->value(); return nice_blog_if_banner_enabled( $control ) && ( 'category' === $content_type ); }