Skip to content

Commit

Permalink
Update: Increate footnotes meta priority and separate footnotes meta …
Browse files Browse the repository at this point in the history
…registration. (#58882)

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: peterwilsoncc <peterwilsoncc@git.wordpress.org>
Co-authored-by: mcsf <mcsf@git.wordpress.org>
  • Loading branch information
4 people committed Feb 16, 2024
1 parent a2d2c2b commit 96cb434
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions packages/block-library/src/footnotes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,30 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
* @since 6.3.0
*/
function register_block_core_footnotes() {
$post_types = get_post_types(
register_block_type_from_metadata(
__DIR__ . '/footnotes',
array(
'show_in_rest' => true,
'public' => true,
'render_callback' => 'render_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' ) ) {
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',
Expand All @@ -89,14 +104,12 @@ function register_block_core_footnotes() {
);
}
}
register_block_type_from_metadata(
__DIR__ . '/footnotes',
array(
'render_callback' => 'render_block_core_footnotes',
)
);
}
add_action( 'init', 'register_block_core_footnotes' );
/**
* 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.
Expand Down

1 comment on commit 96cb434

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 96cb434.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7934221031
📝 Reported issues:

Please sign in to comment.