summaryrefslogtreecommitdiffstats
path: root/wp-includes/blocks/footnotes.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:26 +0000
commit30883c26bdceb9eaf32c8d4a1b0c1bce223b5226 (patch)
tree39a02e2aeb21ab5b7923c6f5757d66d55b708912 /wp-includes/blocks/footnotes.php
parentAdding upstream version 6.4.3+dfsg1. (diff)
downloadwordpress-30883c26bdceb9eaf32c8d4a1b0c1bce223b5226.tar.xz
wordpress-30883c26bdceb9eaf32c8d4a1b0c1bce223b5226.zip
Adding upstream version 6.5+dfsg1.upstream/6.5+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/blocks/footnotes.php')
-rw-r--r--wp-includes/blocks/footnotes.php46
1 files changed, 34 insertions, 12 deletions
diff --git a/wp-includes/blocks/footnotes.php b/wp-includes/blocks/footnotes.php
index bc6291d..380c093 100644
--- a/wp-includes/blocks/footnotes.php
+++ b/wp-includes/blocks/footnotes.php
@@ -68,18 +68,6 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
* @since 6.3.0
*/
function register_block_core_footnotes() {
- foreach ( array( 'post', 'page' ) as $post_type ) {
- register_post_meta(
- $post_type,
- 'footnotes',
- array(
- 'show_in_rest' => true,
- 'single' => true,
- 'type' => 'string',
- 'revisions_enabled' => true,
- )
- );
- }
register_block_type_from_metadata(
__DIR__ . '/footnotes',
array(
@@ -89,6 +77,40 @@ function register_block_core_footnotes() {
}
add_action( 'init', 'register_block_core_footnotes' );
+
+/**
+ * Registers the footnotes meta field required for footnotes to work.
+ *
+ * @since 6.5.0
+ */
+function register_block_core_footnotes_post_meta() {
+ $post_types = get_post_types( array( 'show_in_rest' => 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' )
+ ) {
+ register_post_meta(
+ $post_type,
+ 'footnotes',
+ array(
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'string',
+ 'revisions_enabled' => true,
+ )
+ );
+ }
+ }
+}
+/*
+ * Most post types are registered at priority 10, so use priority 20 here in
+ * order to catch them.
+*/
+add_action( 'init', 'register_block_core_footnotes_post_meta', 20 );
+
/**
* Adds the footnotes field to the revisions display.
*