-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add new hook for Gutenberg latest posts block #26628
Add new hook for Gutenberg latest posts block #26628
Conversation
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.
Thanks @romain-d. Looks good, two notes:
-
Let's drop
core
and simply name this filterblock_latest_posts_query_args
. In WordPress, filters that don't have a prefix are implicitly core filters. -
Could you please add a doc comment before the
apply_filter
which explains what this filter does? You can see an example of what one of these looks like here. In this case we'll want@since 5.7.0
.
Hi @noisysocks , Thanks for the feedback, I made the requested changes. Best, |
@romain-d: Could you please rebase |
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.
Nice stuff!
I'm not really sure adding an adhoc hook for a specific block is a good idea? were there any discussion about this? |
There is already a general-purpose hook for modifying block's data: |
Agreed. Unless there is a really compelling for this block-specific hook, it seems important to revert so as not to open a precedent. |
It seems like the use case would be adding or removing an argument to the query which gets the latest posts for the block. That doesn't seem possible with the existing hooks |
Sometimes, it's not about it being possible or not. We need to make hard decisions. In this particular instance, someone could just replace the latest post block by his own block or override the render function. Yes, it's not as simple as a simple hook but it's better than having adhoc hook that we'll be forced to maintain. Especially since the Query block is meant to replace that block anyway. |
This reverts commit 6d475af.
@youknowriad I added a revert here since I merged this: #27078 |
Thank you Noah |
Hello,
following my error on the WordPress trac, I redo this PR here.
FYI https://core.trac.wordpress.org/ticket/51694
Add a hook to changes arguments of Gutenberg latests posts block query
Romain DORR, Be API