Editor: Update WordPress packages for 6.0 RC 2 (part 2)

Includes cherry-picked commit from the Gutenberg plugin that fix a bug discovere just before WordPress 6.0 RC 2.

Props hellofromtonya, zieladam, kebbet.
See #55567.


Built from https://develop.svn.wordpress.org/trunk@53378


git-svn-id: http://core.svn.wordpress.org/trunk@52967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
gziolo 2022-05-10 15:57:28 +00:00
parent 6a989e83f6
commit 8f952495a7
3 changed files with 24 additions and 40 deletions

View File

@ -23,8 +23,9 @@ function render_block_core_comments_title( $attributes ) {
$show_comments_count = ! empty( $attributes['showCommentsCount'] ) && $attributes['showCommentsCount']; $show_comments_count = ! empty( $attributes['showCommentsCount'] ) && $attributes['showCommentsCount'];
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
$comments_count = get_comments_number(); $comments_count = get_comments_number();
$post_title = '“' . get_the_title() . '”'; /* translators: %s: Post title. */
$tag_name = 'h2'; $post_title = sprintf( __( '“%s”' ), get_the_title() );
$tag_name = 'h2';
if ( isset( $attributes['level'] ) ) { if ( isset( $attributes['level'] ) ) {
$tag_name = 'h' . $attributes['level']; $tag_name = 'h' . $attributes['level'];
} }

View File

@ -14,51 +14,23 @@
* @return string Returns the cover block markup, if useFeaturedImage is true. * @return string Returns the cover block markup, if useFeaturedImage is true.
*/ */
function render_block_core_cover( $attributes, $content ) { function render_block_core_cover( $attributes, $content ) {
if ( false === $attributes['useFeaturedImage'] ) { if ( 'image' !== $attributes['backgroundType'] || false === $attributes['useFeaturedImage'] ) {
return $content; return $content;
} }
$current_featured_image = get_the_post_thumbnail_url(); if ( ! ( $attributes['hasParallax'] || $attributes['isRepeated'] ) ) {
$attr = array(
if ( false === $current_featured_image ) { 'class' => 'wp-block-cover__image-background',
return $content; 'data-object-fit' => 'cover',
}
$is_img_element = ! ( $attributes['hasParallax'] || $attributes['isRepeated'] );
$is_image_background = 'image' === $attributes['backgroundType'];
if ( $is_image_background && ! $is_img_element ) {
$content = preg_replace(
'/class=\".*?\"/',
'${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
$content,
1
); );
}
if ( $is_image_background && $is_img_element ) {
$object_position = '';
if ( isset( $attributes['focalPoint'] ) ) { if ( isset( $attributes['focalPoint'] ) ) {
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . $object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
round( $attributes['focalPoint']['y'] * 100 ) . '%'; $attr['data-object-position'] = $object_position;
$attr['style'] = 'object-position: ' . $object_position;
} }
$image_template = '<img $image = get_the_post_thumbnail( null, 'post-thumbnail', $attr );
class="wp-block-cover__image-background"
alt="%s"
src="%s"
style="object-position: %s"
data-object-fit="cover"
data-object-position="%s"
/>';
$image = sprintf(
$image_template,
esc_attr( get_the_post_thumbnail_caption() ),
esc_url( $current_featured_image ),
esc_attr( $object_position ),
esc_attr( $object_position )
);
$content = str_replace( $content = str_replace(
'</span><div', '</span><div',
@ -66,6 +38,17 @@ function render_block_core_cover( $attributes, $content ) {
$content $content
); );
} else {
if ( in_the_loop() ) {
update_post_thumbnail_cache();
}
$current_featured_image = get_the_post_thumbnail_url();
$content = preg_replace(
'/class=\".*?\"/',
'${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
$content,
1
);
} }
return $content; return $content;

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.1-alpha-53377'; $wp_version = '6.1-alpha-53378';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.