Closed artemov-alexey closed 6 months ago
Hello! Is there a way to decide inside of enqueue() method eather to enqueue 3rd party script or not depending on the value of ACF true/false field in block? We have a custom form block, so if the field is set to TRUE we want the js script to be enqueued in enqueue() method. Here is example what's needed but doesn't work because get_field returns null in enqueue():
public function enqueue(): void { $chilipiper = (bool) get_field('chilipiper'); if (true === $chilipiper) { wp_enqueue_script('chilipiper-lib'); bundle('chilipiper')->enqueue(); } }
Thanks in advance!
If you find a way to get the values from a get_field, please let me know. I am encountering the same issue.
The commit that codepuncher has put in does in fact work to allow me to fetch block data.
Hello! Is there a way to decide inside of enqueue() method eather to enqueue 3rd party script or not depending on the value of ACF true/false field in block? We have a custom form block, so if the field is set to TRUE we want the js script to be enqueued in enqueue() method. Here is example what's needed but doesn't work because get_field returns null in enqueue():
Thanks in advance!