PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
24.1.0 24.0.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 All 404 releases
gutenberg / lib / compat / wordpress-7.1 / query-block.php

query-block.php in Gutenberg trunk, at lib/compat/wordpress-7.1/query-block.php

28 lines 732 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Temporary compatibility code for new functionalities/changes related to the query block.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Filters the query loop block query vars to exclude the current post.
10 *
11 * @param array $query The current query vars.
12 * @param WP_Block $block The block instance.
13 *
14 * @return array The modified query vars.
15 */
16 function gutenberg_filter_query_block_exclude_current( $query, $block ) {
17 if ( ! empty( $block->context['query']['excludeCurrent'] ) ) {
18 $current_post_id = get_the_ID();
19 if ( $current_post_id ) {
20 $query['post__not_in'][] = $current_post_id;
21 }
22 }
23
24 return $query;
25 }
26
27 add_filter( 'query_loop_block_query_vars', 'gutenberg_filter_query_block_exclude_current', 10, 2 );
28