Make WordPress Core


Ignore:
Timestamp:
04/12/2022 03:10:30 PM (3 years ago)
Author:
gziolo
Message:

Editor: Update WordPress packages based based on Gutenberg v13.0 RC3

This is the last step of backports from the Gutenberg plugin for WordPress 6.0 Beta 1 release. It includes all updates WordPress packages published to npm based on the Gutenberg plugin v13.0 RC3 release. This patch also includes all the necessary changes applied to core blocks. New blocks included:

  • Avatar
  • Comment Author Name
  • Comment Content
  • Comment Date
  • Comment Edit Link
  • Comment Rely Link
  • Comment Template
  • Comments Pagination
  • Comments Pagination Next
  • Comments Pagination Previous
  • Comments Query Loop
  • Home Link
  • Post Author Biography
  • Query No Results
  • Read More

See more details in https://github.com/WordPress/wordpress-develop/pull/2564.

Props zieladam, ramonopoly, ocean90.
Fixes #55505.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/gallery.php

    r52402 r53157  
    3434
    3535/**
     36 * Adds a style tag for the --wp--style--unstable-gallery-gap var.
     37 *
     38 * The Gallery block needs to recalculate Image block width based on
     39 * the current gap setting in order to maintain the number of flex columns
     40 * so a css var is added to allow this.
     41 *
     42 * @param array  $attributes Attributes of the block being rendered.
     43 * @param string $content Content of the block being rendered.
     44 * @return string The content of the block being rendered.
     45 */
     46function block_core_gallery_render( $attributes, $content ) {
     47    $gap = _wp_array_get( $attributes, array( 'style', 'spacing', 'blockGap' ) );
     48    // Skip if gap value contains unsupported characters.
     49    // Regex for CSS value borrowed from `safecss_filter_attr`, and used here
     50    // because we only want to match against the value, not the CSS attribute.
     51    $gap     = preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap;
     52    $class   = wp_unique_id( 'wp-block-gallery-' );
     53    $content = preg_replace(
     54        '/' . preg_quote( 'class="', '/' ) . '/',
     55        'class="' . $class . ' ',
     56        $content,
     57        1
     58    );
     59    // --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
     60    // gap on the gallery.
     61    $gap_value = $gap ? $gap : 'var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )';
     62    $style     = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_value . '; gap: ' . $gap_value . '}';
     63    // Ideally styles should be loaded in the head, but blocks may be parsed
     64    // after that, so loading in the footer for now.
     65    // See https://core.trac.wordpress.org/ticket/53494.
     66    add_action(
     67        'wp_footer',
     68        function () use ( $style ) {
     69            echo '<style> ' . $style . '</style>';
     70        }
     71    );
     72    return $content;
     73}
     74/**
    3675 * Registers the `core/gallery` block on server.
    37  * This render callback needs to be here
    38  * so that the gallery styles are loaded in block-based themes.
    3976 */
    4077function register_block_core_gallery() {
     
    4279        __DIR__ . '/gallery',
    4380        array(
    44             'render_callback' => function ( $attributes, $content ) {
    45                 return $content;
    46             },
     81            'render_callback' => 'block_core_gallery_render',
    4782        )
    4883    );
Note: See TracChangeset for help on using the changeset viewer.