Changeset 51421 for trunk/src/wp-includes/blocks/post-template.php
- Timestamp:
- 07/13/2021 04:39:05 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/post-template.php
r51199 r51421 87 87 } 88 88 add_action( 'init', 'register_block_core_post_template' ); 89 90 /**91 * Renders the legacy `core/query-loop` block on the server.92 * It triggers a developer warning and then calls the renamed93 * block's `render_callback` function output.94 *95 * This can be removed when WordPress 5.9 is released.96 *97 * @param array $attributes Block attributes.98 * @param string $content Block default content.99 * @param WP_Block $block Block instance.100 *101 * @return string Returns the output of the query, structured using the layout defined by the block's inner blocks.102 */103 function render_legacy_query_loop_block( $attributes, $content, $block ) {104 trigger_error(105 /* translators: %1$s: Block type */106 sprintf( __( 'Block %1$s has been renamed to Post Template. %1$s will be supported until WordPress version 5.9.' ), $block->name ),107 headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE108 );109 return render_block_core_post_template( $attributes, $content, $block );110 }111 112 /**113 * Complements the renaming of `Query Loop` to `Post Template`.114 * This ensures backwards compatibility for any users running the Gutenberg115 * plugin who have used Query Loop prior to its renaming.116 *117 * This can be removed when WordPress 5.9 is released.118 *119 * @see https://github.com/WordPress/gutenberg/pull/32514120 */121 function gutenberg_register_legacy_query_loop_block() {122 $registry = WP_Block_Type_Registry::get_instance();123 if ( $registry->is_registered( 'core/query-loop' ) ) {124 unregister_block_type( 'core/query-loop' );125 }126 register_block_type(127 'core/query-loop',128 array(129 'category' => 'design',130 'uses_context' => array(131 'queryId',132 'query',133 'queryContext',134 'displayLayout',135 'templateSlug',136 ),137 'supports' => array(138 'reusable' => false,139 'html' => false,140 'align' => true,141 ),142 'style' => 'wp-block-post-template',143 'render_callback' => 'render_legacy_query_loop_block',144 'skip_inner_blocks' => true,145 )146 );147 }148 add_action( 'init', 'gutenberg_register_legacy_query_loop_block' );
Note: See TracChangeset
for help on using the changeset viewer.