编辑:comment-template.php
<?php /** * Server-side rendering of the `core/comment-template` block. * * @package WordPress */ /** * Function that recursively renders a list of nested comments. * * @since 6.3.0 Changed render_block_context priority to `1`. * * @global int $comment_depth * * @param WP_Comment[] $comments The array of comments. * @param WP_Block $block Block instance. * @return string */ function block_core_comment_template_render_comments( $comments, $block ) { global $comment_depth; $thread_comments = get_option( 'thread_comments' ); $thread_comments_depth = get_option( 'thread_comments_depth' ); if ( empty( $comment_depth ) ) { $comment_depth = 1; } $content = ''; foreach ( $comments as $comment ) { $comment_id = $comment->comment_ID; $filter_block_context = static function ( $context ) use ( $comment_id ) { $context['commentId'] = $comment_id; return $context; }; /* * We set commentId context through the `render_block_context` filter so * that dynamically inserted blocks (at `render_block` filter stage) * will also receive that context. * * Use an early priority to so that other 'render_block_context' filters * have access to the values. */ add_filter( 'render_block_context', $filter_block_context, 1 ); /* * We construct a new WP_Block instance from the parsed block so that * it'll receive any changes made by the `render_block_data` filter. */ $block_content = ( new WP_Block( $block->parsed_block ) )->render( array( 'dynamic' => false ) ); remove_filter( 'render_block_context', $filter_block_context, 1 ); $children = $comment->get_children(); /* * We need to create the CSS classes BEFORE recursing into the children. * This is because comment_class() uses globals like `$comment_alt` * and `$comment_thread_alt` which are order-sensitive. * * The `false` parameter at the end means that we do NOT want the function * to `echo` the output but to return a string. * See https://developer.wordpress.org/reference/functions/comment_class/#parameters. */ $comment_classes = comment_class( '', $comment->comment_ID, $comment->comment_post_ID, false ); // If the comment has children, recurse to create the HTML for the nested // comments. if ( ! empty( $children ) && ! empty( $thread_comments ) ) { if ( $comment_depth < $thread_comments_depth ) { ++$comment_depth; $inner_content = block_core_comment_template_render_comments( $children, $block ); $block_content .= sprintf( '<ol>%1$s</ol>', $inner_content ); --$comment_depth; } else { $block_content .= block_core_comment_template_render_comments( $children, $block ); } } $content .= sprintf( '<li id="comment-%1$s" %2$s>%3$s</li>', $comment->comment_ID, $comment_classes, $block_content ); } return $content; } /** * Renders the `core/comment-template` block on the server. * * @since 6.0.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 comments using the layout * defined by the block's inner blocks. */ function render_block_core_comment_template( $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; } $comment_query = new WP_Comment_Query( build_comment_query_vars_from_block( $block ) ); // Get an array of comments for the current post. $comments = $comment_query->get_comments(); if ( count( $comments ) === 0 ) { return ''; } $comment_order = get_option( 'comment_order' ); if ( 'desc' === $comment_order ) { $comments = array_reverse( $comments ); } $wrapper_attributes = get_block_wrapper_attributes(); return sprintf( '<ol %1$s>%2$s</ol>', $wrapper_attributes, block_core_comment_template_render_comments( $comments, $block ) ); } /** * Registers the `core/comment-template` block on the server. * * @since 6.0.0 */ function register_block_core_comment_template() { register_block_type_from_metadata( __DIR__ . '/comment-template', array( 'render_callback' => 'render_block_core_comment_template', 'skip_inner_blocks' => true, ) ); } add_action( 'init', 'register_block_core_comment_template' );
保存文件
位置:
home
/
robertofarias
/
public_html
/
wp-includes
/
blocks
批量上传
创建
创建
批量权限
批量删除
名称
权限
大小
修改时间
操作
↑ 返回上级
-
-
-
-
accordion
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
accordion-heading
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
accordion-item
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
accordion-panel
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
archives
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
audio
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
avatar
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
block
drwxr-xr-x
-
2024-07-17 11:52
权限
删除
重命名
button
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
buttons
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
calendar
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
categories
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
code
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
column
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
columns
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comment-author-name
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-content
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comment-date
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-edit-link
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-reply-link
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-template
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-next
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-numbers
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-previous
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
cover
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
details
drwxr-xr-x
-
2023-08-09 11:43
权限
删除
重命名
embed
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
file
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
footnotes
drwxr-xr-x
-
2023-08-09 11:43
权限
删除
重命名
freeform
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
gallery
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
group
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
heading
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
home-link
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
html
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
image
drwxr-xr-x
-
2023-11-08 10:55
权限
删除
重命名
latest-comments
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
latest-posts
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
legacy-widget
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
list
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
list-item
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
loginout
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
math
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
media-text
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
missing
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
more
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
navigation
drwxr-xr-x
-
2023-11-08 10:55
权限
删除
重命名
navigation-link
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
navigation-submenu
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
nextpage
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
page-list
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
page-list-item
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
paragraph
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
pattern
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-author
drwxr-xr-x
-
2025-12-04 05:42
权限
删除
重命名
post-author-biography
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
post-author-name
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
post-comments-count
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-comments-form
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-comments-link
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-content
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
post-date
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-excerpt
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-featured-image
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-navigation-link
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
post-template
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
post-terms
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-time-to-read
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
preformatted
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
pullquote
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query
drwxr-xr-x
-
2024-04-03 10:16
权限
删除
重命名
query-no-results
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-next
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-numbers
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-previous
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-total
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
quote
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
read-more
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
rss
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
search
drwxr-xr-x
-
2023-08-09 11:43
权限
删除
重命名
separator
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
shortcode
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
site-logo
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
site-tagline
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
site-title
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
social-link
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
social-links
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
spacer
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
table
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
tag-cloud
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
template-part
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
term-count
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
term-description
drwxr-xr-x
-
2023-08-09 11:43
权限
删除
重命名
term-name
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
term-template
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
terms-query
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
text-columns
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
verse
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
video
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
widget-group
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
accordion-item.php
-rw-r--r--
2.35 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
accordion.php
-rw-r--r--
1.12 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
archives.php
-rw-r--r--
4.31 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
avatar.php
-rw-r--r--
5.61 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
block.php
-rw-r--r--
4.09 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
blocks-json.php
-rw-r--r--
213.43 KB
2026-02-27 10:54
编辑
下载
权限
删除
重命名
button.php
-rw-r--r--
1.71 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
calendar.php
-rw-r--r--
5.93 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
categories.php
-rw-r--r--
4.54 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
comment-author-name.php
-rw-r--r--
2.08 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
comment-date.php
-rw-r--r--
1.82 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
comment-edit-link.php
-rw-r--r--
1.67 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
comment-template.php
-rw-r--r--
4.39 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
comments-pagination-next.php
-rw-r--r--
1.88 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
comments-pagination-numbers.php
-rw-r--r--
1.59 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
comments-pagination-previous.php
-rw-r--r--
1.75 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
comments-pagination.php
-rw-r--r--
1.23 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
comments-title.php
-rw-r--r--
2.71 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
cover.php
-rw-r--r--
3.1 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
error_log
-rw-r--r--
26.36 KB
2026-04-02 20:32
编辑
下载
权限
删除
重命名
file.php
-rw-r--r--
1.83 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
footnotes.php
-rw-r--r--
3.68 KB
2024-04-03 10:16
编辑
下载
权限
删除
重命名
gallery.php
-rw-r--r--
6.29 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
heading.php
-rw-r--r--
1.27 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
home-link.php
-rw-r--r--
5.31 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
image.php
-rw-r--r--
13.5 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
index.php
-rw-r--r--
4.99 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
latest-comments.php
-rw-r--r--
4.91 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
latest-posts.php
-rw-r--r--
8.53 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
legacy-widget.php
-rw-r--r--
3.92 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
list.php
-rw-r--r--
1.24 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
loginout.php
-rw-r--r--
1.63 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
media-text.php
-rw-r--r--
4.28 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
navigation-link.php
-rw-r--r--
13.63 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
navigation-submenu.php
-rw-r--r--
9.74 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
navigation.php
-rw-r--r--
48.39 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
page-list-item.php
-rw-r--r--
361 B
2024-07-17 11:51
编辑
下载
权限
删除
重命名
page-list.php
-rw-r--r--
13.29 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
pattern.php
-rw-r--r--
1.75 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
post-author-biography.php
-rw-r--r--
1.49 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
post-author-name.php
-rw-r--r--
1.91 KB
2025-05-01 11:02
编辑
下载
权限
删除
重命名
post-author.php
-rw-r--r--
2.67 KB
2025-05-01 11:02
编辑
下载
权限
删除
重命名
post-comments-count.php
-rw-r--r--
1.25 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-comments-form.php
-rw-r--r--
2.74 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
post-comments-link.php
-rw-r--r--
2.18 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-content.php
-rw-r--r--
2.29 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-date.php
-rw-r--r--
3.55 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-excerpt.php
-rw-r--r--
3.53 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-featured-image.php
-rw-r--r--
9.14 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-navigation-link.php
-rw-r--r--
4.72 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
post-template.php
-rw-r--r--
5.61 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
post-terms.php
-rw-r--r--
3.55 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
post-time-to-read.php
-rw-r--r--
6.34 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-title.php
-rw-r--r--
2.09 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-no-results.php
-rw-r--r--
1.8 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-pagination-next.php
-rw-r--r--
3.69 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
query-pagination-numbers.php
-rw-r--r--
4.66 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-pagination-previous.php
-rw-r--r--
3.49 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
query-pagination.php
-rw-r--r--
1.15 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-title.php
-rw-r--r--
2.87 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
query-total.php
-rw-r--r--
2.48 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
query.php
-rw-r--r--
5.56 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
read-more.php
-rw-r--r--
1.79 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
require-dynamic-blocks.php
-rw-r--r--
4.59 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
require-static-blocks.php
-rw-r--r--
558 B
2025-12-04 05:41
编辑
下载
权限
删除
重命名
rss.php
-rw-r--r--
4.5 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
search.php
-rw-r--r--
23.26 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
shortcode.php
-rw-r--r--
735 B
2024-07-17 11:51
编辑
下载
权限
删除
重命名
site-logo.php
-rw-r--r--
6.19 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
site-tagline.php
-rw-r--r--
1.17 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
site-title.php
-rw-r--r--
1.82 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
social-link.php
-rw-r--r--
66.15 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
tag-cloud.php
-rw-r--r--
1.55 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
template-part.php
-rw-r--r--
9.92 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
term-count.php
-rw-r--r--
1.8 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
term-description.php
-rw-r--r--
1.73 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
term-name.php
-rw-r--r--
2.02 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
term-template.php
-rw-r--r--
4.41 KB
2026-02-27 10:54
编辑
下载
权限
删除
重命名
video.php
-rw-r--r--
2.67 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
widget-group.php
-rw-r--r--
2.38 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名