Skip to content

Commit

Permalink
Avoids polluting Layout functionality with Query Pagination specific …
Browse files Browse the repository at this point in the history
…requirements.

This characteristic was introduced here: WordPress#36681 and currently it is only necesary for the Query Pagination block so we can move the functionality to the block's code to avoid adding extra logic to the Layout block support.
  • Loading branch information
matiasbenedetto committed Dec 3, 2021
1 parent d7d2484 commit b19c779
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,11 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
$id = uniqid();
$style = gutenberg_get_layout_style( ".wp-container-$id", $used_layout, $has_block_gap_support );
$container_class = 'wp-container-' . $id . ' ';
$justify_class = $used_layout['justifyContent'] ? 'wp-justify-' . $used_layout['justifyContent'] . ' ' : '';
// This assumes the hook only applies to blocks with a single wrapper.
// I think this is a reasonable limitation for that particular hook.
$content = preg_replace(
'/' . preg_quote( 'class="', '/' ) . '/',
'class="' . $container_class . $justify_class,
'class="' . $container_class,
$block_content,
1
);
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/query-pagination/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ function render_block_core_query_pagination( $attributes, $content ) {
return '';
}

$justifyContent = $attributes['layout']['justifyContent'];
$justify_class = $justifyContent ? 'wp-justify-' . $justifyContent : '';

return sprintf(
'<div %1$s>%2$s</div>',
get_block_wrapper_attributes(),
get_block_wrapper_attributes( array( 'class' => $justify_class ) ),
$content
);
}
Expand Down

0 comments on commit b19c779

Please sign in to comment.