1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
<?php
/**
* Check if the given value is a instance of the rule class.
*
* @param mixed $rule
*
* @return bool
*/
function papi_is_rule( $rule ) {
return $rule instanceof Papi_Core_Conditional_Rule;
}
/**
* Get conditional rule.
*
* @param array|Papi_Core_Conditional_Rule $rule
*
* @return Papi_Page|null
*/
function papi_rule( $rule ) {
if ( is_array( $rule ) && ! empty( $rule ) ) {
return new Papi_Core_Conditional_Rule( $rule );
}
if ( $rule instanceof Papi_Core_Conditional_Rule ) {
return $rule;
}
}