Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey there Insomnia88,

    Hope you’re well today!

    I’ve had to check this with the plugin developer, please try adding the following:

    <?php
    add_action( 'wp', 'my_function' );
    
    function my_function() {
    	if ( using_custom_sidebar( 'cs-1' ) ) {
    		wp_die( 'Amazing, we\'ve got CS-1 on the page!' );
    	}
    }
    
    // Function checks if the current page uses the custom sidebar
    function using_custom_sidebar( $looking_for ) {
    	if ( ! did_action( 'wp' ) ) {
    		wp_die( 'too early!' );
    	}
    
    	$cs = CustomSidebarsReplacer::instance();
    	$defaults = CustomSidebars::get_options();
    	$replacements = $cs->determine_replacements( $defaults );
    
    	// Check all theme sidebars to see if any one uses the specified replacement
    	foreach ( $replacements as $key => $data ) {
    		if ( is_array( $data ) && $data[0] == $looking_for ) {
    			return true;
    		}
    	}
    
    	return false;
    }

    With this you’ll be able to check if specific sidebar has been used. Replace 1 in “cs-1” with the the id of your sidebar.

    Hope this helps ??

    Cheers,
    Bojan

    Thread Starter Insomnia88

    (@insomnia88)

    This code looks good on the firs sight but I have to tell you that I switched to another plugin because I had time pressure so I cannot test it ?? I still switch the status to resolved.

    Hey again Insomnia88,

    Sorry to hear you’ve decided to switch to another plugin. Please let us know if you decide to use custom sidebars and if you have additional questions ??

    Have a great day!

    Cheers,
    Bojan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to check for custom sidebar?’ is closed to new replies.