Advertisement
srikat

[Condition] ACF Field Empty

Jul 18th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. if ( function_exists( 'oxygen_vsb_register_condition' ) ) {
  2.  
  3. oxygen_vsb_register_condition(
  4. // Condition Name
  5. 'ACF Field Empty',
  6.  
  7. // Values: The array of pre-set values the user can choose from.
  8. // Set the custom key's value to true to allow users to input custom values.
  9. array(
  10. 'options' => array(),
  11. 'custom' => true
  12. ),
  13.  
  14. // Operators
  15. array( '--' ),
  16.  
  17. // Callback Function: Name of function that will be used to handle the condition
  18. 'acf_field_empty_fallback',
  19.  
  20. // Condition Category: Default ones are Archive, Author, Other, Post, User
  21. 'ACF'
  22. );
  23.  
  24. }
  25.  
  26. /**
  27. * Callback function to handle the condition.
  28. * @param mixed $value Input value - in this case, name of ACF custom field.
  29. * @param string $operator Comparison operator selected by the user.
  30. *
  31. * @return boolean true or false.
  32. */
  33. function acf_field_empty_fallback( $value, $operator ) {
  34.  
  35. return ( get_field( $value ) ) ? false : true;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement