PCH Excerpt Generator: Fix wrong initialization of the module #2179
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.
Description
The Excerpt Generator feature is currently being initialized in the
init
hook. Since the script only needs to be present on the block editor, using this specific hook is not desirable, since it will load the script everywhere in the site, including the front-end.This PR changes the initialisation of the Excerpt Generator feature to the
enqueue_block_editor_assets
hook, and sets it with a priority of 9, to load before the PCH Editor Sidebar. This is required as loading after the sidebar does not work properly.Motivation and context
Make sure that the Excerpt Generator script is only loaded when it is actually needed.
How has this been tested?
Tested locally on my WordPress environment, and validated that the script is only being loaded in the block editor context, and that it is functioning as before.