Custom fields conditions
-
There is new conditions checking in 1.2 and it seems to work wrong. In /wp-content/plugins/types/embedded/classes/conditional/evaluate.php you do a check for all the conditions in function “evulate”. Variable $passed is originally false
/* * * Since Types 1.2 * We force initial value to be FALSE. * Better to have restricted than allowed because of sensitive data. * If conditional is set on field and it goes wrong - better to abort * so user can report bug without exposing his content. */ $passed = false;Most of times code go to check if all or one condition is passed operating vars $passed_all and $passed_one. After that you check if not all the conditions passed and logic is and or if no one passed and logic is or.
if ( $count > 1 ) { if ( !$passed_all && $field['data']['conditional_display']['relation'] == 'AND' ) { $passed = false; } if ( !$passed_one && $field['data']['conditional_display']['relation'] == 'OR' ) { $passed = false; } }And you make $passed “falser” then before. So when it is gonna be true? Isn’t better to use instead:
if ( $count > 1 ) { $passed = !(!$passed_all && $field['data']['conditional_display']['relation'] == 'AND' || !$passed_one && $field['data']['conditional_display']['relation'] == 'OR'); }It help me in most of cases I use conditions of types plugin.
The topic ‘Custom fields conditions’ is closed to new replies.