Skip to content

Commit

Permalink
Add a render callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jffng authored and scruffian committed Aug 12, 2021
1 parent 0be70f3 commit 5b3c034
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
26 changes: 25 additions & 1 deletion packages/block-library/src/query-pagination/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<div %1$s>%2$s</div>',
$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' );
6 changes: 2 additions & 4 deletions packages/block-library/src/query-pagination/save.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/**
* WordPress dependencies
*/
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import { InnerBlocks } from '@wordpress/block-editor';

export default function save() {
return (
<div { ...useBlockProps.save() }>
<InnerBlocks.Content />
</div>
<InnerBlocks.Content />
);
}

0 comments on commit 5b3c034

Please sign in to comment.