Avoid doing-it-wrong notices with direct calls #8
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.
This PR fixes an issue where the
wp_script_is
,wp_style_is
,wp_register_script
andwp_register_style
functions would be called too early, triggering a doint-it-wrong PHP notice.Calling those functions before at least one of the
init
,wp_enqueue_scripts
,admin_enqueue_scripts
orlogin_enqueue_scripts
actions has fire, will trigger a doing-it-wrong notice.The change consists in running the same checks those functions would call to know if the registration would happen too early, if that is the case, the asset will be queued later.
I think the library API should abstract away the "is it too early?" concern, and just do it when it's right.