| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Server-side rendering of the `core/comments-pagination-previous` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Renders the `core/comments-pagination-previous` block on the server. 10 * 11 * @since 6.0.0 12 * 13 * @param array $attributes Block attributes. 14 * @param string $content Block default content. 15 * @param WP_Block $block Block instance. 16 * 17 * @return string Returns the previous posts link for the comments pagination. 18 */ 19 function render_block_core_comments_pagination_previous( $attributes, $content, $block ) { 20 $default_label = __( 'Older Comments' ); 21 $label = ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label; 22 $pagination_arrow = get_comments_pagination_arrow( $block, 'previous' ); 23 24 // Escaping early as pagination arrow can return HTML that should not be escaped. 25 $label = esc_html( $label ); 26 if ( $pagination_arrow ) { 27 $label = $pagination_arrow . $label; 28 } 29 30 $filter_link_attributes = static function () { 31 return get_block_wrapper_attributes(); 32 }; 33 add_filter( 'previous_comments_link_attributes', $filter_link_attributes ); 34 35 $comment_vars = build_comment_query_vars_from_block( $block ); 36 $previous_comments_link = get_previous_comments_link( $label, $comment_vars['paged'] ?? null ); 37 38 remove_filter( 'previous_comments_link_attributes', $filter_link_attributes ); 39 40 if ( ! isset( $previous_comments_link ) ) { 41 return ''; 42 } 43 44 return $previous_comments_link; 45 } 46 47 /** 48 * Registers the `core/comments-pagination-previous` block on the server. 49 * 50 * @since 6.0.0 51 */ 52 function register_block_core_comments_pagination_previous() { 53 register_block_type_from_metadata( 54 __DIR__ . '/comments-pagination-previous', 55 array( 56 'render_callback' => 'render_block_core_comments_pagination_previous', 57 ) 58 ); 59 } 60 add_action( 'init', 'register_block_core_comments_pagination_previous' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sun Nov 1 08:20:35 2026 | Cross-referenced by PHPXref |