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:
parent
6a989e83f6
commit
8f952495a7
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -14,51 +14,23 @@
|
|||
* @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',
|
||||
|
@ -66,6 +38,17 @@ function render_block_core_cover( $attributes, $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;
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue