Cwicly Plugin version: 1.3.1
This is an issue I constantly have to deal with.
Though there are different workarounds, I think it’s worth requiring a fix to make life easier
Let’s say I have an ACF file field, and that I don’t want to display it if no file has been selected.
The get_field() function will return:
falseif no file has been selected;
non empty arraywith data if a file has been selected.
(So, not only I don’t want to display it, but it will also cause an error when accessing indexes of
The issue is that Cwicly conditions don’t seem to work when comparing such ACF field.
And when I use a code block to the same comparisons with PHP, it works perfectly.
Here is how comparison should behave according to PHP manual:
But nothing seems to work inside Cwicly:
- comparing empty or non-empty field to
truealways seems to be false;
- comparing empty or non-empty field with
not emptyalways seems to be false;
- same using PHP functions like get_field() or get_sub_field() to access fields in conditions.
The only solution that seems to work is using
gettype(get_field('document')) === 'array' condition, but there’s a gap with empty but actual arrays to use it properly in all cases.
Am I missing something? Some syntax trick I’m not aware of?
What is weird is that
gettype() seems to respond correctly, but not other functions!!!