-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: Footnotes support for other CPT's. #57353
Conversation
Size Change: +6 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
Flaky tests detected in 6648c03. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7302999431
|
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 for the PR. This looks reasonable to me. Thoughts, @ellatrix?
6648c03
to
cba7fc3
Compare
Any sense of when this might be added to core (footnote support for other post types)? |
); | ||
foreach ( $post_types as $post_type ) { | ||
// Only register the meta field if the post type supports the editor, custom fields, and revisions. | ||
if ( post_type_supports( $post_type, 'editor' ) && post_type_supports( $post_type, 'custom-fields' ) && post_type_supports( $post_type, 'revisions' ) ) { |
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.
Why is custom-fields
required?
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.
@jorgefilipecosta: yeah, is that needed? Looking through Core's source I don't think this is a requirement.
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.
Oh sorry, I missed the question, without custom-fields support the footnotes are not saved on the REST API.
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.
Works for me :)
Assuming it can be merged in the next weeks, it will land in WP 6.5. |
One thing we may want to do, later on, is to materialise footnotes as a proper first-party feature. It could default to true if the post type meets all the necessary conditions (as laid out in this PR), but users could then explicitly opt out with: remove_post_type_support( 'my_type', 'footnotes' ); |
Dev note: Footnotes support was expanded for all CPT's In WordPress version 6.5, footnotes are now supported on any custom post type that fulfills certain requirements. To be eligible for footnotes, a custom post type must have capabilities like rest API, custom fields, revisions, and editor support. If a post type meets these requirements, footnotes should be available by default without requiring any changes from the developer. However, if a developer wants to remove footnotes support in a specific condition, for example, in a particular post type, they can use the block API like any other block. The following code sample demonstrates how we can remove footnotes support from the "post" post type:
|
This pull request adds support for footnotes in all custom post types (CPTs) that meet the following requirements:
Additionally, this pull request allows plugins to remove footnotes support from any post type by removing the footnotes meta key from the post type. For example, to remove footnotes support from pages, use the following code:
Testing
Added the following post type:
I have confirmed that the footnotes are functioning correctly on the specified post type.
Furthermore, I have removed the "custom-fields" support from the post type and confirmed that the footnotes are no longer available on the post type.
In addition, I have verified that the example mentioned earlier successfully removes footnotes support from pages.