Skip to content

Commit

Permalink
Move Query Loop related backwards compatibility code to the appropria…
Browse files Browse the repository at this point in the history
…te location.
  • Loading branch information
desrosj committed Jul 9, 2021
1 parent ab995bb commit 9bf643e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
38 changes: 38 additions & 0 deletions lib/compat/wordpress-5.8/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
38 changes: 0 additions & 38 deletions packages/block-library/src/post-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

0 comments on commit 9bf643e

Please sign in to comment.