Diff: STRATO-apps/wordpress_03/app/wp-includes/blocks/comments-pagination-previous.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
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 = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
22 + $pagination_arrow = get_comments_pagination_arrow( $block, 'previous' );
23 + if ( $pagination_arrow ) {
24 + $label = $pagination_arrow . $label;
25 + }
26 +
27 + $filter_link_attributes = static function () {
28 + return get_block_wrapper_attributes();
29 + };
30 + add_filter( 'previous_comments_link_attributes', $filter_link_attributes );
31 +
32 + $comment_vars = build_comment_query_vars_from_block( $block );
33 + $previous_comments_link = get_previous_comments_link( $label, $comment_vars['paged'] ?? null );
34 +
35 + remove_filter( 'previous_comments_link_attributes', $filter_link_attributes );
36 +
37 + if ( ! isset( $previous_comments_link ) ) {
38 + return '';
39 + }
40 +
41 + return $previous_comments_link;
42 + }
43 +
44 + /**
45 + * Registers the `core/comments-pagination-previous` block on the server.
46 + *
47 + * @since 6.0.0
48 + */
49 + function register_block_core_comments_pagination_previous() {
50 + register_block_type_from_metadata(
51 + __DIR__ . '/comments-pagination-previous',
52 + array(
53 + 'render_callback' => 'render_block_core_comments_pagination_previous',
54 + )
55 + );
56 + }
57 + add_action( 'init', 'register_block_core_comments_pagination_previous' );
58 +