Make WordPress Core


Ignore:
Timestamp:
05/10/2022 04:20:59 PM (4 years ago)
Author:
hellofromTonya
Message:

Editor: Update WordPress packages for 6.0 RC 2.

[53377] Included cherry-picked commits from the Gutenberg plugin that fix bugs discovered after WordPress 6.0 RC 1.

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

Props zieladam, ndiego, kebbet, hellofromTonya.
Merges [53377] and [53378] to the 6.0 branch.
Fixes #55567.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/src/wp-includes/blocks/cover.php

    r53329 r53381  
    1515 */
    1616function render_block_core_cover( $attributes, $content ) {
    17         if ( false === $attributes['useFeaturedImage'] ) {
     17        if ( 'image' !== $attributes['backgroundType'] || false === $attributes['useFeaturedImage'] ) {
    1818                return $content;
    1919        }
    2020
    21         $current_featured_image = get_the_post_thumbnail_url();
     21        if ( ! ( $attributes['hasParallax'] || $attributes['isRepeated'] ) ) {
     22                $attr = array(
     23                        'class'           => 'wp-block-cover__image-background',
     24                        'data-object-fit' => 'cover',
     25                );
    2226
    23         if ( false === $current_featured_image ) {
    24                 return $content;
    25         }
    26 
    27         $is_img_element      = ! ( $attributes['hasParallax'] || $attributes['isRepeated'] );
    28         $is_image_background = 'image' === $attributes['backgroundType'];
    29 
    30         if ( $is_image_background && ! $is_img_element ) {
    31                 $content = preg_replace(
    32                         '/class=\".*?\"/',
    33                         '${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
    34                         $content,
    35                         1
    36                 );
    37         }
    38 
    39         if ( $is_image_background && $is_img_element ) {
    40                 $object_position = '';
    4127                if ( isset( $attributes['focalPoint'] ) ) {
    42                         $object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' .
    43                         round( $attributes['focalPoint']['y'] * 100 ) . '%';
     28                        $object_position              = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
     29                        $attr['data-object-position'] = $object_position;
     30                        $attr['style']                = 'object-position: ' . $object_position;
    4431                }
    4532
    46                 $image_template = '<img
    47                         class="wp-block-cover__image-background"
    48                         alt="%s"
    49                         src="%s"
    50                         style="object-position: %s"
    51                         data-object-fit="cover"
    52                         data-object-position="%s"
    53                 />';
    54 
    55                 $image = sprintf(
    56                         $image_template,
    57                         esc_attr( get_the_post_thumbnail_caption() ),
    58                         esc_url( $current_featured_image ),
    59                         esc_attr( $object_position ),
    60                         esc_attr( $object_position )
    61                 );
     33                $image = get_the_post_thumbnail( null, 'post-thumbnail', $attr );
    6234
    6335                $content = str_replace(
    … …  
    6739                );
    6840
     41        } else {
     42                if ( in_the_loop() ) {
     43                        update_post_thumbnail_cache();
     44                }
     45                $current_featured_image = get_the_post_thumbnail_url();
     46                $content                = preg_replace(
     47                        '/class=\".*?\"/',
     48                        '${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
     49                        $content,
     50                        1
     51                );
    6952        }
    7053
Note: See TracChangeset for help on using the changeset viewer.