PluginProbe
Gutenberg / 12.1.0
Gutenberg v12.1.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / compat / wordpress-5.9 / blocks.php

blocks.php in Gutenberg 12.1.0, at lib/compat/wordpress-5.9/blocks.php

45 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Temporary compatibility shims for features present in Gutenberg.
4 * This file should be removed when WordPress 5.9.0 becomes the lowest
5 * supported version by this plugin.
6 *
7 * @package gutenberg
8 */
9
10 if ( ! function_exists( 'get_query_pagination_arrow' ) ) {
11 /**
12 * Helper function that returns the proper pagination arrow html for
13 * `QueryPaginationNext` and `QueryPaginationPrevious` blocks based
14 * on the provided `paginationArrow` from `QueryPagination` context.
15 *
16 * It's used in QueryPaginationNext and QueryPaginationPrevious blocks.
17 *
18 * @param WP_Block $block Block instance.
19 * @param boolean $is_next Flag for hanlding `next/previous` blocks.
20 *
21 * @return string|null Returns the constructed WP_Query arguments.
22 */
23 function get_query_pagination_arrow( $block, $is_next ) {
24 $arrow_map = array(
25 'none' => '',
26 'arrow' => array(
27 'next' => '',
28 'previous' => '',
29 ),
30 'chevron' => array(
31 'next' => '»',
32 'previous' => '«',
33 ),
34 );
35 if ( ! empty( $block->context['paginationArrow'] ) && array_key_exists( $block->context['paginationArrow'], $arrow_map ) && ! empty( $arrow_map[ $block->context['paginationArrow'] ] ) ) {
36 $pagination_type = $is_next ? 'next' : 'previous';
37 $arrow_attribute = $block->context['paginationArrow'];
38 $arrow = $arrow_map[ $block->context['paginationArrow'] ][ $pagination_type ];
39 $arrow_classes = "wp-block-query-pagination-$pagination_type-arrow is-arrow-$arrow_attribute";
40 return "<span class='$arrow_classes'>$arrow</span>";
41 }
42 return null;
43 }
44 }
45