ndiego / block-visibility

Conditional visibility controls for all WordPress blocks.
https://www.blockvisibilitywp.com
GNU General Public License v2.0
130 stars 10 forks source link

ACF rule set with equal rule doesn't work properly #50

Closed land0r closed 1 year ago

land0r commented 2 years ago

Description

For numeric ACF values, there is no proper working for the rule set because the condition in PHP is strict - https://github.com/ndiego/block-visibility/blob/main/includes/frontend/visibility-tests/acf.php#L205

If you remove === to == or try to add some type for this check, there will be the desired result.

Step-by-step reproduction instructions

  1. Add any block (paragraph) to Gutenberg.
  2. Add a rule set with ACF. ACF rule is "Show the block if 'Numeric ACF' is equal to 12"
  3. Save the page

Expected behavior

You will see this block because the code tries to compare 12 == '12' (integer with string but without strict comparison)

Actual behavior

You will not see this block because the code tries to compare 12 === '12' (integer with string)

Screenshots or screen recording (optional)

2022-11-15 15 26 58 iq-foundertrac test ef64fe07381e

System information

v-vovk commented 2 years ago

I totally agree with you, it's a very annoying thing

ndiego commented 2 years ago

@land0r Thanks for reporting this, and I apologize for the delayed reply. This will be fixed in the next version, scheduled for 2022-12-05.