For example if there is a Customizer section that focuses on Woocommerce options, I’d like the user to be on the shop page for that, to see all these changes, live.

I can do http://127.0.0.1/wp-admin/customize.php?url=http://127.0.0.1/shop&autofocus[section]=woocommerce as a link in the admin panel, which will put customizer on that URL, with the relevant section open, but that’s not ideal.

I would like the customizer to automatically navigate to the specified url when the user clicks on any section.

Is there any way to have onSectionClick event and then set previewUrl to something?

1
1

You could use active_callback property to delegate section visibility depending on current preview screen.

$wp_customize->add_section( 'my-section',
array(
    'title' => __( 'Section Title' ),
    'active_callback' => 'is_shop',
) );

Or custom

$wp_customize->add_section( 'my-section',
array(
    'title' => __( 'Section Title' ),
    'active_callback' => 'is_custom_condition',
) );
function is_custom_condition(){
    $condition_is_met = //Some boolean returning logic;
    if( ! $condition_is_met ){
         return false;
    }
    return true;
}

Leave a Reply

Your email address will not be published. Required fields are marked *