From 2057de333b57af78b1d7f70c6ba182a4ed911f23 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Mon, 23 Jan 2023 15:10:32 +0100 Subject: [PATCH 01/12] Add missing has-link-color class to the front --- packages/block-library/src/latest-posts/index.php | 4 ++++ packages/block-library/src/post-author/index.php | 3 ++- packages/block-library/src/post-terms/index.php | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index 18168ba37bce84..efafc6fcd8705b 100644 --- a/packages/block-library/src/latest-posts/index.php +++ b/packages/block-library/src/latest-posts/index.php @@ -191,6 +191,10 @@ function render_block_core_latest_posts( $attributes ) { $class .= ' has-author'; } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $class .= ' has-link-color'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) ); return sprintf( diff --git a/packages/block-library/src/post-author/index.php b/packages/block-library/src/post-author/index.php index 49890067c0eb99..1d6d59e53516b3 100644 --- a/packages/block-library/src/post-author/index.php +++ b/packages/block-library/src/post-author/index.php @@ -38,7 +38,8 @@ function render_block_core_post_author( $attributes, $content, $block ) { $byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false; $classes = array_merge( isset( $attributes['itemsJustification'] ) ? array( 'items-justified-' . $attributes['itemsJustification'] ) : array(), - isset( $attributes['textAlign'] ) ? array( 'has-text-align-' . $attributes['textAlign'] ) : array() + isset( $attributes['textAlign'] ) ? array( 'has-text-align-' . $attributes['textAlign'] ) : array(), + isset( $attributes['style']['elements']['link']['color']['text'] ) ? array( 'has-link-color' ) : array() ); $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index f98baba65ec639..06dd983dd9fcf1 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -32,6 +32,10 @@ function render_block_core_post_terms( $attributes, $content, $block ) { $classes .= ' has-text-align-' . $attributes['textAlign']; } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } + $separator = empty( $attributes['separator'] ) ? ' ' : $attributes['separator']; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); From ee07a81dfc2b5b81c29173003402b3b3b55bff9e Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 24 Jan 2023 07:25:46 +0100 Subject: [PATCH 02/12] Add has-link-color to calendar block --- packages/block-library/src/calendar/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/calendar/index.php b/packages/block-library/src/calendar/index.php index 01d2b7eb8ad91b..de82ba22f7a994 100644 --- a/packages/block-library/src/calendar/index.php +++ b/packages/block-library/src/calendar/index.php @@ -56,7 +56,9 @@ function render_block_core_calendar( $attributes ) { $styles = gutenberg_style_engine_get_styles( array( 'color' => $color_block_styles ), array( 'convert_vars_to_classnames' => true ) ); $inline_styles = empty( $styles['css'] ) ? '' : sprintf( ' style="%s"', esc_attr( $styles['css'] ) ); $classnames = empty( $styles['classnames'] ) ? '' : ' ' . esc_attr( $styles['classnames'] ); - + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classnames .= ' has-link-color'; + } // Apply color classes and styles to the calendar. $calendar = str_replace( ' Date: Tue, 24 Jan 2023 08:23:11 +0100 Subject: [PATCH 03/12] Add has-link-color class to comment blocks --- packages/block-library/src/comment-author-name/index.php | 3 +++ packages/block-library/src/comment-content/index.php | 3 +++ packages/block-library/src/comment-date/index.php | 3 +++ packages/block-library/src/comment-edit-link/index.php | 3 +++ packages/block-library/src/comment-reply-link/index.php | 3 +++ packages/block-library/src/comments-pagination/index.php | 9 ++++++++- packages/block-library/src/post-comments-form/index.php | 4 +++- packages/block-library/src/post-comments-link/index.php | 8 ++++++-- 8 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/comment-author-name/index.php b/packages/block-library/src/comment-author-name/index.php index 04d8e60c65e8ca..5933da06c986c8 100644 --- a/packages/block-library/src/comment-author-name/index.php +++ b/packages/block-library/src/comment-author-name/index.php @@ -29,6 +29,9 @@ function render_block_core_comment_author_name( $attributes, $content, $block ) if ( isset( $attributes['textAlign'] ) ) { $classes .= 'has-text-align-' . $attributes['textAlign']; } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); $comment_author = get_comment_author( $comment ); diff --git a/packages/block-library/src/comment-content/index.php b/packages/block-library/src/comment-content/index.php index 90ba060b44dfa7..fac12917f60b94 100644 --- a/packages/block-library/src/comment-content/index.php +++ b/packages/block-library/src/comment-content/index.php @@ -53,6 +53,9 @@ function render_block_core_comment_content( $attributes, $content, $block ) { if ( isset( $attributes['textAlign'] ) ) { $classes .= 'has-text-align-' . $attributes['textAlign']; } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); diff --git a/packages/block-library/src/comment-date/index.php b/packages/block-library/src/comment-date/index.php index 9bff9f2f6cbbfb..6473bc3508a012 100644 --- a/packages/block-library/src/comment-date/index.php +++ b/packages/block-library/src/comment-date/index.php @@ -24,6 +24,9 @@ function render_block_core_comment_date( $attributes, $content, $block ) { } $classes = ''; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); $formatted_date = get_comment_date( diff --git a/packages/block-library/src/comment-edit-link/index.php b/packages/block-library/src/comment-edit-link/index.php index 39727ea5aed109..9370d9930a77e2 100644 --- a/packages/block-library/src/comment-edit-link/index.php +++ b/packages/block-library/src/comment-edit-link/index.php @@ -31,6 +31,9 @@ function render_block_core_comment_edit_link( $attributes, $content, $block ) { if ( isset( $attributes['textAlign'] ) ) { $classes .= 'has-text-align-' . $attributes['textAlign']; } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); diff --git a/packages/block-library/src/comment-reply-link/index.php b/packages/block-library/src/comment-reply-link/index.php index 5b9bf1068fb21a..18761b30071df2 100644 --- a/packages/block-library/src/comment-reply-link/index.php +++ b/packages/block-library/src/comment-reply-link/index.php @@ -55,6 +55,9 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) { if ( isset( $attributes['textAlign'] ) ) { $classes .= 'has-text-align-' . $attributes['textAlign']; } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); diff --git a/packages/block-library/src/comments-pagination/index.php b/packages/block-library/src/comments-pagination/index.php index 5c041c237c64fb..e9453eebc903eb 100644 --- a/packages/block-library/src/comments-pagination/index.php +++ b/packages/block-library/src/comments-pagination/index.php @@ -22,9 +22,16 @@ function render_block_core_comments_pagination( $attributes, $content ) { return; } + $classes = ''; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } + + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + return sprintf( '
%2$s
', - get_block_wrapper_attributes(), + $wrapper_attributes, $content ); } diff --git a/packages/block-library/src/post-comments-form/index.php b/packages/block-library/src/post-comments-form/index.php index 53a6f8b5242a90..4ea3dfda0d3f3f 100644 --- a/packages/block-library/src/post-comments-form/index.php +++ b/packages/block-library/src/post-comments-form/index.php @@ -26,7 +26,9 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) { if ( isset( $attributes['textAlign'] ) ) { $classes .= ' has-text-align-' . $attributes['textAlign']; } - + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' ); diff --git a/packages/block-library/src/post-comments-link/index.php b/packages/block-library/src/post-comments-link/index.php index d2460497e74404..d4ce4299a8ebfb 100644 --- a/packages/block-library/src/post-comments-link/index.php +++ b/packages/block-library/src/post-comments-link/index.php @@ -22,8 +22,12 @@ function render_block_core_post_comments_link( $attributes, $content, $block ) { return ''; } - $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $comments_number = (int) get_comments_number( $block->context['postId'] ); $comments_link = get_comments_link( $block->context['postId'] ); $post_title = get_the_title( $block->context['postId'] ); From 70477dcdb482b10cd331590d9303970d87e9a2ff Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 24 Jan 2023 09:42:12 +0100 Subject: [PATCH 04/12] Update a few more blocks --- packages/block-library/src/post-author-name/index.php | 11 ++++++----- .../block-library/src/post-comments-link/index.php | 1 - packages/block-library/src/post-excerpt/index.php | 3 +++ packages/block-library/src/post-template/index.php | 3 +++ packages/block-library/src/post-title/index.php | 7 +++++-- packages/block-library/src/query-no-results/index.php | 7 ++++++- packages/block-library/src/query-pagination/index.php | 5 +++++ 7 files changed, 28 insertions(+), 9 deletions(-) diff --git a/packages/block-library/src/post-author-name/index.php b/packages/block-library/src/post-author-name/index.php index 08496d3e963bff..7344f608ee17a8 100644 --- a/packages/block-library/src/post-author-name/index.php +++ b/packages/block-library/src/post-author-name/index.php @@ -23,14 +23,15 @@ function render_block_core_post_author_name( $attributes, $content, $block ) { return ''; } - $author_name = get_the_author_meta( 'display_name', $author_id ); - $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; - + $author_name = get_the_author_meta( 'display_name', $author_id ); + $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { $author_name = sprintf( '', get_author_posts_url( $author_id ), esc_attr( $attributes['linkTarget'] ), $author_name ); } - - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( '
%2$s
', $wrapper_attributes, $author_name ); } diff --git a/packages/block-library/src/post-comments-link/index.php b/packages/block-library/src/post-comments-link/index.php index d4ce4299a8ebfb..1dbae13a8a0d9a 100644 --- a/packages/block-library/src/post-comments-link/index.php +++ b/packages/block-library/src/post-comments-link/index.php @@ -27,7 +27,6 @@ function render_block_core_post_comments_link( $attributes, $content, $block ) { $classes .= ' has-link-color'; } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); - $comments_number = (int) get_comments_number( $block->context['postId'] ); $comments_link = get_comments_link( $block->context['postId'] ); $post_title = get_the_title( $block->context['postId'] ); diff --git a/packages/block-library/src/post-excerpt/index.php b/packages/block-library/src/post-excerpt/index.php index 79cc959cd86d7e..87b9aadf26f00f 100644 --- a/packages/block-library/src/post-excerpt/index.php +++ b/packages/block-library/src/post-excerpt/index.php @@ -42,6 +42,9 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) { if ( isset( $attributes['textAlign'] ) ) { $classes .= "has-text-align-{$attributes['textAlign']}"; } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); $content = '

' . $excerpt; diff --git a/packages/block-library/src/post-template/index.php b/packages/block-library/src/post-template/index.php index c12a0e68b8e248..eff93a434ef60d 100644 --- a/packages/block-library/src/post-template/index.php +++ b/packages/block-library/src/post-template/index.php @@ -68,6 +68,9 @@ function render_block_core_post_template( $attributes, $content, $block ) { $classnames = "is-flex-container columns-{$block->context['displayLayout']['columns']}"; } } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classnames .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) ); diff --git a/packages/block-library/src/post-title/index.php b/packages/block-library/src/post-title/index.php index 125a2d81ddcbe3..a8a0afa18161b3 100644 --- a/packages/block-library/src/post-title/index.php +++ b/packages/block-library/src/post-title/index.php @@ -27,7 +27,7 @@ function render_block_core_post_title( $attributes, $content, $block ) { } $tag_name = 'h2'; - $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; if ( isset( $attributes['level'] ) ) { $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . $attributes['level']; @@ -37,7 +37,10 @@ function render_block_core_post_title( $attributes, $content, $block ) { $rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : ''; $title = sprintf( '%4$s', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), $rel, $title ); } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( '<%1$s %2$s>%3$s', diff --git a/packages/block-library/src/query-no-results/index.php b/packages/block-library/src/query-no-results/index.php index 6d4dad48f49e00..edb322838dd1be 100644 --- a/packages/block-library/src/query-no-results/index.php +++ b/packages/block-library/src/query-no-results/index.php @@ -40,9 +40,14 @@ function render_block_core_query_no_results( $attributes, $content, $block ) { wp_reset_postdata(); } + $classes = ''; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( '

%2$s
', - get_block_wrapper_attributes(), + $wrapper_attributes, $content ); } diff --git a/packages/block-library/src/query-pagination/index.php b/packages/block-library/src/query-pagination/index.php index eaa784be08e7d6..a4b23877b75b70 100644 --- a/packages/block-library/src/query-pagination/index.php +++ b/packages/block-library/src/query-pagination/index.php @@ -18,9 +18,14 @@ function render_block_core_query_pagination( $attributes, $content ) { return ''; } + $classes = ''; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'aria-label' => __( 'Pagination' ), + 'class' => $classes, ) ); From 605d4a3118d3e41ff0239df8cb39e22c7a032a7d Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 24 Jan 2023 10:00:49 +0100 Subject: [PATCH 05/12] CS fixes, add more blocks --- packages/block-library/src/post-date/index.php | 9 ++++++--- packages/block-library/src/post-title/index.php | 4 ++-- packages/block-library/src/site-title/index.php | 9 ++++++--- packages/block-library/src/term-description/index.php | 9 +++++---- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/block-library/src/post-date/index.php b/packages/block-library/src/post-date/index.php index fc1537d1566896..ff0a5362191d8c 100644 --- a/packages/block-library/src/post-date/index.php +++ b/packages/block-library/src/post-date/index.php @@ -18,9 +18,12 @@ function render_block_core_post_date( $attributes, $content, $block ) { return ''; } - $post_ID = $block->context['postId']; - $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $post_ID = $block->context['postId']; + $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) { $formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID ); diff --git a/packages/block-library/src/post-title/index.php b/packages/block-library/src/post-title/index.php index a8a0afa18161b3..54e37ee4133b99 100644 --- a/packages/block-library/src/post-title/index.php +++ b/packages/block-library/src/post-title/index.php @@ -26,8 +26,8 @@ function render_block_core_post_title( $attributes, $content, $block ) { return ''; } - $tag_name = 'h2'; - $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + $tag_name = 'h2'; + $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; if ( isset( $attributes['level'] ) ) { $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . $attributes['level']; diff --git a/packages/block-library/src/site-title/index.php b/packages/block-library/src/site-title/index.php index 3c3e4d86692387..d26ef8bb79f6ec 100644 --- a/packages/block-library/src/site-title/index.php +++ b/packages/block-library/src/site-title/index.php @@ -18,8 +18,11 @@ function render_block_core_site_title( $attributes ) { return; } - $tag_name = 'h1'; - $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + $tag_name = 'h1'; + $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } if ( isset( $attributes['level'] ) ) { $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . (int) $attributes['level']; @@ -37,7 +40,7 @@ function render_block_core_site_title( $attributes ) { esc_html( $site_title ) ); } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( '<%1$s %2$s>%3$s', diff --git a/packages/block-library/src/term-description/index.php b/packages/block-library/src/term-description/index.php index 4f1cd7e518d110..04f8946ce1c509 100644 --- a/packages/block-library/src/term-description/index.php +++ b/packages/block-library/src/term-description/index.php @@ -23,10 +23,11 @@ function render_block_core_term_description( $attributes ) { return ''; } - $extra_attributes = ( isset( $attributes['textAlign'] ) ) - ? array( 'class' => 'has-text-align-' . $attributes['textAlign'] ) - : array(); - $wrapper_attributes = get_block_wrapper_attributes( $extra_attributes ); + $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes .= ' has-link-color'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return '
' . $term_description . '
'; } From 717d98244de15ad590688b50aaf8ec7673355d85 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 24 Jan 2023 11:09:10 +0100 Subject: [PATCH 06/12] Remove the extra space from the single class names --- packages/block-library/src/comment-date/index.php | 5 +---- packages/block-library/src/comments-pagination/index.php | 6 +----- packages/block-library/src/query-no-results/index.php | 5 +---- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/comment-date/index.php b/packages/block-library/src/comment-date/index.php index 6473bc3508a012..0f9c18bf2c0068 100644 --- a/packages/block-library/src/comment-date/index.php +++ b/packages/block-library/src/comment-date/index.php @@ -23,10 +23,7 @@ function render_block_core_comment_date( $attributes, $content, $block ) { return ''; } - $classes = ''; - if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; - } + $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : ''; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); $formatted_date = get_comment_date( diff --git a/packages/block-library/src/comments-pagination/index.php b/packages/block-library/src/comments-pagination/index.php index e9453eebc903eb..78e5d9c052ed9e 100644 --- a/packages/block-library/src/comments-pagination/index.php +++ b/packages/block-library/src/comments-pagination/index.php @@ -22,11 +22,7 @@ function render_block_core_comments_pagination( $attributes, $content ) { return; } - $classes = ''; - if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; - } - + $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : ''; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( diff --git a/packages/block-library/src/query-no-results/index.php b/packages/block-library/src/query-no-results/index.php index edb322838dd1be..faadf6f2f60936 100644 --- a/packages/block-library/src/query-no-results/index.php +++ b/packages/block-library/src/query-no-results/index.php @@ -40,10 +40,7 @@ function render_block_core_query_no_results( $attributes, $content, $block ) { wp_reset_postdata(); } - $classes = ''; - if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; - } + $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : ''; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( '
%2$s
', From 4432a3e613d443c5f7bcf6988748b02f19211bc7 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 24 Jan 2023 11:22:25 +0100 Subject: [PATCH 07/12] CS fixes --- packages/block-library/src/query-no-results/index.php | 2 +- packages/block-library/src/query-pagination/index.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/query-no-results/index.php b/packages/block-library/src/query-no-results/index.php index faadf6f2f60936..4342ba57cccbd7 100644 --- a/packages/block-library/src/query-no-results/index.php +++ b/packages/block-library/src/query-no-results/index.php @@ -40,7 +40,7 @@ function render_block_core_query_no_results( $attributes, $content, $block ) { wp_reset_postdata(); } - $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : ''; + $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : ''; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( '
%2$s
', diff --git a/packages/block-library/src/query-pagination/index.php b/packages/block-library/src/query-pagination/index.php index a4b23877b75b70..9b7289ec22e0fa 100644 --- a/packages/block-library/src/query-pagination/index.php +++ b/packages/block-library/src/query-pagination/index.php @@ -18,10 +18,7 @@ function render_block_core_query_pagination( $attributes, $content ) { return ''; } - $classes = ''; - if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; - } + $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : ''; $wrapper_attributes = get_block_wrapper_attributes( array( 'aria-label' => __( 'Pagination' ), From 866906625e4980d7e3c0d0b774dc66d10857dc05 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 24 Jan 2023 13:59:12 +0100 Subject: [PATCH 08/12] Remove extra spaces --- .../src/comment-author-name/index.php | 8 ++++---- .../src/comment-content/index.php | 8 ++++---- .../src/comment-edit-link/index.php | 8 ++++---- .../src/comment-reply-link/index.php | 8 ++++---- .../src/comments-pagination/index.php | 2 +- .../block-library/src/latest-posts/index.php | 19 +++++++------------ .../src/post-author-name/index.php | 14 +++++++++----- .../src/post-comments-form/index.php | 8 ++++---- .../src/post-comments-link/index.php | 9 ++++++--- .../block-library/src/post-date/index.php | 10 +++++++--- .../block-library/src/post-excerpt/index.php | 8 ++++---- .../block-library/src/post-terms/index.php | 9 ++++----- 12 files changed, 58 insertions(+), 53 deletions(-) diff --git a/packages/block-library/src/comment-author-name/index.php b/packages/block-library/src/comment-author-name/index.php index 5933da06c986c8..d3cd68c0dfbfc6 100644 --- a/packages/block-library/src/comment-author-name/index.php +++ b/packages/block-library/src/comment-author-name/index.php @@ -25,15 +25,15 @@ function render_block_core_comment_author_name( $attributes, $content, $block ) return ''; } - $classes = ''; + $classes = array(); if ( isset( $attributes['textAlign'] ) ) { - $classes .= 'has-text-align-' . $attributes['textAlign']; + $classes[] = 'has-text-align-' . $attributes['textAlign']; } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); $comment_author = get_comment_author( $comment ); $link = get_comment_author_url( $comment ); diff --git a/packages/block-library/src/comment-content/index.php b/packages/block-library/src/comment-content/index.php index fac12917f60b94..50bca402acf034 100644 --- a/packages/block-library/src/comment-content/index.php +++ b/packages/block-library/src/comment-content/index.php @@ -49,15 +49,15 @@ function render_block_core_comment_content( $attributes, $content, $block ) { } } - $classes = ''; + $classes = array(); if ( isset( $attributes['textAlign'] ) ) { - $classes .= 'has-text-align-' . $attributes['textAlign']; + $classes[] = 'has-text-align-' . $attributes['textAlign']; } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); return sprintf( '
%2$s%3$s
', diff --git a/packages/block-library/src/comment-edit-link/index.php b/packages/block-library/src/comment-edit-link/index.php index 9370d9930a77e2..ce7ad9bf207d43 100644 --- a/packages/block-library/src/comment-edit-link/index.php +++ b/packages/block-library/src/comment-edit-link/index.php @@ -27,15 +27,15 @@ function render_block_core_comment_edit_link( $attributes, $content, $block ) { $link_atts .= sprintf( 'target="%s"', esc_attr( $attributes['linkTarget'] ) ); } - $classes = ''; + $classes = array(); if ( isset( $attributes['textAlign'] ) ) { - $classes .= 'has-text-align-' . $attributes['textAlign']; + $classes[] = 'has-text-align-' . $attributes['textAlign']; } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); return sprintf( '', diff --git a/packages/block-library/src/comment-reply-link/index.php b/packages/block-library/src/comment-reply-link/index.php index 18761b30071df2..3f7b6e48b617c8 100644 --- a/packages/block-library/src/comment-reply-link/index.php +++ b/packages/block-library/src/comment-reply-link/index.php @@ -51,15 +51,15 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) { return; } - $classes = ''; + $classes = array(); if ( isset( $attributes['textAlign'] ) ) { - $classes .= 'has-text-align-' . $attributes['textAlign']; + $classes[] = 'has-text-align-' . $attributes['textAlign']; } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); return sprintf( '
%2$s
', diff --git a/packages/block-library/src/comments-pagination/index.php b/packages/block-library/src/comments-pagination/index.php index 78e5d9c052ed9e..2f9cef27f78cf6 100644 --- a/packages/block-library/src/comments-pagination/index.php +++ b/packages/block-library/src/comments-pagination/index.php @@ -22,7 +22,7 @@ function render_block_core_comments_pagination( $attributes, $content ) { return; } - $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : ''; + $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : ''; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index efafc6fcd8705b..d3945ee2c9ee2f 100644 --- a/packages/block-library/src/latest-posts/index.php +++ b/packages/block-library/src/latest-posts/index.php @@ -173,29 +173,24 @@ function render_block_core_latest_posts( $attributes ) { remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 ); - $class = 'wp-block-latest-posts__list'; - + $classes = array( 'wp-block-latest-posts__list' ); if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) { - $class .= ' is-grid'; + $classes[] = 'is-grid'; } - if ( isset( $attributes['columns'] ) && 'grid' === $attributes['postLayout'] ) { - $class .= ' columns-' . $attributes['columns']; + $classes[] = 'columns-' . $attributes['columns']; } - if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { - $class .= ' has-dates'; + $classes[] = 'has-dates'; } - if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) { - $class .= ' has-author'; + $classes[] = 'has-author'; } - if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $class .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); return sprintf( '
    %2$s
', diff --git a/packages/block-library/src/post-author-name/index.php b/packages/block-library/src/post-author-name/index.php index 7344f608ee17a8..c5c6d142e06ddf 100644 --- a/packages/block-library/src/post-author-name/index.php +++ b/packages/block-library/src/post-author-name/index.php @@ -24,14 +24,18 @@ function render_block_core_post_author_name( $attributes, $content, $block ) { } $author_name = get_the_author_meta( 'display_name', $author_id ); - $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; - if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; - } if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { $author_name = sprintf( '', get_author_posts_url( $author_id ), esc_attr( $attributes['linkTarget'] ), $author_name ); } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + + $classes = array(); + if ( isset( $attributes['textAlign'] ) ) { + $classes[] = 'has-text-align-' . $attributes['textAlign']; + } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes[] = 'has-link-color'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); return sprintf( '
%2$s
', $wrapper_attributes, $author_name ); } diff --git a/packages/block-library/src/post-comments-form/index.php b/packages/block-library/src/post-comments-form/index.php index 4ea3dfda0d3f3f..644b02ae0f1498 100644 --- a/packages/block-library/src/post-comments-form/index.php +++ b/packages/block-library/src/post-comments-form/index.php @@ -22,14 +22,14 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) { return; } - $classes = 'comment-respond'; // See comment further below. + $classes = array( 'comment-respond' ); // See comment further below. if ( isset( $attributes['textAlign'] ) ) { - $classes .= ' has-text-align-' . $attributes['textAlign']; + $classes[] = 'has-text-align-' . $attributes['textAlign']; } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' ); diff --git a/packages/block-library/src/post-comments-link/index.php b/packages/block-library/src/post-comments-link/index.php index 1dbae13a8a0d9a..2742a037fafb16 100644 --- a/packages/block-library/src/post-comments-link/index.php +++ b/packages/block-library/src/post-comments-link/index.php @@ -22,11 +22,14 @@ function render_block_core_post_comments_link( $attributes, $content, $block ) { return ''; } - $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + $classes = array(); + if ( isset( $attributes['textAlign'] ) ) { + $classes[] = 'has-text-align-' . $attributes['textAlign']; + } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); $comments_number = (int) get_comments_number( $block->context['postId'] ); $comments_link = get_comments_link( $block->context['postId'] ); $post_title = get_the_title( $block->context['postId'] ); diff --git a/packages/block-library/src/post-date/index.php b/packages/block-library/src/post-date/index.php index ff0a5362191d8c..5c20ee30c2b398 100644 --- a/packages/block-library/src/post-date/index.php +++ b/packages/block-library/src/post-date/index.php @@ -19,11 +19,15 @@ function render_block_core_post_date( $attributes, $content, $block ) { } $post_ID = $block->context['postId']; - $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + + $classes = array(); + if ( isset( $attributes['textAlign'] ) ) { + $classes[] = 'has-text-align-' . $attributes['textAlign']; + } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) { $formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID ); diff --git a/packages/block-library/src/post-excerpt/index.php b/packages/block-library/src/post-excerpt/index.php index 87b9aadf26f00f..1380918fe10583 100644 --- a/packages/block-library/src/post-excerpt/index.php +++ b/packages/block-library/src/post-excerpt/index.php @@ -38,14 +38,14 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) { * result in showing only one `read more` link at a time. */ add_filter( 'excerpt_more', $filter_excerpt_more ); - $classes = ''; + $classes = array(); if ( isset( $attributes['textAlign'] ) ) { - $classes .= "has-text-align-{$attributes['textAlign']}"; + $classes[] = 'has-text-align-' . $attributes['textAlign']; } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); $content = '

' . $excerpt; $show_more_on_new_line = ! isset( $attributes['showMoreOnNewLine'] ) || $attributes['showMoreOnNewLine']; diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index 06dd983dd9fcf1..5511dd2f8e8859 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -27,18 +27,17 @@ function render_block_core_post_terms( $attributes, $content, $block ) { return ''; } - $classes = 'taxonomy-' . $attributes['term']; + $classes = array( 'taxonomy-' . $attributes['term'] ); if ( isset( $attributes['textAlign'] ) ) { - $classes .= ' has-text-align-' . $attributes['textAlign']; + $classes[] = 'has-text-align-' . $attributes['textAlign']; } - if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } $separator = empty( $attributes['separator'] ) ? ' ' : $attributes['separator']; - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); $prefix = "

"; if ( isset( $attributes['prefix'] ) && $attributes['prefix'] ) { From 9ddde0289c4b35e187ad81a81f2ccc66253ee73a Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 24 Jan 2023 14:03:11 +0100 Subject: [PATCH 09/12] Remove extra spaces. --- packages/block-library/src/post-title/index.php | 11 +++++++---- packages/block-library/src/term-description/index.php | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/block-library/src/post-title/index.php b/packages/block-library/src/post-title/index.php index 54e37ee4133b99..1f03b12fc2b46c 100644 --- a/packages/block-library/src/post-title/index.php +++ b/packages/block-library/src/post-title/index.php @@ -27,8 +27,6 @@ function render_block_core_post_title( $attributes, $content, $block ) { } $tag_name = 'h2'; - $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; - if ( isset( $attributes['level'] ) ) { $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . $attributes['level']; } @@ -37,10 +35,15 @@ function render_block_core_post_title( $attributes, $content, $block ) { $rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : ''; $title = sprintf( '%4$s', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), $rel, $title ); } + + $classes = array(); + if ( isset( $attributes['textAlign'] ) ) { + $classes[] = 'has-text-align-' . $attributes['textAlign']; + } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); return sprintf( '<%1$s %2$s>%3$s', diff --git a/packages/block-library/src/term-description/index.php b/packages/block-library/src/term-description/index.php index 04f8946ce1c509..011ec28f2e5e63 100644 --- a/packages/block-library/src/term-description/index.php +++ b/packages/block-library/src/term-description/index.php @@ -23,11 +23,14 @@ function render_block_core_term_description( $attributes ) { return ''; } - $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + $classes = array(); + if ( isset( $attributes['textAlign'] ) ) { + $classes[] = 'has-text-align-' . $attributes['textAlign']; + } if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { - $classes .= ' has-link-color'; + $classes[] = 'has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); return '
' . $term_description . '
'; } From 2a67eafeb2c0d283b449e86d14d7df420185a26c Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 24 Jan 2023 14:06:12 +0100 Subject: [PATCH 10/12] CS fix, remove space --- packages/block-library/src/post-comments-link/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/post-comments-link/index.php b/packages/block-library/src/post-comments-link/index.php index 2742a037fafb16..a8092190086a76 100644 --- a/packages/block-library/src/post-comments-link/index.php +++ b/packages/block-library/src/post-comments-link/index.php @@ -22,7 +22,7 @@ function render_block_core_post_comments_link( $attributes, $content, $block ) { return ''; } - $classes = array(); + $classes = array(); if ( isset( $attributes['textAlign'] ) ) { $classes[] = 'has-text-align-' . $attributes['textAlign']; } From a763205e23e519cc4b086345b2ce19d0316fec2c Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Wed, 25 Jan 2023 10:01:32 +0200 Subject: [PATCH 11/12] Avoid the use of array_merge when not needed --- packages/block-library/src/post-author/index.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/post-author/index.php b/packages/block-library/src/post-author/index.php index 1d6d59e53516b3..7e6a9e6a0bd852 100644 --- a/packages/block-library/src/post-author/index.php +++ b/packages/block-library/src/post-author/index.php @@ -36,11 +36,16 @@ function render_block_core_post_author( $attributes, $content, $block ) { } $byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false; - $classes = array_merge( - isset( $attributes['itemsJustification'] ) ? array( 'items-justified-' . $attributes['itemsJustification'] ) : array(), - isset( $attributes['textAlign'] ) ? array( 'has-text-align-' . $attributes['textAlign'] ) : array(), - isset( $attributes['style']['elements']['link']['color']['text'] ) ? array( 'has-link-color' ) : array() - ); + $classes = array(); + if ( isset( $attributes['itemsJustification'] ) ) { + $classes[] = 'items-justified-' . $attributes['itemsJustification']; + } + if ( isset( $attributes['textAlign'] ) ) { + $classes[] = 'has-text-align-' . $attributes['textAlign']; + } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes[] = 'has-link-color'; + } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); From 30771d9a3f543039e97f20a6960b9f4e46a54854 Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Wed, 25 Jan 2023 10:06:26 +0200 Subject: [PATCH 12/12] trim the classnames --- packages/block-library/src/post-template/index.php | 2 +- packages/block-library/src/site-title/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/post-template/index.php b/packages/block-library/src/post-template/index.php index eff93a434ef60d..3a3c207cf92ee2 100644 --- a/packages/block-library/src/post-template/index.php +++ b/packages/block-library/src/post-template/index.php @@ -72,7 +72,7 @@ function render_block_core_post_template( $attributes, $content, $block ) { $classnames .= ' has-link-color'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classnames ) ) ); $content = ''; while ( $query->have_posts() ) { diff --git a/packages/block-library/src/site-title/index.php b/packages/block-library/src/site-title/index.php index d26ef8bb79f6ec..255615b3a4e450 100644 --- a/packages/block-library/src/site-title/index.php +++ b/packages/block-library/src/site-title/index.php @@ -40,7 +40,7 @@ function render_block_core_site_title( $attributes ) { esc_html( $site_title ) ); } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classes ) ) ); return sprintf( '<%1$s %2$s>%3$s',