đ File Manager
đ Edit File: footnotes.php
<?php /** * Server-side rendering of the `core/footnotes` block. * * @package WordPress */ /** * Renders the `core/footnotes` block on the server. * * @since 6.3.0 * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. * * @return string Returns the HTML representing the footnotes. */ function render_block_core_footnotes( $attributes, $content, $block ) { // Bail out early if the post ID is not set for some reason. if ( empty( $block->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 ( ! is_array( $footnotes ) || count( $footnotes ) === 0 ) { return ''; } $wrapper_attributes = get_block_wrapper_attributes(); $footnote_index = 1; $block_content = ''; foreach ( $footnotes as $footnote ) { // Translators: %d: Integer representing the number of return links on the page. $aria_label = sprintf( __( 'Jump to footnote reference %1$d' ), $footnote_index ); $block_content .= sprintf( '<li id="%1$s">%2$s <a href="#%1$s-link" aria-label="%3$s">âŠī¸</a></li>', $footnote['id'], $footnote['content'], $aria_label ); ++$footnote_index; } return sprintf( '<ol %1$s>%2$s</ol>', $wrapper_attributes, $block_content ); } /** * Registers the `core/footnotes` block on the server. * * @since 6.3.0 */ 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' ); /** * 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. * * @since 6.3.0 * * @param array $fields The revision fields. * @return array The revision fields. */ function wp_add_footnotes_to_revision( $fields ) { $fields['footnotes'] = __( 'Footnotes' ); return $fields; } add_filter( '_wp_post_revision_fields', 'wp_add_footnotes_to_revision' ); /** * Gets the footnotes field from the revision for the revisions screen. * * @since 6.3.0 * * @param string $revision_field The field value, but $revision->$field * (footnotes) does not exist. * @param string $field The field name, in this case "footnotes". * @param object $revision The revision object to compare against. * @return string The field value. */ function wp_get_footnotes_from_revision( $revision_field, $field, $revision ) { return get_metadata( 'post', $revision->ID, $field, true ); } add_filter( '_wp_post_revision_field_footnotes', 'wp_get_footnotes_from_revision', 10, 3 );
Cancel
Type
Item Name
Actions
đ
..
đ
archives
âī¸
đ
audio
âī¸
đ
avatar
âī¸
đ
block
âī¸
đ
button
âī¸
đ
buttons
âī¸
đ
calendar
âī¸
đ
categories
âī¸
đ
code
âī¸
đ
column
âī¸
đ
columns
âī¸
đ
comment-author-name
âī¸
đ
comment-content
âī¸
đ
comment-date
âī¸
đ
comment-edit-link
âī¸
đ
comment-reply-link
âī¸
đ
comment-template
âī¸
đ
comments
âī¸
đ
comments-pagination
âī¸
đ
comments-pagination-next
âī¸
đ
comments-pagination-numbers
âī¸
đ
comments-pagination-previous
âī¸
đ
comments-title
âī¸
đ
cover
âī¸
đ
details
âī¸
đ
embed
âī¸
đ
file
âī¸
đ
footnotes
âī¸
đ
freeform
âī¸
đ
gallery
âī¸
đ
group
âī¸
đ
heading
âī¸
đ
home-link
âī¸
đ
html
âī¸
đ
image
âī¸
đ
latest-comments
âī¸
đ
latest-posts
âī¸
đ
legacy-widget
âī¸
đ
list
âī¸
đ
list-item
âī¸
đ
loginout
âī¸
đ
media-text
âī¸
đ
missing
âī¸
đ
more
âī¸
đ
navigation
âī¸
đ
navigation-link
âī¸
đ
navigation-submenu
âī¸
đ
nextpage
âī¸
đ
page-list
âī¸
đ
page-list-item
âī¸
đ
paragraph
âī¸
đ
pattern
âī¸
đ
post-author
âī¸
đ
post-author-biography
âī¸
đ
post-author-name
âī¸
đ
post-comments-form
âī¸
đ
post-content
âī¸
đ
post-date
âī¸
đ
post-excerpt
âī¸
đ
post-featured-image
âī¸
đ
post-navigation-link
âī¸
đ
post-template
âī¸
đ
post-terms
âī¸
đ
post-title
âī¸
đ
preformatted
âī¸
đ
pullquote
âī¸
đ
query
âī¸
đ
query-no-results
âī¸
đ
query-pagination
âī¸
đ
query-pagination-next
âī¸
đ
query-pagination-numbers
âī¸
đ
query-pagination-previous
âī¸
đ
query-title
âī¸
đ
quote
âī¸
đ
read-more
âī¸
đ
rss
âī¸
đ
search
âī¸
đ
separator
âī¸
đ
shortcode
âī¸
đ
site-logo
âī¸
đ
site-tagline
âī¸
đ
site-title
âī¸
đ
social-link
âī¸
đ
social-links
âī¸
đ
spacer
âī¸
đ
table
âī¸
đ
tag-cloud
âī¸
đ
template-part
âī¸
đ
term-description
âī¸
đ
text-columns
âī¸
đ
verse
âī¸
đ
video
âī¸
đ
widget-group
âī¸
đ
archives.php
âī¸
đ
đ
avatar.php
âī¸
đ
đ
block.php
âī¸
đ
đ
blocks-json.php
âī¸
đ
đ
button.php
âī¸
đ
đ
calendar.php
âī¸
đ
đ
categories.php
âī¸
đ
đ
comment-author-name.php
âī¸
đ
đ
comment-content.php
âī¸
đ
đ
comment-date.php
âī¸
đ
đ
comment-edit-link.php
âī¸
đ
đ
comment-reply-link.php
âī¸
đ
đ
comment-template.php
âī¸
đ
đ
comments-pagination-next.php
âī¸
đ
đ
comments-pagination-numbers.php
âī¸
đ
đ
comments-pagination-previous.php
âī¸
đ
đ
comments-pagination.php
âī¸
đ
đ
comments-title.php
âī¸
đ
đ
comments.php
âī¸
đ
đ
cover.php
âī¸
đ
đ
file.php
âī¸
đ
đ
footnotes.php
âī¸
đ
đ
gallery.php
âī¸
đ
đ
heading.php
âī¸
đ
đ
home-link.php
âī¸
đ
đ
image.php
âī¸
đ
đ
index.php
âī¸
đ
đ
latest-comments.php
âī¸
đ
đ
latest-posts.php
âī¸
đ
đ
legacy-widget.php
âī¸
đ
đ
list.php
âī¸
đ
đ
loginout.php
âī¸
đ
đ
media-text.php
âī¸
đ
đ
navigation-link.php
âī¸
đ
đ
navigation-submenu.php
âī¸
đ
đ
navigation.php
âī¸
đ
đ
page-list-item.php
âī¸
đ
đ
page-list.php
âī¸
đ
đ
pattern.php
âī¸
đ
đ
post-author-biography.php
âī¸
đ
đ
post-author-name.php
âī¸
đ
đ
post-author.php
âī¸
đ
đ
post-comments-form.php
âī¸
đ
đ
post-content.php
âī¸
đ
đ
post-date.php
âī¸
đ
đ
post-excerpt.php
âī¸
đ
đ
post-featured-image.php
âī¸
đ
đ
post-navigation-link.php
âī¸
đ
đ
post-template.php
âī¸
đ
đ
post-terms.php
âī¸
đ
đ
post-title.php
âī¸
đ
đ
query-no-results.php
âī¸
đ
đ
query-pagination-next.php
âī¸
đ
đ
query-pagination-numbers.php
âī¸
đ
đ
query-pagination-previous.php
âī¸
đ
đ
query-pagination.php
âī¸
đ
đ
query-title.php
âī¸
đ
đ
query.php
âī¸
đ
đ
read-more.php
âī¸
đ
đ
require-dynamic-blocks.php
âī¸
đ
đ
require-static-blocks.php
âī¸
đ
đ
rss.php
âī¸
đ
đ
search.php
âī¸
đ
đ
shortcode.php
âī¸
đ
đ
site-logo.php
âī¸
đ
đ
site-tagline.php
âī¸
đ
đ
site-title.php
âī¸
đ
đ
social-link.php
âī¸
đ
đ
tag-cloud.php
âī¸
đ
đ
template-part.php
âī¸
đ
đ
term-description.php
âī¸
đ
đ
widget-group.php
âī¸
đ