-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix move CONTENT_ONLY_BLOCKS
into component body to ensure the editor.postContentBlockTypes
filter gets called whenever the values are used
#62292
Conversation
…tor.postContentBlockTypes` filter gets called whenever the values are used
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +9 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Thanks.
A bit nitpicky but can we keep the unfiltered CONTENT_ONLY_BLOCKS
constant at the top level and then do this in the component?
const contentOnlyBlocks = applyFilters( 'editor.postContentBlockTypes', CONTENT_ONLY_BLOCKS );
That way the capitalisation is properly indicating that the value never changes.
@noisysocks thanks for the review :) I updated the PR as you suggested 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Groovy, thanks!
…ody-to-ensure-the-filter-applies
…ody-to-ensure-the-filter-applies
…tor.postContentBlockTypes` filter gets called whenever the values are used (#62292) Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org> Co-authored-by: noisysocks <noisysocks@git.wordpress.org>
…tor.postContentBlockTypes` filter gets called whenever the values are used (#62292) Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org> Co-authored-by: noisysocks <noisysocks@git.wordpress.org>
…tor.postContentBlockTypes` filter gets called whenever the values are used (WordPress#62292) Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org> Co-authored-by: noisysocks <noisysocks@git.wordpress.org>
This was cherry-picked to the wp/6.6 branch. |
What?
Moves the
applyFilters( 'editor.postContentBlockTypes' )
call into the function body of the React component where it is used.Why?
Without this change the filter only gets run once at the time the
wp-editor
JS loads in the browser. This makes it almost impossible to call hook into this filter because most scripts that work with blocks havewp-editor
as a dependency.How?
Moving the constant with the
applyFilters
call into the function body of the component.Testing Instructions