Return an array of rules for use with register_field_group() 'location' key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @func acfw_location_rules | |
* Return an array of rules for use with register_field_group() 'location' key | |
* @param array $a | |
* @param str $param | |
* @param str $operator | |
* @param bool $extended | |
*/ | |
function acfw_location_rules( array $a, $param, $op, $extended = false ){ | |
$return = array(); | |
foreach ($a as $b){ | |
$push = array( | |
'param' => $param, | |
'operator' => $op, | |
'value' => $b | |
); | |
if ($extended){ | |
// wrap it to denote an "OR" | |
$push = array($push); | |
} | |
$return[] = $push; | |
} | |
if (! $extended){ | |
// wrap it so we don't have to | |
$return = array($return); | |
} | |
return $return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment