A location rule in ACF that never matches anything. Useful when you are using field groups together with the “Clone” field type.
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 | |
/* | |
Plugin Name: Advanced Custom Fields: Nowhere location rules | |
Description: Adds a "Nowhere" location rule in ACF | |
*/ | |
add_filter('acf/location/rule_types', function($rules) { | |
$rules['Extra']['nowhere'] = 'Nowhere'; | |
return $rules; | |
}); | |
add_filter('acf/location/rule_operators/nowhere', function($choices) { | |
if(isset($choices['=='])) { | |
unset($choices['==']); | |
} | |
if(isset($choices['!='])) { | |
unset($choices['!=']); | |
} | |
$choices['nowhere'] = '-'; | |
return $choices; | |
}); | |
add_filter('acf/location/rule_values/nowhere', function($choices) { | |
return ['nowhere' => '-']; | |
}); | |
add_filter('acf/location/rule_match/nowhere', function($match, $rule, $options) { | |
return false; | |
}, 10, 3); |