ndiego / block-visibility

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

Create new filter hook on `run_acf_rule_tests` #73

Open seemly opened 1 year ago

seemly commented 1 year ago

I have added a new bv_run_acf_rule_tests_value filter hook.

This means you can pass a shortcode into the Value field in the UI and run do_shortcode using the new filter before 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.

add_filter('bv_run_acf_rule_tests_value', function($value) {
    if(str_contains($value, '[acf field=')) {
        return do_shortcode($value);
    }

    return $value;
});
Screenshot 2023-07-03 at 20 07 24