-
Notifications
You must be signed in to change notification settings - Fork 3k
Add: Footnotes support in core. #6003
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8150,3 +8150,38 @@ function wp_create_initial_post_meta() { | |
) | ||
); | ||
} | ||
|
||
/** | ||
* Registers the footnotes meta field for post types that support it. | ||
* | ||
* @internal | ||
* @since 6.5.0 | ||
* | ||
* @link https://github.com/WordPress/gutenberg/pull/57353 | ||
*/ | ||
function _wp_register_footnotes_meta_field() { | ||
$post_types = get_post_types( | ||
array( | ||
'show_in_rest' => true, | ||
'public' => true, | ||
) | ||
); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. In There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
$post_type_meta_keys = get_registered_meta_keys( 'post', $post_type ); | ||
if ( ! isset( $post_type_meta_keys['footnotes'] ) ) { | ||
register_post_meta( | ||
$post_type, | ||
'footnotes', | ||
array( | ||
'show_in_rest' => true, | ||
'single' => true, | ||
'type' => 'string', | ||
'revisions_enabled' => true, | ||
) | ||
); | ||
} | ||
} | ||
} | ||
} |
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.
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.