diff --git a/packages/block-library/src/query-pagination/deprecated.js b/packages/block-library/src/query-pagination/deprecated.js
new file mode 100644
index 00000000000000..5db43785412bb4
--- /dev/null
+++ b/packages/block-library/src/query-pagination/deprecated.js
@@ -0,0 +1,19 @@
+/**
+ * WordPress dependencies
+ */
+import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
+
+const deprecated = [
+ // Version with wrapper `div` element.
+ {
+ save() {
+ return (
+
+
+
+ );
+ },
+ },
+];
+
+export default deprecated;
diff --git a/packages/block-library/src/query-pagination/index.js b/packages/block-library/src/query-pagination/index.js
index a15bdd4389cee5..05124f3321b67b 100644
--- a/packages/block-library/src/query-pagination/index.js
+++ b/packages/block-library/src/query-pagination/index.js
@@ -9,6 +9,7 @@ import { queryPagination as icon } from '@wordpress/icons';
import metadata from './block.json';
import edit from './edit';
import save from './save';
+import deprecated from './deprecated';
const { name } = metadata;
export { metadata, name };
@@ -17,4 +18,5 @@ export const settings = {
icon,
edit,
save,
+ deprecated,
};
diff --git a/packages/block-library/src/query-pagination/index.php b/packages/block-library/src/query-pagination/index.php
index a9f31bf78fc4fe..ae32242bc9e49a 100644
--- a/packages/block-library/src/query-pagination/index.php
+++ b/packages/block-library/src/query-pagination/index.php
@@ -5,12 +5,35 @@
* @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 ) {
+ if ( empty( trim( $content ) ) ) {
+ return '';
+ }
+
+ return sprintf(
+ '%2$s
',
+ get_block_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 000acdcd4a6055..17571d8f30d2de 100644
--- a/packages/block-library/src/query-pagination/save.js
+++ b/packages/block-library/src/query-pagination/save.js
@@ -1,12 +1,8 @@
/**
* WordPress dependencies
*/
-import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
+import { InnerBlocks } from '@wordpress/block-editor';
export default function save() {
- return (
-
-
-
- );
+ return ;
}
diff --git a/test/integration/fixtures/blocks/core__query-pagination.html b/test/integration/fixtures/blocks/core__query-pagination.html
index c962c0346e6662..076f0ad1e83ff0 100644
--- a/test/integration/fixtures/blocks/core__query-pagination.html
+++ b/test/integration/fixtures/blocks/core__query-pagination.html
@@ -1,3 +1,2 @@
-
diff --git a/test/integration/fixtures/blocks/core__query-pagination.json b/test/integration/fixtures/blocks/core__query-pagination.json
index 9a5c156770fbf9..0ab0484c12785b 100644
--- a/test/integration/fixtures/blocks/core__query-pagination.json
+++ b/test/integration/fixtures/blocks/core__query-pagination.json
@@ -7,6 +7,6 @@
"paginationArrow": "none"
},
"innerBlocks": [],
- "originalContent": ""
+ "originalContent": ""
}
]
diff --git a/test/integration/fixtures/blocks/core__query-pagination.parsed.json b/test/integration/fixtures/blocks/core__query-pagination.parsed.json
index 60ec7f9aa9d732..831be0bc71a32c 100644
--- a/test/integration/fixtures/blocks/core__query-pagination.parsed.json
+++ b/test/integration/fixtures/blocks/core__query-pagination.parsed.json
@@ -3,9 +3,7 @@
"blockName": "core/query-pagination",
"attrs": {},
"innerBlocks": [],
- "innerHTML": "\n\n",
- "innerContent": [
- "\n\n"
- ]
+ "innerHTML": "\n",
+ "innerContent": [ "\n" ]
}
]
diff --git a/test/integration/fixtures/blocks/core__query-pagination.serialized.html b/test/integration/fixtures/blocks/core__query-pagination.serialized.html
index c962c0346e6662..912a9515fee7f9 100644
--- a/test/integration/fixtures/blocks/core__query-pagination.serialized.html
+++ b/test/integration/fixtures/blocks/core__query-pagination.serialized.html
@@ -1,3 +1 @@
-
-
-
+
diff --git a/test/integration/fixtures/blocks/core__query-pagination__deprecated.html b/test/integration/fixtures/blocks/core__query-pagination__deprecated.html
new file mode 100644
index 00000000000000..c962c0346e6662
--- /dev/null
+++ b/test/integration/fixtures/blocks/core__query-pagination__deprecated.html
@@ -0,0 +1,3 @@
+
+
+
diff --git a/test/integration/fixtures/blocks/core__query-pagination__deprecated.json b/test/integration/fixtures/blocks/core__query-pagination__deprecated.json
new file mode 100644
index 00000000000000..a5ade7819c893b
--- /dev/null
+++ b/test/integration/fixtures/blocks/core__query-pagination__deprecated.json
@@ -0,0 +1,10 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/query-pagination",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [],
+ "originalContent": ""
+ }
+]
diff --git a/test/integration/fixtures/blocks/core__query-pagination__deprecated.parsed.json b/test/integration/fixtures/blocks/core__query-pagination__deprecated.parsed.json
new file mode 100644
index 00000000000000..60ec7f9aa9d732
--- /dev/null
+++ b/test/integration/fixtures/blocks/core__query-pagination__deprecated.parsed.json
@@ -0,0 +1,11 @@
+[
+ {
+ "blockName": "core/query-pagination",
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "\n\n",
+ "innerContent": [
+ "\n\n"
+ ]
+ }
+]
diff --git a/test/integration/fixtures/blocks/core__query-pagination__deprecated.serialized.html b/test/integration/fixtures/blocks/core__query-pagination__deprecated.serialized.html
new file mode 100644
index 00000000000000..912a9515fee7f9
--- /dev/null
+++ b/test/integration/fixtures/blocks/core__query-pagination__deprecated.serialized.html
@@ -0,0 +1 @@
+