From 9bf643e75df56ab76ac90c82f43b27af857313ce Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 9 Jul 2021 10:41:30 -0400 Subject: [PATCH] Move Query Loop related backwards compatibility code to the appropriate location. --- lib/compat/wordpress-5.8/blocks.php | 38 +++++++++++++++++++ .../block-library/src/post-template/index.php | 38 ------------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/compat/wordpress-5.8/blocks.php b/lib/compat/wordpress-5.8/blocks.php index 54a9864a270964..799c0c9c1aa627 100644 --- a/lib/compat/wordpress-5.8/blocks.php +++ b/lib/compat/wordpress-5.8/blocks.php @@ -55,3 +55,41 @@ function gutenberg_block_type_metadata_view_script( $settings, $metadata ) { } add_filter( 'block_type_metadata_settings', 'gutenberg_block_type_metadata_view_script', 10, 2 ); + +/** + * Complements the renaming of `Query Loop` to `Post Template`. + * This ensures backwards compatibility for any users running the Gutenberg + * plugin who have used Query Loop prior to its renaming. + * + * This can be removed when WordPress 5.9 is released. + * + * @see https://github.com/WordPress/gutenberg/pull/32514 + */ +function gutenberg_register_legacy_query_loop_block() { + $registry = WP_Block_Type_Registry::get_instance(); + if ( $registry->is_registered( 'core/query-loop' ) ) { + unregister_block_type( 'core/query-loop' ); + } + register_block_type( + 'core/query-loop', + array( + 'category' => 'design', + 'uses_context' => array( + 'queryId', + 'query', + 'queryContext', + 'displayLayout', + 'templateSlug', + ), + 'supports' => array( + 'reusable' => false, + 'html' => false, + 'align' => true, + ), + 'style' => 'wp-block-post-template', + 'render_callback' => 'render_legacy_query_loop_block', + 'skip_inner_blocks' => true, + ) + ); +} +add_action( 'init', 'gutenberg_register_legacy_query_loop_block' ); diff --git a/packages/block-library/src/post-template/index.php b/packages/block-library/src/post-template/index.php index c7f52c905577e9..c95024b1703a21 100644 --- a/packages/block-library/src/post-template/index.php +++ b/packages/block-library/src/post-template/index.php @@ -109,41 +109,3 @@ function render_legacy_query_loop_block( $attributes, $content, $block ) { ); return render_block_core_post_template( $attributes, $content, $block ); } - -/** - * Complements the renaming of `Query Loop` to `Post Template`. - * This ensures backwards compatibility for any users running the Gutenberg - * plugin who have used Query Loop prior to its renaming. - * - * This can be removed when WordPress 5.9 is released. - * - * @see https://github.com/WordPress/gutenberg/pull/32514 - */ -function gutenberg_register_legacy_query_loop_block() { - $registry = WP_Block_Type_Registry::get_instance(); - if ( $registry->is_registered( 'core/query-loop' ) ) { - unregister_block_type( 'core/query-loop' ); - } - register_block_type( - 'core/query-loop', - array( - 'category' => 'design', - 'uses_context' => array( - 'queryId', - 'query', - 'queryContext', - 'displayLayout', - 'templateSlug', - ), - 'supports' => array( - 'reusable' => false, - 'html' => false, - 'align' => true, - ), - 'style' => 'wp-block-post-template', - 'render_callback' => 'render_legacy_query_loop_block', - 'skip_inner_blocks' => true, - ) - ); -} -add_action( 'init', 'gutenberg_register_legacy_query_loop_block' );