From dfdc9a9d513081350810d764b56d3c64999d3b97 Mon Sep 17 00:00:00 2001 From: Chris Sparshott Date: Mon, 3 Jul 2023 20:05:03 +0100 Subject: [PATCH] Create new filter hook on `run_acf_rule_tests` I have added a new `bv_run_acf_rule_tests_value` filter hook. This means you can then pass a shortcode into the `Value` field in the UI, and run `do_shortcode` using the new filter prior to comparison. This is useful when bulk importing posts using something like WP All Import, and you want to compare the value against a dynamically generated value defined in an ACF field on the current post --- includes/frontend/visibility-tests/acf.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/frontend/visibility-tests/acf.php b/includes/frontend/visibility-tests/acf.php index d576a9ca..f78f660e 100644 --- a/includes/frontend/visibility-tests/acf.php +++ b/includes/frontend/visibility-tests/acf.php @@ -201,6 +201,8 @@ function run_acf_rule_tests( $operator, $value, $acf_field ) { } elseif ( 'empty' === $operator ) { $test_result = empty( $field_value ); } elseif ( isset( $value ) ) { + // This allows developers to modify $value, including adding support for shortcode value comparisons + $value = apply_filters( 'bv_run_acf_rule_tests_value', $value ); // Choice values are generally arrays and need to be treated differently. // Allow for type juggling here since array can include strings or numbers.