I have two custom widgets a Search_Widget_Page which is created with the following code;
class Search_Widget_Page extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
'Search_Widget_Page',
__('Search Form - Pages', 'text_domain'),
array( 'description' => __( 'Add a search form to a page, there must not be another search form in the side bar.', 'text_domain' ), ) // Args
);
}
I then have another similar widget that can display in the sidebar, however, I do no want it to display if the widget above is being used on the page. I have tried the following code to no avail;
public function widget( $args, $instance ) {
if( is_active_widget( 'Search_Widget_Page' ) ) { // check if search widget is used
Do not display this widget
} else {
Display this widget
}