Support » Plugin: Widget Options » Use filter ‘widget_options_logic_override’ to create logic?

  • wzshop

    (@wzshop)


    Hi,
    Is there anyone who used the widget_options_logic_override filter in order to create widget logic? Is there some documentation on this?
    I’ve found the filter in includes/widgets/display.php and trying to do something with the function below (just for testing), but nothing happening:

    function cc_widget_logic( $display_logic ) {
    print_r ($display_logic); 
    }
    add_filter( 'widget_options_logic_override', 'cc_widget_logic', 10, 1 );

    Anyone? Thanks!

    • This topic was modified 9 months ago by  wzshop.
Viewing 1 replies (of 1 total)
  • wzshop

    (@wzshop)

    Hi,
    Ok I figured out that the widget logic has to be filled with something. Setting a ‘-‘ into the logic tab allowed me to use the filter mentioned above. Now I am not that much of an expert to know 100% certain what I am doing, but the code below seems to be working. Can anyone peerview this code? I want to show a widget with ‘-‘ logic on single pages that have a certain term, and hide it on other pages.

    function cc_widget_logic( $display_logic ) {
    	if (is_single() && has_term( 'test', 'listing_category' )) {
    		//Show widget with logic
    		$display_logic .= true;
    	} else {
    		//Hide widget with logic
    		$display_logic = false;
    	}
    return $display_logic;
    }
    add_filter( 'widget_options_logic_override', 'cc_widget_logic', 30, 1 );
Viewing 1 replies (of 1 total)
  • The topic ‘Use filter ‘widget_options_logic_override’ to create logic?’ is closed to new replies.