Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
413 stars 56 forks source link

enhance: pass block data to enqueue method #146

Closed codepuncher closed 1 year ago

codepuncher commented 1 year ago

Ref #144 and #143

I have played about locally on this and seems we can simply pass the $block array to the enqueue method which gives access to $block['data']['my_field_name']. This allowed me to conditionally enqueue assets depending on field values.

This PR needs more work like adding the argument to Block::enqueue($data = []) but I opened the PR just to get the ball rolling on this. It would result in a breaking change since the signature has changed.

@Log1x - anything to add to this? Not as nice as get_field in the method but hey it works.

Log1x commented 1 year ago

Sorry for the late response.

Thanks for finding out you can do this. We'll need to update the stubs, etc. and then yeah push a major release since it's a breaking change.

Do you want me to take over or do you want to do the remaining changes?

codepuncher commented 1 year ago

Unfortunately I don't have the availability to continue with it - feel free to take over.

Log1x commented 1 year ago

Superseded by #154