-
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
Add filter to disable PostAuthor #12687
Conversation
9bd1048
to
763d68a
Compare
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.
Tested and confirmed that I was able to remove the see the author dropdown, and that adding the filter in the documentation removed the input.
It'd be nice to get some direction on whether it's worth filtering just the hiding of the box, vs. going a step further and making the component fully filterable so you can replace it entirely. Interesting idea though; definitely can see how it'd be useful to make this more flexible (Co-Authors Plus could benefit, for instance) |
@chrisvanpatten Co-Authors-Plus is exactly the use case, their quick fix was this PR Automattic/Co-Authors-Plus#630 which is far from ideal. My thought was that a multiple author plugin stores data in a different way, that it is beyond what the current component does. I suppose a new component provided by the plugin could handle the data the same way it would if it implemented as a sidebar module. I'm open to the idea of a filter that allows replacing |
763d68a
to
18deb82
Compare
@chrisvanpatten @mtias - updated with a different approach using a full component passed in to filter to switch it out. I welcome feedback. For the CoAuthorsPlus use case, it will require them to fully embrace Gutenberg and write a component to integrate. However, this seems like the much better and more flexible path to take. |
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.
We should mirror the solution used in other places and wrap PostAuthor
component with withFilter
HOC as it is always used with PostAuthorCheck
anyways. See: https://github.com/WordPress/gutenberg/blob/master/packages/edit-post/src/components/sidebar/post-author/index.js#L9.
See PostFeaturedImage
as an example: https://github.com/WordPress/gutenberg/blob/master/packages/editor/src/components/post-featured-image/index.js#L146
See also the first part of README file for |
Adds the ability for a developer to switch out the PostAuthor component with their own using the filter `editor.PostAuthor`
18deb82
to
85d9bfd
Compare
Thanks @gziolo so much better (and easier). I was pointed to PostFeatureImage as an example to look at but started off in the wrong direction, I looked at just this piece: https://github.com/WordPress/gutenberg/blob/master/packages/editor/src/components/post-featured-image/index.js#L35 Updated and included a readme for the component documenting how to extend it properly. |
The docs look good to me! |
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.
It looks good, thanks for updating 👍
@@ -63,4 +64,5 @@ export default compose( [ | |||
}, | |||
} ) ), | |||
withInstanceId, | |||
withFilters( 'editor.PostAuthor' ), |
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.
Like we discussed in previous #core-js chats, we should resist adding new filters/actions.
An alternative here would be to build a custom edit-post module.
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.
It is part of the Post & Status
panel, so it had to be re-created from scratch. I think we should introduce all missing filters for the elements we put in the sidebar for backward compatibility and consistency. However, we should stop doing it in other places unless there is a really good reason to do so. I can't think of any at the moment :)
* Add filter to replace PostAuthor component Adds the ability for a developer to switch out the PostAuthor component with their own using the filter `editor.PostAuthor` * Add readme for PostAuthor component, with hook documented * Remove documentation here, included in component readme
* Add filter to replace PostAuthor component Adds the ability for a developer to switch out the PostAuthor component with their own using the filter `editor.PostAuthor` * Add readme for PostAuthor component, with hook documented * Remove documentation here, included in component readme
Description
Adds a filter to the PostAuthor component which allows to override with a custom component.
How has this been tested?
Confirm the author field shows fine before/after apply the patch
In the plugin or theme that wants to override the component, use the following JavaScript code, remember to include
'wp-hooks', 'wp-element'
in your enqueue dependency array.Types of changes
This extends gutenberg with the
editor.PostAuthor
filter giving developers a hook to control the component for PostAuthor.Checklist: