Logic rules

To add conditional rules that integrate with a loop type, register them with the Tangible Logic module.

The goal is to allow building conditions in an intuitive way, close to natural English.

In practice, the conditional UI is typically used on the admin side to control visibility of templates or builder widgets, based on user-constructed rule groups.



First, get an instance of the Logic module.

$logic = tangible_logic();

This can be done within or after the plugins_loaded action.

Then call the extend_rules_by_category method.


It accepts the following arguments:

  • Category name (string)

    Used to group rule definitions and generate documentation

  • Rule definitions (array)

    This is the same as the fields property in the conditions config for the Logic module.

    Each rule definition is an associative array with:

    • name
    • label
    • operands
    • values
  • Evaluator (anonymous function, or function name as string)

    This is the same as the evaluator for the Logic module.

    It is a function that receives a rule to evaluate, and returns true or false (boolean).