add_section( 'blogmag_recent', array( 'title' => esc_html__( 'Recent', 'blogmag' ), 'panel' => 'blogoholic_home_panel', ) ); // recent enable settings $wp_customize->add_setting( 'blogmag_recent', array( 'sanitize_callback' => 'blogoholic_sanitize_select', 'default' => 'disable' ) ); $wp_customize->add_control( 'blogmag_recent', array( 'section' => 'blogmag_recent', 'label' => esc_html__( 'Content type:', 'blogmag' ), 'description' => esc_html__( 'Choose where you want to render the content from.', 'blogmag' ), 'type' => 'select', 'choices' => array( 'disable' => esc_html__( '--Disable--', 'blogmag' ), 'post' => esc_html__( 'Post', 'blogmag' ), ) ) ); $wp_customize->add_setting( 'blogmag_recent_title', array( 'sanitize_callback' => 'sanitize_text_field', 'default' => esc_html__( 'Recent Posts', 'blogmag' ), ) ); $wp_customize->add_control( 'blogmag_recent_title', array( 'section' => 'blogmag_recent', 'label' => esc_html__( 'Title:', 'blogmag' ), 'active_callback' => 'blogmag_if_recent_enabled' ) ); $recent_num = 3; for ($i=1; $i <= $recent_num ; $i++) { // recent post setting $wp_customize->add_setting( 'blogmag_recent_post_'.$i, array( 'sanitize_callback' => 'blogoholic_sanitize_dropdown_pages', ) ); $wp_customize->add_control( 'blogmag_recent_post_'.$i, array( 'section' => 'blogmag_recent', 'label' => esc_html__( 'Post ', 'blogmag' ).$i, 'type' => 'select', 'choices' => blogoholic_get_post_choices(), 'active_callback' => 'blogmag_if_recent_enabled' ) ); }