Skip to content

Custom display_on

Pablo dos Santos Gonçalves Pacheco edited this page Jul 4, 2018 · 7 revisions

If the current display_on options aren't enough for you, you can setup custom triggers where/when the notice should be displayed.

In order to do that you only need to create a custom name for your case and a callback using the filter "ttwpwpan_rule_{$condition}", like this:

1. Create a custom case and optionally create some parameters

'display_on' => array(
   'custom_case' => array( 'some_parameter' => 'some_value' )
);

2. Add a filter

add_filter( "ttwpwpan_rule_" . "custom_case", function( $match = false, $conditions ){
   if( $conditions['some_parameter'] == 'some_value' ){
      $match = true;
   }
   return $match;
}, 10, 2 );