-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 in core. #6003
Add: Footnotes support in core. #6003
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
f7aa6fb
to
8d731a1
Compare
8d731a1
to
bcd6db8
Compare
); | ||
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' ) && post_type_supports( $post_type, 'footnotes' ) ) { |
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.
In src/wp-includes/class-wp-post-type.php
, we have already added support for a specific post type. Why are we checking a similar condition here again?
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.
The reason for the check was that meanwhile, a plugin may have removed a support after the code in src/wp-includes/class-wp-post-type.php executed.
@@ -669,6 +669,9 @@ public function add_supports() { | |||
add_post_type_support( $this->name, $args ); | |||
} | |||
} | |||
if ( post_type_supports( $this->name, 'editor' ) && post_type_supports( $this->name, 'custom-fields' ) && post_type_supports( $this->name, 'revisions' ) && ! post_type_supports( $this->name, 'footnotes' ) ) { |
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.
For multiple conditions i personally follow.
if ( post_type_supports( $this->name, 'editor' ) && post_type_supports( $this->name, 'custom-fields' ) && post_type_supports( $this->name, 'revisions' ) && ! post_type_supports( $this->name, 'footnotes' ) ) { | |
if ( | |
post_type_supports( $this->name, 'editor' ) && | |
post_type_supports( $this->name, 'custom-fields' ) && | |
post_type_supports( $this->name, 'revisions' ) && | |
! post_type_supports( $this->name, 'footnotes' ) | |
) { |
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.
Thank you for the suggestion 👍 I'm applying it at WordPress/gutenberg#58882.
Cross posting my change request from the Gutenberg PR WordPress/gutenberg#58573 (review) that I think it's best to make the footnotes opt in for CPTs. Let's finalise the approach in the upstream repo rather than discussing in two PRs. |
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 Core SVNIf you're a Core Committer, use this list when committing to
GitHub Merge commitsIf 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. |
Closing this PR following @ellatrix suggestion at WordPress/gutenberg#58573 (comment). |
Core version of WordPress/gutenberg#58573.
Adds footnote support for custom post types in the core. Creates a new footnotes support key.
By default, every post that meets footnotes requirements has support for footnotes.
Developers can now remove footnotes support with:
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
remove_post_type_support( 'page', 'footnotes' );
successfully removes footnotes support from pages.