add_setting( 'actual_news_grid_posts_sub_heading', array( 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( new Actual_News_Sub_Section_Heading_Custom_Control( $wp_customize, 'actual_news_grid_posts_sub_heading', array( 'label' => esc_html__( 'Banner Grid Posts Section', 'actual-news' ), 'settings' => 'actual_news_grid_posts_sub_heading', 'section' => 'news_articles_banner_section', 'active_callback' => 'news_articles_if_banner_enabled', 'priority' => 12, ) ) ); // Grid content type settings. $wp_customize->add_setting( 'actual_news_grid_posts_content_type', array( 'default' => 'post', 'sanitize_callback' => 'news_articles_sanitize_select', ) ); $wp_customize->add_control( 'actual_news_grid_posts_content_type', array( 'label' => esc_html__( 'Grid Posts Content type:', 'actual-news' ), 'description' => esc_html__( 'Choose where you want to render the content from.', 'actual-news' ), 'section' => 'news_articles_banner_section', 'settings' => 'actual_news_grid_posts_content_type', 'type' => 'select', 'active_callback' => 'news_articles_if_banner_enabled', 'priority' => 14, 'choices' => array( 'post' => esc_html__( 'Post', 'actual-news' ), 'category' => esc_html__( 'Category', 'actual-news' ), ), ) ); for ( $actual_news_i = 1; $actual_news_i <= 3; $actual_news_i++ ) { // Grid Posts post setting. $wp_customize->add_setting( 'actual_news_grid_posts_post_' . $actual_news_i, array( 'sanitize_callback' => 'news_articles_sanitize_dropdown_pages', ) ); $wp_customize->add_control( 'actual_news_grid_posts_post_' . $actual_news_i, array( 'label' => sprintf( esc_html__( 'Post %d', 'actual-news' ), $actual_news_i ), 'section' => 'news_articles_banner_section', 'type' => 'select', 'choices' => news_articles_get_post_choices(), 'active_callback' => 'actual_news_grid_posts_section_content_type_post_enabled', 'priority' => 16, ) ); } // Featured Posts category setting. $wp_customize->add_setting( 'actual_news_grid_posts_category', array( 'sanitize_callback' => 'news_articles_sanitize_select', ) ); $wp_customize->add_control( 'actual_news_grid_posts_category', array( 'label' => esc_html__( 'Category', 'actual-news' ), 'section' => 'news_articles_banner_section', 'type' => 'select', 'choices' => news_articles_get_post_cat_choices(), 'active_callback' => 'actual_news_grid_posts_section_content_type_category_enabled', 'priority' => 18, ) ); // Latest News Tab Enable. $wp_customize->add_setting( 'actual_news_latest_news_tab_enable', array( 'default' => true, 'sanitize_callback' => 'news_articles_sanitize_checkbox', ) ); $wp_customize->add_control( new Actual_News_Toggle_Checkbox_Custom_control( $wp_customize, 'actual_news_latest_news_tab_enable', array( 'label' => esc_html__( 'Enable Latest News Tab', 'actual-news' ), 'type' => 'checkbox', 'settings' => 'actual_news_latest_news_tab_enable', 'section' => 'news_articles_banner_section', 'active_callback' => 'news_articles_if_banner_enabled', 'priority' => 65, ) ) ); /*========================Active Callback==============================*/ // banner grid posts. function actual_news_grid_posts_section_content_type_post_enabled( $control ) { $content_type = $control->manager->get_setting( 'actual_news_grid_posts_content_type' )->value(); return news_articles_if_banner_enabled( $control ) && ( 'post' === $content_type ); } function actual_news_grid_posts_section_content_type_category_enabled( $control ) { $content_type = $control->manager->get_setting( 'actual_news_grid_posts_content_type' )->value(); return news_articles_if_banner_enabled( $control ) && ( 'category' === $content_type ); }