Skip to content

Commit

Permalink
Register footnotes related meta data.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Feb 6, 2024
1 parent 50f6236 commit a1f1611
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@

// CPT wp_block custom postmeta field.
add_action( 'init', 'wp_create_initial_post_meta' );
// Registers the footnotes meta field for post types that support it.
add_action( 'init', 'wp_register_footnotes_meta_field', 100 );

// Include revisioned meta when considering whether a post revision has changed.
add_filter( 'wp_save_post_revision_post_has_changed', 'wp_check_revisioned_meta_fields_have_changed', 10, 3 );
Expand Down
33 changes: 33 additions & 0 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -8252,3 +8252,36 @@ function wp_create_initial_post_meta() {
)
);
}

/**
* Registers the footnotes meta field for post types that support it.
*
* @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 ) );
$post_types = array_filter( $post_types, 'is_post_type_viewable' );
foreach ( $post_types as $post_type ) {
if ( ! post_type_supports( $post_type, 'footnotes' ) ) {
// Post type does not support footnotes, continue.
continue;
}
$post_type_meta_keys = get_registered_meta_keys( 'post', $post_type );
if ( isset( $post_type_meta_keys['footnotes'] ) ) {
// Footnotes meta key is already registered, continue.
continue;
}
register_post_meta(
$post_type,
'footnotes',
array(
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'revisions_enabled' => true,
)
);
}
}

0 comments on commit a1f1611

Please sign in to comment.