WordPress Customizer: How can you have multiple active callbacks on one control?

You can create a third active callback function that just references the two existing ones, for example via an anonymous function (PHP≥5.3):

// About Block Button Text
$wp_customize->add_setting( 'about_block_button_text', array(
    'default'           => __( 'Read More', 'my_theme_name' )
) );    
$wp_customize->add_control( 'about_block_button_text', array(
    'label'             => __( 'About Button Text', 'my_theme_name' ),
    'type'              => 'text',
    'section'           => 'about',
    'active_callback'   => function( $control ) {
        return ( 
            display_about_block_button_callback( $control )
            &&
            display_about_block_callback( $control )
        );
    },
) );

Leave a Comment