Skip to content

Commit

Permalink
Editor: Update WordPress packages for 6.0 RC 2 (part 2)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gziolo committed May 10, 2022
1 parent 6a989e8 commit 8f95249
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 40 deletions.
5 changes: 3 additions & 2 deletions wp-includes/blocks/comments-title.php
Expand Up @@ -23,8 +23,9 @@ function render_block_core_comments_title( $attributes ) {
$show_comments_count = ! empty( $attributes['showCommentsCount'] ) && $attributes['showCommentsCount'];
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
$comments_count = get_comments_number();
$post_title = '“' . get_the_title() . '”';
$tag_name = 'h2';
/* translators: %s: Post title. */
$post_title = sprintf( __( '“%s”' ), get_the_title() );
$tag_name = 'h2';
if ( isset( $attributes['level'] ) ) {
$tag_name = 'h' . $attributes['level'];
}
Expand Down
57 changes: 20 additions & 37 deletions wp-includes/blocks/cover.php
Expand Up @@ -14,58 +14,41 @@
* @return string Returns the cover block markup, if useFeaturedImage is true.
*/
function render_block_core_cover( $attributes, $content ) {
if ( false === $attributes['useFeaturedImage'] ) {
if ( 'image' !== $attributes['backgroundType'] || false === $attributes['useFeaturedImage'] ) {
return $content;
}

$current_featured_image = get_the_post_thumbnail_url();

if ( false === $current_featured_image ) {
return $content;
}

$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 ( ! ( $attributes['hasParallax'] || $attributes['isRepeated'] ) ) {
$attr = array(
'class' => 'wp-block-cover__image-background',
'data-object-fit' => 'cover',
);
}

if ( $is_image_background && $is_img_element ) {
$object_position = '';
if ( isset( $attributes['focalPoint'] ) ) {
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' .
round( $attributes['focalPoint']['y'] * 100 ) . '%';
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
$attr['data-object-position'] = $object_position;
$attr['style'] = 'object-position: ' . $object_position;
}

$image_template = '<img
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 )
);
$image = get_the_post_thumbnail( null, 'post-thumbnail', $attr );

$content = str_replace(
'</span><div',
'</span>' . $image . '<div',
$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;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -16,7 +16,7 @@
*
* @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.
Expand Down

0 comments on commit 8f95249

Please sign in to comment.