Last active
April 20, 2021 16:25
-
-
Save flyingwebie/9acea680c7690bedddfb64dda0c5a013 to your computer and use it in GitHub Desktop.
ACF Repeater Field / Single Field Not Empty
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 | |
if ( function_exists( 'oxygen_vsb_register_condition' ) ) { | |
oxygen_vsb_register_condition( | |
// Condition Name | |
'ACF Field Not Empty', | |
// Values: The array of pre-set values the user can choose from. | |
// Set the custom key's value to true to allow users to input custom values. | |
array( | |
'options' => array(), | |
'custom' => true | |
), | |
// Operators | |
array( '--' ), | |
// Callback Function: Name of function that will be used to handle the condition | |
'acf_field_not_empty_callback', | |
// Condition Category: Default ones are Archive, Author, Other, Post, User | |
'ACF' | |
); | |
oxygen_vsb_register_condition( | |
// Condition Name | |
'ACF Repeater Field Not Empty', | |
// Values: The array of pre-set values the user can choose from. | |
// Set the custom key's value to true to allow users to input custom values. | |
array( | |
'options' => array(), | |
'custom' => true | |
), | |
// Operators | |
array( '--' ), | |
// Callback Function: Name of function that will be used to handle the condition | |
'acf_repeater_field_not_empty_callback', | |
// Condition Category: Default ones are Archive, Author, Other, Post, User | |
'ACF' | |
); | |
} | |
/** | |
* Callback function to handle the condition. | |
* @param mixed $value Input value - in this case, name of the ACF custom field. | |
* @param string $operator Comparison operator selected by the user. | |
* | |
* @return boolean true or false. | |
*/ | |
function acf_field_not_empty_callback( $value, $operator ) { | |
return ( get_field( $value ) ) ? true : false; | |
} | |
function acf_repeater_field_not_empty_callback( $value, $operator ) { | |
return ( get_sub_field( $value ) ) ? true : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment