Last active
January 25, 2022 17:51
-
-
Save Spellhammer/2b4547c36c2e2d9a8e0fa9ec84c83cf7 to your computer and use it in GitHub Desktop.
Post Type Condition For ACF Extended Post Types
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
if( function_exists('oxygen_vsb_register_condition') ) { | |
add_action('init', 'register_post_type_condition_acfe', 99); | |
function register_post_type_condition_acfe() { | |
$post_types = array_values(get_post_types(array('public'=>true))); | |
global $oxy_condition_operators; | |
oxygen_vsb_register_condition('ACFE Post Type',array('options'=>$post_types, 'custom'=>false), array('==', '!='), 'condition_post_type_callback_acfe', 'ACFE'); | |
} | |
function condition_post_type_callback_acfe($value, $operator) { | |
$current_post_type = get_post_type( get_the_ID() ); | |
$value = (string) $value; | |
global $OxygenConditions; | |
return $OxygenConditions->eval_string($current_post_type, $value, $operator); | |
} } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment