context['postId'] ) ) { return ''; } if ( post_password_required( $block->context['postId'] ) ) { return; } $footnotes = get_post_meta( $block->context['postId'], 'footnotes', true ); if ( ! $footnotes ) { return; } $footnotes = json_decode( $footnotes, true ); if ( count( $footnotes ) === 0 ) { return ''; } $wrapper_attributes = get_block_wrapper_attributes(); $block_content = ''; foreach ( $footnotes as $footnote ) { $block_content .= sprintf( '
  • %2$s ↩︎
  • ', $footnote['id'], $footnote['content'] ); } return sprintf( '
      %2$s
    ', $wrapper_attributes, $block_content ); } /** * Registers the `core/footnotes` block on the server. */ 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', ) ); } register_block_type_from_metadata( __DIR__ . '/footnotes', array( 'render_callback' => 'render_block_core_footnotes', ) ); } add_action( 'init', 'register_block_core_footnotes' );