Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The primary funcitonality that is being introduced is allowing you to make multiple registrations just by using the API exposed.
Previously, because internally there were calls to wp_script_is or wp_style_is even if you removed the asset altogether you could not register more than once.
Registering more than once can have some advantages - listing a couple that pop on the top of my head.
Now you can modify your original's script dependencies to include your new script. Making managing when your script should be included easy. Wherever my original script is included, also please include my extension.
Also this PR introduces a magic method which enables us to call script or style methods from WP on the asset instance itself. You only need to call the method without the
wp_
prefix and replacing withasset
wherever thescript
orstyle
would be.So now you can do:
See an example of a snippet we had to provide support to achieve the functionality being added here:
https://lw.slack.com/archives/C01SBD5T03V/p1732799298015619?thread_ts=1732270965.841129&cid=C01SBD5T03V