diff --git a/lib/class-wp-block-supports.php b/lib/class-wp-block-supports.php index 8a65dc74640749..031312a45fd8e4 100644 --- a/lib/class-wp-block-supports.php +++ b/lib/class-wp-block-supports.php @@ -67,14 +67,12 @@ public function register( $block_support_name, $block_support_config ) { * Generates an array of HTML attributes, such as classes, by applying to * the given block all of the features that the block supports. * - * @param array $parsed_block Block as parsed from content. + * @param string $block_name The name of the block to be processed. + * @param array $block_attributes The attributes of the block to be processed. * @return array Array of HTML attributes. */ - public function apply_block_supports( $parsed_block ) { - $block_attributes = $parsed_block['attrs']; - $block_type = WP_Block_Type_Registry::get_instance()->get_registered( - $parsed_block['blockName'] - ); + public function apply_block_supports( $block_name, $block_attributes ) { + $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_name ); // If no render_callback, assume styles have been previously handled. if ( ! $block_type || empty( $block_type ) ) { @@ -139,13 +137,14 @@ private function register_attributes() { * Generates a string of attributes by applying to the current block being * rendered all of the features that the block supports. * - * @param array $extra_attributes Optional. Extra attributes to render on the block wrapper. + * @param string $block_name The name of the block to be processed. + * @param array $block_attributes The attributes of the block to be processed. + * @param array $extra_attributes Optional. Extra attributes to render on the block wrapper. * * @return string String of HTML classes. */ -function get_block_wrapper_attributes( $extra_attributes = array() ) { - global $current_parsed_block; - $new_attributes = WP_Block_Supports::get_instance()->apply_block_supports( $current_parsed_block ); +function get_block_wrapper_attributes( $block_name, $block_attributes, $extra_attributes = array() ) { + $new_attributes = WP_Block_Supports::get_instance()->apply_block_supports( $block_name, $block_attributes ); if ( empty( $new_attributes ) && empty( $extra_attributes ) ) { return ''; diff --git a/lib/class-wp-block.php b/lib/class-wp-block.php index d7788c1d614dc5..cd029050745660 100644 --- a/lib/class-wp-block.php +++ b/lib/class-wp-block.php @@ -203,7 +203,6 @@ public function __get( $name ) { */ public function render( $options = array() ) { global $post; - global $current_parsed_block; $options = array_replace( array( 'dynamic' => true, @@ -217,14 +216,9 @@ public function render( $options = array() ) { if ( ! $options['dynamic'] || empty( $this->block_type->skip_inner_blocks ) ) { $index = 0; foreach ( $this->inner_content as $chunk ) { - if ( is_string( $chunk ) ) { - $block_content .= $chunk; - } else { - $parent_parsed_block = $current_parsed_block; - $current_parsed_block = $this->inner_blocks[ $index ]->parsed_block; - $block_content .= $this->inner_blocks[ $index++ ]->render(); - $current_parsed_block = $parent_parsed_block; - } + $block_content .= is_string( $chunk ) ? + $chunk : + $this->inner_blocks[ $index++ ]->render(); } } diff --git a/lib/compat.php b/lib/compat.php index 2c4dfb9033c103..e63a7a5af514ad 100644 --- a/lib/compat.php +++ b/lib/compat.php @@ -366,18 +366,11 @@ function gutenberg_replace_default_block_categories( $default_categories ) { } add_filter( 'block_categories', 'gutenberg_replace_default_block_categories' ); -global $current_parsed_block; -$current_parsed_block = array( - 'blockName' => null, - 'attributes' => null, -); - /** * Shim that hooks into `pre_render_block` so as to override `render_block` with * a function that assigns block context. * * The context handling can be removed when plugin support requires WordPress 5.5.0+. - * The global current_parsed_block assignment can be removed when plugin support requires WordPress 5.6.0+. * * @see https://core.trac.wordpress.org/ticket/49927 * @see https://core.trac.wordpress.org/changeset/48243 @@ -389,7 +382,6 @@ function gutenberg_replace_default_block_categories( $default_categories ) { */ function gutenberg_render_block_with_assigned_block_context( $pre_render, $parsed_block ) { global $post, $wp_query; - global $current_parsed_block; /* * If a non-null value is provided, a filter has run at an earlier priority @@ -399,8 +391,6 @@ function gutenberg_render_block_with_assigned_block_context( $pre_render, $parse return $pre_render; } - $current_parsed_block = $parsed_block; - $source_block = $parsed_block; /** This filter is documented in src/wp-includes/blocks.php */ diff --git a/packages/block-library/src/archives/index.php b/packages/block-library/src/archives/index.php index 04e7e4957cb3a8..4f241b7cd7bd57 100644 --- a/packages/block-library/src/archives/index.php +++ b/packages/block-library/src/archives/index.php @@ -10,11 +10,13 @@ * * @see WP_Widget_Archives * - * @param array $attributes The block attributes. + * @param Array $attributes The block attributes. + * @param String $content InnerBlocks content of the Block. + * @param WPBlock $block Block object. * * @return string Returns the post content with archives added. */ -function render_block_core_archives( $attributes ) { +function render_block_core_archives( $attributes, $content, $block ) { $show_post_count = ! empty( $attributes['showPostCounts'] ); $class = ''; @@ -97,7 +99,11 @@ function render_block_core_archives( $attributes ) { ); } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $classnames ) + ); return sprintf( '', diff --git a/packages/block-library/src/calendar/index.php b/packages/block-library/src/calendar/index.php index 6e0c52886adda8..f32b0df6ffb732 100644 --- a/packages/block-library/src/calendar/index.php +++ b/packages/block-library/src/calendar/index.php @@ -8,11 +8,13 @@ /** * Renders the `core/calendar` block on server. * - * @param array $attributes The block attributes. + * @param Array $attributes The block attributes. + * @param String $content InnerBlocks content of the Block. + * @param WPBlock $block Block object. * * @return string Returns the block content. */ -function render_block_core_calendar( $attributes ) { +function render_block_core_calendar( $attributes, $content, $block ) { global $monthnum, $year; $previous_monthnum = $monthnum; @@ -31,7 +33,10 @@ function render_block_core_calendar( $attributes ) { } } - $wrapper_attributes = get_block_wrapper_attributes(); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes + ); $output = sprintf( '
%2$s
', $wrapper_attributes, diff --git a/packages/block-library/src/categories/index.php b/packages/block-library/src/categories/index.php index c820b7bd76b578..d5e9316e562993 100644 --- a/packages/block-library/src/categories/index.php +++ b/packages/block-library/src/categories/index.php @@ -8,11 +8,13 @@ /** * Renders the `core/categories` block on server. * - * @param array $attributes The block attributes. + * @param Array $attributes The block attributes. + * @param String $content InnerBlocks content of the Block. + * @param WPBlock $block Block object. * * @return string Returns the categories list/dropdown markup. */ -function render_block_core_categories( $attributes ) { +function render_block_core_categories( $attributes, $content, $block ) { static $block_id = 0; $block_id++; @@ -47,7 +49,11 @@ function render_block_core_categories( $attributes ) { $type = 'list'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => "wp-block-categories-{$type}" ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => "wp-block-categories-{$type}" ) + ); return sprintf( $wrapper_markup, diff --git a/packages/block-library/src/latest-comments/index.php b/packages/block-library/src/latest-comments/index.php index 555a125c4aa2ba..3a80d254064a0a 100644 --- a/packages/block-library/src/latest-comments/index.php +++ b/packages/block-library/src/latest-comments/index.php @@ -36,11 +36,13 @@ function wp_latest_comments_draft_or_post_title( $post = 0 ) { /** * Renders the `core/latest-comments` block on server. * - * @param array $attributes The block attributes. + * @param Array $attributes The block attributes. + * @param String $content InnerBlocks content of the Block. + * @param WPBlock $block Block object. * * @return string Returns the post content with latest comments added. */ -function render_block_core_latest_comments( $attributes = array() ) { +function render_block_core_latest_comments( $attributes = array(), $content, $block ) { // This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php. $comments = get_comments( apply_filters( @@ -129,7 +131,11 @@ function render_block_core_latest_comments( $attributes = array() ) { if ( empty( $comments ) ) { $classnames[] = 'no-comments'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => implode( ' ', $classnames ) ) + ); return ! empty( $comments ) ? sprintf( '
    %2$s
', diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index a43646edd72ce2..66660bce1df892 100644 --- a/packages/block-library/src/latest-posts/index.php +++ b/packages/block-library/src/latest-posts/index.php @@ -28,11 +28,13 @@ function block_core_latest_posts_get_excerpt_length() { /** * Renders the `core/latest-posts` block on server. * - * @param array $attributes The block attributes. + * @param Array $attributes The block attributes. + * @param String $content InnerBlocks content of the Block. + * @param WPBlock $block Block object. * * @return string Returns the post content with latest posts added. */ -function render_block_core_latest_posts( $attributes ) { +function render_block_core_latest_posts( $attributes, $content, $block ) { global $post, $block_core_latest_posts_excerpt_length; $args = array( @@ -171,7 +173,11 @@ function render_block_core_latest_posts( $attributes ) { $class .= ' has-author'; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $class ) + ); return sprintf( '', diff --git a/packages/block-library/src/navigation-link/index.php b/packages/block-library/src/navigation-link/index.php index 57c4b3354fc099..13a1b5ce152d0e 100644 --- a/packages/block-library/src/navigation-link/index.php +++ b/packages/block-library/src/navigation-link/index.php @@ -97,9 +97,9 @@ function block_core_navigation_link_render_submenu_icon() { /** * Renders the `core/navigation-link` block. * - * @param array $attributes The block attributes. - * @param array $content The saved content. - * @param array $block The parsed block. + * @param array $attributes The block attributes. + * @param array $content The saved content. + * @param WPBlock $block The parsed block. * * @return string Returns the post content with the legacy widget added. */ @@ -128,6 +128,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) { }; $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, array( 'class' => $css_classes . ( $has_submenu ? ' has-child' : '' ) . ( $is_active ? ' current-menu-item' : '' ), diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index b56ea6023be975..5eebde706a8624 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -97,9 +97,9 @@ function block_core_navigation_render_submenu_icon() { /** * Renders the `core/navigation` block on server. * - * @param array $attributes The block attributes. - * @param array $content The saved content. - * @param array $block The parsed block. + * @param array $attributes The block attributes. + * @param array $content The saved content. + * @param WPBlock $block The parsed block. * * @return string Returns the post content with the legacy widget added. */ @@ -140,6 +140,8 @@ function render_block_core_navigation( $attributes, $content, $block ) { } $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, array( 'class' => implode( ' ', $classes ), 'style' => $colors['inline_styles'] . $font_sizes['inline_styles'], diff --git a/packages/block-library/src/post-author/index.php b/packages/block-library/src/post-author/index.php index e31be65f709942..75e8d5c990f280 100644 --- a/packages/block-library/src/post-author/index.php +++ b/packages/block-library/src/post-author/index.php @@ -35,7 +35,11 @@ function render_block_core_post_author( $attributes, $content, $block ) { isset( $attributes['textAlign'] ) ? array( 'has-text-align-' . $attributes['textAlign'] ) : array() ); - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => implode( ' ', $classes ) ) + ); return sprintf( '
', $wrapper_attributes ) . ( ! empty( $attributes['showAvatar'] ) ? '
' . $avatar . '
' : '' ) . diff --git a/packages/block-library/src/post-comment-author/index.php b/packages/block-library/src/post-comment-author/index.php index 9cad587d3d447c..ccc63b60ad1f28 100644 --- a/packages/block-library/src/post-comment-author/index.php +++ b/packages/block-library/src/post-comment-author/index.php @@ -18,7 +18,10 @@ function render_block_core_post_comment_author( $attributes, $content, $block ) return ''; } - $wrapper_attributes = get_block_wrapper_attributes(); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes + ); return sprintf( '
%2$s
', diff --git a/packages/block-library/src/post-comment-content/index.php b/packages/block-library/src/post-comment-content/index.php index 0670fb0af15da3..e0f6f5d044ac7b 100644 --- a/packages/block-library/src/post-comment-content/index.php +++ b/packages/block-library/src/post-comment-content/index.php @@ -17,7 +17,10 @@ function render_block_core_post_comment_content( $attributes, $content, $block ) if ( ! isset( $block->context['commentId'] ) ) { return ''; } - $wrapper_attributes = get_block_wrapper_attributes(); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes + ); return sprintf( '
%2$s
', $wrapper_attributes, diff --git a/packages/block-library/src/post-comment-date/index.php b/packages/block-library/src/post-comment-date/index.php index f46529b55e295c..af80a86af1bc10 100644 --- a/packages/block-library/src/post-comment-date/index.php +++ b/packages/block-library/src/post-comment-date/index.php @@ -18,7 +18,10 @@ function render_block_core_post_comment_date( $attributes, $content, $block ) { return ''; } - $wrapper_attributes = get_block_wrapper_attributes(); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes + ); return sprintf( '
', $wrapper_attributes, diff --git a/packages/block-library/src/post-comments-count/index.php b/packages/block-library/src/post-comments-count/index.php index 86430a41d53493..1e04654bdef40d 100644 --- a/packages/block-library/src/post-comments-count/index.php +++ b/packages/block-library/src/post-comments-count/index.php @@ -23,7 +23,11 @@ function render_block_core_post_comments_count( $attributes, $content, $block ) $classes .= 'has-text-align-' . $attributes['textAlign']; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $classes ) + ); return sprintf( '
%2$s
', $wrapper_attributes, diff --git a/packages/block-library/src/post-comments-form/index.php b/packages/block-library/src/post-comments-form/index.php index 0474bdce1b722c..f456821002eec8 100644 --- a/packages/block-library/src/post-comments-form/index.php +++ b/packages/block-library/src/post-comments-form/index.php @@ -26,7 +26,11 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) { ob_start(); comment_form( array(), $block->context['postId'] ); $form = ob_get_clean(); - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $classes ) + ); return sprintf( '
%2$s
', $wrapper_attributes, $form ); } diff --git a/packages/block-library/src/post-comments/index.php b/packages/block-library/src/post-comments/index.php index d9629c32f0e6f4..621fb741eb7160 100644 --- a/packages/block-library/src/post-comments/index.php +++ b/packages/block-library/src/post-comments/index.php @@ -36,7 +36,11 @@ function render_block_core_post_comments( $attributes, $content, $block ) { $classes .= 'has-text-align-' . $attributes['textAlign']; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $classes ) + ); $output = sprintf( '
', $wrapper_attributes ) . ob_get_clean() . '
'; return $output; } diff --git a/packages/block-library/src/post-content/index.php b/packages/block-library/src/post-content/index.php index 7ee8b4dd1b7055..1464ed25662dfe 100644 --- a/packages/block-library/src/post-content/index.php +++ b/packages/block-library/src/post-content/index.php @@ -18,7 +18,11 @@ function render_block_core_post_content( $attributes, $content, $block ) { return ''; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'entry-content' ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => 'entry-content' ) + ); return ( '
' . diff --git a/packages/block-library/src/post-date/index.php b/packages/block-library/src/post-date/index.php index 940820b504692f..fe7e7bb4fde3b4 100644 --- a/packages/block-library/src/post-date/index.php +++ b/packages/block-library/src/post-date/index.php @@ -19,7 +19,11 @@ function render_block_core_post_date( $attributes, $content, $block ) { } $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $align_class_name ) + ); return sprintf( '
', diff --git a/packages/block-library/src/post-excerpt/index.php b/packages/block-library/src/post-excerpt/index.php index a6a4c641dc0103..bec5d2c0eb3433 100644 --- a/packages/block-library/src/post-excerpt/index.php +++ b/packages/block-library/src/post-excerpt/index.php @@ -32,7 +32,11 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) { if ( isset( $attributes['textAlign'] ) ) { $classes .= 'has-text-align-' . $attributes['textAlign']; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $classes ) + ); $output = sprintf( '
', esc_attr( $wrapper_attributes ) ) . '

' . get_the_excerpt( $block->context['postId'] ); if ( ! isset( $attributes['showMoreOnNewLine'] ) || $attributes['showMoreOnNewLine'] ) { diff --git a/packages/block-library/src/post-featured-image/index.php b/packages/block-library/src/post-featured-image/index.php index 2822fb352f8a73..a06d672cfcb12c 100644 --- a/packages/block-library/src/post-featured-image/index.php +++ b/packages/block-library/src/post-featured-image/index.php @@ -25,7 +25,10 @@ function render_block_core_post_featured_image( $attributes, $content, $block ) $featured_image = sprintf( '%2s', get_the_permalink( $post_ID ), $featured_image ); } - $wrapper_attributes = get_block_wrapper_attributes(); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes + ); return '

' . $featured_image . '

'; } diff --git a/packages/block-library/src/post-hierarchical-terms/index.php b/packages/block-library/src/post-hierarchical-terms/index.php index bf26204b57e654..78a069ca898bd6 100644 --- a/packages/block-library/src/post-hierarchical-terms/index.php +++ b/packages/block-library/src/post-hierarchical-terms/index.php @@ -34,7 +34,11 @@ function render_block_core_post_hierarchical_terms( $attributes, $content, $bloc ); } $terms_links = trim( $terms_links, ' | ' ); - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $align_class_name ) + ); return sprintf( '
%2$s
', diff --git a/packages/block-library/src/post-tags/index.php b/packages/block-library/src/post-tags/index.php index dd703074088229..0b929a6f1d15c9 100644 --- a/packages/block-library/src/post-tags/index.php +++ b/packages/block-library/src/post-tags/index.php @@ -25,7 +25,11 @@ function render_block_core_post_tags( $attributes, $content, $block ) { $classes .= 'has-text-align-' . $attributes['textAlign']; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $classes ) + ); $output = sprintf( '
', $wrapper_attributes ); foreach ( $post_tags as $tag ) { diff --git a/packages/block-library/src/post-title/index.php b/packages/block-library/src/post-title/index.php index 798278b5567af5..50851cf44e1037 100644 --- a/packages/block-library/src/post-title/index.php +++ b/packages/block-library/src/post-title/index.php @@ -31,7 +31,11 @@ function render_block_core_post_title( $attributes, $content, $block ) { if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { $title = sprintf( '%4s', get_the_permalink( $post_ID ), $attributes['linkTarget'], $attributes['rel'], $title ); } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $align_class_name ) + ); return sprintf( '<%1$s %2$s>%3$s', diff --git a/packages/block-library/src/rss/index.php b/packages/block-library/src/rss/index.php index b0a31bf2bbd6d0..8f37b622215651 100644 --- a/packages/block-library/src/rss/index.php +++ b/packages/block-library/src/rss/index.php @@ -8,11 +8,13 @@ /** * Renders the `core/rss` block on server. * - * @param array $attributes The block attributes. + * @param array $attributes Block attributes. + * @param string $content Block default content. + * @param WP_Block $block Block instance. * * @return string Returns the block content with received rss items. */ -function render_block_core_rss( $attributes ) { +function render_block_core_rss( $attributes, $content, $block ) { $rss = fetch_feed( $attributes['feedURL'] ); if ( is_wp_error( $rss ) ) { @@ -87,7 +89,11 @@ function render_block_core_rss( $attributes ) { if ( isset( $attributes['columns'] ) && 'grid' === $attributes['blockLayout'] ) { $classnames[] = 'columns-' . $attributes['columns']; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => implode( ' ', $classnames ) ) + ); return sprintf( '
    %s
', $wrapper_attributes, $list_items ); } diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index 36607188ff44a3..de3b810c86b28f 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -8,11 +8,13 @@ /** * Dynamically renders the `core/search` block. * - * @param array $attributes The block attributes. + * @param array $attributes Block attributes. + * @param string $content Block default content. + * @param WP_Block $block Block instance. * * @return string The search block markup. */ -function render_block_core_search( $attributes ) { +function render_block_core_search( $attributes, $content, $block ) { static $instance_id = 0; // Older versions of the Search block defaulted the label and buttonText @@ -96,7 +98,11 @@ function render_block_core_search( $attributes ) { $width_styles, $input_markup . $button_markup ); - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $classnames ) + ); return sprintf( '
%s
', diff --git a/packages/block-library/src/site-logo/index.php b/packages/block-library/src/site-logo/index.php index efadd3ce16c61f..14570bda44a2ba 100644 --- a/packages/block-library/src/site-logo/index.php +++ b/packages/block-library/src/site-logo/index.php @@ -8,11 +8,13 @@ /** * Renders the `core/site-logo` block on the server. * - * @param array $attributes The block attributes. + * @param array $attributes Block attributes. + * @param string $content Block default content. + * @param WP_Block $block Block instance. * * @return string The render. */ -function render_block_core_site_logo( $attributes ) { +function render_block_core_site_logo( $attributes, $content, $block ) { $adjust_width_height_filter = function ( $image ) use ( $attributes ) { if ( empty( $attributes['width'] ) ) { return $image; @@ -32,7 +34,11 @@ function render_block_core_site_logo( $attributes ) { $classnames[] = "align{$attributes['align']}"; } - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => implode( ' ', $classnames ) ) + ); $html = sprintf( '
%s
', $wrapper_attributes, $custom_logo ); remove_filter( 'wp_get_attachment_image_src', $adjust_width_height_filter ); return $html; diff --git a/packages/block-library/src/site-tagline/index.php b/packages/block-library/src/site-tagline/index.php index e248d51011e761..4513c7d0461bac 100644 --- a/packages/block-library/src/site-tagline/index.php +++ b/packages/block-library/src/site-tagline/index.php @@ -8,13 +8,19 @@ /** * Renders the `core/site-tagline` block on the server. * - * @param array $attributes The block attributes. + * @param array $attributes Block attributes. + * @param string $content Block default content. + * @param WP_Block $block Block instance. * * @return string The render. */ -function render_block_core_site_tagline( $attributes ) { +function render_block_core_site_tagline( $attributes, $content, $block ) { $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $align_class_name ) + ); return sprintf( '

%2$s

', diff --git a/packages/block-library/src/site-title/index.php b/packages/block-library/src/site-title/index.php index 6cbd6988f9c102..24f2f33a92336e 100644 --- a/packages/block-library/src/site-title/index.php +++ b/packages/block-library/src/site-title/index.php @@ -8,11 +8,13 @@ /** * Renders the `core/site-title` block on the server. * - * @param array $attributes The block attributes. + * @param array $attributes Block attributes. + * @param string $content Block default content. + * @param WP_Block $block Block instance. * * @return string The render. */ -function render_block_core_site_title( $attributes ) { +function render_block_core_site_title( $attributes, $content, $block ) { $tag_name = 'h1'; $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; @@ -21,7 +23,11 @@ function render_block_core_site_title( $attributes ) { } $link = sprintf( '%2$s', get_bloginfo( 'url' ), get_bloginfo( 'name' ) ); - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => $align_class_name ) + ); return sprintf( '<%1$s %2$s>%3$s', diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index f2320da312fc51..6951e3f442da8c 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -33,7 +33,11 @@ function render_block_core_social_link( $attributes, $content, $block ) { } $icon = block_core_social_link_get_icon( $service ); - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'wp-social-link wp-social-link-' . $service . $class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes, + array( 'class' => 'wp-social-link wp-social-link-' . $service . $class_name ) + ); return '
  • ' . $icon . '
  • '; } diff --git a/packages/block-library/src/tag-cloud/index.php b/packages/block-library/src/tag-cloud/index.php index cdebc9227138a4..3c62f3722369f1 100644 --- a/packages/block-library/src/tag-cloud/index.php +++ b/packages/block-library/src/tag-cloud/index.php @@ -8,11 +8,13 @@ /** * Renders the `core/tag-cloud` block on server. * - * @param array $attributes The block attributes. + * @param array $attributes Block attributes. + * @param string $content Block default content. + * @param WP_Block $block Block instance. * * @return string Returns the tag cloud for selected taxonomy. */ -function render_block_core_tag_cloud( $attributes ) { +function render_block_core_tag_cloud( $attributes, $content, $block ) { $args = array( 'echo' => false, 'taxonomy' => $attributes['taxonomy'], @@ -31,7 +33,10 @@ function render_block_core_tag_cloud( $attributes ) { ); } - $wrapper_attributes = get_block_wrapper_attributes(); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes + ); return sprintf( '

    %2$s

    ', diff --git a/packages/block-library/src/template-part/index.php b/packages/block-library/src/template-part/index.php index 50629eb83534f3..5f37469f5ee011 100644 --- a/packages/block-library/src/template-part/index.php +++ b/packages/block-library/src/template-part/index.php @@ -8,11 +8,13 @@ /** * Renders the `core/template-part` block on the server. * - * @param array $attributes The block attributes. + * @param array $attributes Block attributes. + * @param string $content Block default content. + * @param WP_Block $block Block instance. * * @return string The render. */ -function render_block_core_template_part( $attributes ) { +function render_block_core_template_part( $attributes, $content, $block ) { $content = null; if ( ! empty( $attributes['postId'] ) && get_post_status( $attributes['postId'] ) ) { @@ -63,7 +65,10 @@ function render_block_core_template_part( $attributes ) { } $content = do_shortcode( $content ); $html_tag = esc_attr( $attributes['tagName'] ); - $wrapper_attributes = get_block_wrapper_attributes(); + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $attributes + ); return "<$html_tag $wrapper_attributes>" . str_replace( ']]>', ']]>', $content ) . ""; } diff --git a/phpunit/class-block-supported-styles-test.php b/phpunit/class-block-supported-styles-test.php index 19765f6a2b6611..7bca908b8ebd38 100644 --- a/phpunit/class-block-supported-styles-test.php +++ b/phpunit/class-block-supported-styles-test.php @@ -94,12 +94,12 @@ private function get_content_from_block( $block ) { /** * Returns the rendered output for the current block. * - * @param array $block Block to render. + * @param WPBlock $block Block to render. */ private function render_example_block( $block ) { - global $current_parsed_block; - $current_parsed_block = $block; - $wrapper_attributes = get_block_wrapper_attributes( + $wrapper_attributes = get_block_wrapper_attributes( + $block->name, + $block->attributes, array( 'class' => 'foo-bar-class', 'style' => 'test: style;',