From 5e59ec8825768a60d35f84df201fac8f97807db4 Mon Sep 17 00:00:00 2001 From: Jeff Ong Date: Thu, 22 Jul 2021 16:44:24 -0400 Subject: [PATCH 1/2] Add a render callback. --- .../src/query-pagination/index.php | 26 ++++++++++++++++++- .../src/query-pagination/save.js | 6 ++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/query-pagination/index.php b/packages/block-library/src/query-pagination/index.php index a9f31bf78fc4f..636b6f9ea9345 100644 --- a/packages/block-library/src/query-pagination/index.php +++ b/packages/block-library/src/query-pagination/index.php @@ -5,12 +5,36 @@ * @package WordPress */ +/** + * Renders the `core/query-pagination` block on the server. + * + * @param array $attributes Block attributes. + * @param string $content Block default content. + * + * @return string Returns the wrapper for the Query pagination. + */ +function render_block_core_query_pagination( $attributes, $content ) { + $wrapper_attributes = get_block_wrapper_attributes(); + + if ( empty( $content ) || ctype_space( $content ) ) { + return ''; + } + return sprintf( + '
%2$s
', + $wrapper_attributes, + $content + ); +} + /** * Registers the `core/query-pagination` block on the server. */ function register_block_core_query_pagination() { register_block_type_from_metadata( - __DIR__ . '/query-pagination' + __DIR__ . '/query-pagination', + array( + 'render_callback' => 'render_block_core_query_pagination', + ) ); } add_action( 'init', 'register_block_core_query_pagination' ); diff --git a/packages/block-library/src/query-pagination/save.js b/packages/block-library/src/query-pagination/save.js index 000acdcd4a605..873432fe65954 100644 --- a/packages/block-library/src/query-pagination/save.js +++ b/packages/block-library/src/query-pagination/save.js @@ -1,12 +1,10 @@ /** * WordPress dependencies */ -import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; +import { InnerBlocks } from '@wordpress/block-editor'; export default function save() { return ( -
- -
+ ); } From 6b32739f43d5ec77866cdfef26e3cb9474daf479 Mon Sep 17 00:00:00 2001 From: Jeff Ong Date: Thu, 22 Jul 2021 17:44:57 -0400 Subject: [PATCH 2/2] Remove static save. --- packages/block-library/src/query-pagination/index.js | 2 -- packages/block-library/src/query-pagination/index.php | 4 ++-- packages/block-library/src/query-pagination/save.js | 10 ---------- 3 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 packages/block-library/src/query-pagination/save.js diff --git a/packages/block-library/src/query-pagination/index.js b/packages/block-library/src/query-pagination/index.js index a15bdd4389cee..bc36ba9ca7e32 100644 --- a/packages/block-library/src/query-pagination/index.js +++ b/packages/block-library/src/query-pagination/index.js @@ -8,7 +8,6 @@ import { queryPagination as icon } from '@wordpress/icons'; */ import metadata from './block.json'; import edit from './edit'; -import save from './save'; const { name } = metadata; export { metadata, name }; @@ -16,5 +15,4 @@ export { metadata, name }; export const settings = { icon, edit, - save, }; diff --git a/packages/block-library/src/query-pagination/index.php b/packages/block-library/src/query-pagination/index.php index 636b6f9ea9345..53d958e3665dc 100644 --- a/packages/block-library/src/query-pagination/index.php +++ b/packages/block-library/src/query-pagination/index.php @@ -8,8 +8,8 @@ /** * Renders the `core/query-pagination` block on the server. * - * @param array $attributes Block attributes. - * @param string $content Block default content. + * @param array $attributes Block attributes. + * @param string $content Block default content. * * @return string Returns the wrapper for the Query pagination. */ diff --git a/packages/block-library/src/query-pagination/save.js b/packages/block-library/src/query-pagination/save.js deleted file mode 100644 index 873432fe65954..0000000000000 --- a/packages/block-library/src/query-pagination/save.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * WordPress dependencies - */ -import { InnerBlocks } from '@wordpress/block-editor'; - -export default function save() { - return ( - - ); -}