Last active
May 19, 2017 18:37
-
-
Save daronspence/ac2f976d8929c7bd18c2 to your computer and use it in GitHub Desktop.
Return an array of rules for use with register_field_group() 'location' key
This file contains hidden or 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