Skip to content

Commit

Permalink
avoid printing class if is a value is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Nov 29, 2021
1 parent dde160d commit cadb2a6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ 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 = 'wp-justify-' . $used_layout['justifyContent'];
$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 . $justify_class,
$block_content,
1
);
Expand Down

0 comments on commit cadb2a6

Please sign in to comment.