Skip to content

Commit

Permalink
Block Editor: Update packages and backport the latest Gutenberg fixes.
Browse files Browse the repository at this point in the history
This includes the following fixes:

- Generate babel polyfill dynamically WordPress/gutenberg#31279
- Improve the List View component WordPress/gutenberg#31290 WordPress/gutenberg#32063
- Template mode:
    - Fix embed dimensions WordPress/gutenberg#32057
    - Update the welcome guide WordPress/gutenberg#32055 WordPress/gutenberg#32026
    - Don’t display the notice at the same time as the welcome guide WordPress/gutenberg#32076
    - Remove MetaBoxes WordPress/gutenberg#32315
    - Update the title area WordPress/gutenberg#32037 
- Widgets Screen:
    - Fix unsaved changes WordPress/gutenberg#31757
    - Fix toolbar alignment WordPress/gutenberg#31991
    - Fix block toolbar position after scroll WordPress/gutenberg#32212
    - Fix the visible widget area header WordPress/gutenberg#32262
    - Fix legacy widgets preview WordPress/gutenberg#32260
    - 
- Block Widgets in the customizer: 
    - Fix customizer title overlapping block toolbar WordPress/gutenberg#32140
    - Fix styling issues WordPress/gutenberg#32072
    - Fix escape key events WordPress/gutenberg#32175
    - Add preferences menu group label WordPress/gutenberg#32259
    - Fix creating and replacing legacy widgets WordPress/gutenberg#32005
    - Fix the welcome guide’s image WordPress/gutenberg#32264 WordPress/gutenberg#32302 
- Fix Cover to Image transform duotone error WordPress/gutenberg#32006
- Remove filter_var usage from blocks WordPress/gutenberg#32046 
- Fix image width for aligned Post Featured Image block WordPress/gutenberg#32070
- Prevent excessive Image block re-rendering WordPress/gutenberg#32102
- Remove gutenberg domain from core blocks WordPress/gutenberg#32152
- Use the block editor context class for the the different settings filters WordPress/gutenberg#32159
- Fix Latest Posts block grid view WordPress/gutenberg#32160
- Fix preset classes generation per block WordPress/gutenberg#32190
- Fix logic to enable custom colors and gradients WordPress/gutenberg#32200
- Update the Site Logo logic to use a dedicated site option WordPress/gutenberg#32229
- Limit the Latest Posts block’s featured image width WordPress/gutenberg#32245
- Remove opacity animation in the canvas. WordPress/gutenberg#32266
- Make the focus style valid CSS WordPress/gutenberg#32305
- Fix theme.json styles for the core/list block WordPress/gutenberg#32343
- Fix PHP notice when calling render_block WordPress/gutenberg#32135

Props nosolosw, noisysocks.
See #52991.


git-svn-id: https://develop.svn.wordpress.org/trunk@51051 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
youknowriad committed Jun 1, 2021
1 parent c1757f4 commit 7d91668
Show file tree
Hide file tree
Showing 13 changed files with 1,049 additions and 1,571 deletions.
2,404 changes: 916 additions & 1,488 deletions package-lock.json

Large diffs are not rendered by default.

114 changes: 57 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"last 2 Opera versions"
],
"devDependencies": {
"@wordpress/custom-templated-path-webpack-plugin": "2.0.4",
"@wordpress/dependency-extraction-webpack-plugin": "3.1.3",
"@wordpress/e2e-test-utils": "5.2.0",
"@wordpress/library-export-default-webpack-plugin": "2.0.4",
"@wordpress/scripts": "16.1.0",
"@wordpress/custom-templated-path-webpack-plugin": "2.0.5",
"@wordpress/dependency-extraction-webpack-plugin": "3.1.4",
"@wordpress/e2e-test-utils": "5.3.0",
"@wordpress/library-export-default-webpack-plugin": "2.0.5",
"@wordpress/scripts": "16.1.1",
"autoprefixer": "^9.8.6",
"chalk": "4.1.1",
"check-node-version": "4.1.0",
Expand Down Expand Up @@ -77,58 +77,58 @@
},
"dependencies": {
"@babel/polyfill": "7.10.1",
"@wordpress/a11y": "3.1.0",
"@wordpress/annotations": "2.1.0",
"@wordpress/api-fetch": "5.1.0",
"@wordpress/autop": "3.1.0",
"@wordpress/blob": "3.1.0",
"@wordpress/block-directory": "2.1.2",
"@wordpress/block-editor": "6.1.0",
"@wordpress/block-library": "3.2.1",
"@wordpress/block-serialization-default-parser": "4.1.0",
"@wordpress/blocks": "9.1.0",
"@wordpress/components": "14.1.0",
"@wordpress/compose": "4.1.0",
"@wordpress/core-data": "3.1.1",
"@wordpress/customize-widgets": "1.0.1",
"@wordpress/data": "5.1.0",
"@wordpress/data-controls": "2.1.0",
"@wordpress/date": "4.1.0",
"@wordpress/deprecated": "3.1.0",
"@wordpress/dom": "3.1.0",
"@wordpress/dom-ready": "3.1.0",
"@wordpress/edit-post": "4.1.2",
"@wordpress/edit-widgets": "2.1.2",
"@wordpress/editor": "10.1.1",
"@wordpress/element": "3.1.0",
"@wordpress/escape-html": "2.1.0",
"@wordpress/format-library": "2.1.0",
"@wordpress/hooks": "3.1.0",
"@wordpress/html-entities": "3.1.0",
"@wordpress/i18n": "4.1.0",
"@wordpress/icons": "4.0.0",
"@wordpress/interface": "3.1.0",
"@wordpress/is-shallow-equal": "4.1.0",
"@wordpress/keyboard-shortcuts": "2.1.0",
"@wordpress/keycodes": "3.1.0",
"@wordpress/list-reusable-blocks": "2.1.0",
"@wordpress/media-utils": "2.1.0",
"@wordpress/notices": "3.1.0",
"@wordpress/nux": "4.1.0",
"@wordpress/plugins": "3.1.0",
"@wordpress/primitives": "2.1.0",
"@wordpress/priority-queue": "2.1.0",
"@wordpress/redux-routine": "4.1.0",
"@wordpress/reusable-blocks": "2.1.1",
"@wordpress/rich-text": "4.1.0",
"@wordpress/server-side-render": "2.1.0",
"@wordpress/shortcode": "3.1.0",
"@wordpress/token-list": "2.1.0",
"@wordpress/url": "3.1.0",
"@wordpress/viewport": "3.1.0",
"@wordpress/warning": "2.1.0",
"@wordpress/widgets": "1.1.1",
"@wordpress/wordcount": "3.1.0",
"@wordpress/a11y": "3.1.1",
"@wordpress/annotations": "2.1.1",
"@wordpress/api-fetch": "5.1.1",
"@wordpress/autop": "3.1.1",
"@wordpress/blob": "3.1.1",
"@wordpress/block-directory": "2.1.3",
"@wordpress/block-editor": "6.1.1",
"@wordpress/block-library": "3.2.2",
"@wordpress/block-serialization-default-parser": "4.1.1",
"@wordpress/blocks": "9.1.1",
"@wordpress/components": "14.1.1",
"@wordpress/compose": "4.1.1",
"@wordpress/core-data": "3.1.2",
"@wordpress/customize-widgets": "1.0.2",
"@wordpress/data": "5.1.1",
"@wordpress/data-controls": "2.1.1",
"@wordpress/date": "4.1.1",
"@wordpress/deprecated": "3.1.1",
"@wordpress/dom": "3.1.1",
"@wordpress/dom-ready": "3.1.1",
"@wordpress/edit-post": "4.1.3",
"@wordpress/edit-widgets": "2.1.3",
"@wordpress/editor": "10.1.2",
"@wordpress/element": "3.1.1",
"@wordpress/escape-html": "2.1.1",
"@wordpress/format-library": "2.1.1",
"@wordpress/hooks": "3.1.1",
"@wordpress/html-entities": "3.1.1",
"@wordpress/i18n": "4.1.1",
"@wordpress/icons": "4.0.1",
"@wordpress/interface": "3.1.1",
"@wordpress/is-shallow-equal": "4.1.1",
"@wordpress/keyboard-shortcuts": "2.1.1",
"@wordpress/keycodes": "3.1.1",
"@wordpress/list-reusable-blocks": "2.1.1",
"@wordpress/media-utils": "2.1.1",
"@wordpress/notices": "3.1.1",
"@wordpress/nux": "4.1.1",
"@wordpress/plugins": "3.1.1",
"@wordpress/primitives": "2.1.1",
"@wordpress/priority-queue": "2.1.1",
"@wordpress/redux-routine": "4.1.1",
"@wordpress/reusable-blocks": "2.1.2",
"@wordpress/rich-text": "4.1.1",
"@wordpress/server-side-render": "2.1.1",
"@wordpress/shortcode": "3.1.1",
"@wordpress/token-list": "2.1.1",
"@wordpress/url": "3.1.1",
"@wordpress/viewport": "3.1.1",
"@wordpress/warning": "2.1.1",
"@wordpress/widgets": "1.1.2",
"@wordpress/wordcount": "3.1.1",
"backbone": "1.4.0",
"clipboard": "2.0.8",
"core-js-url-browser": "3.6.4",
Expand Down
5 changes: 4 additions & 1 deletion src/wp-includes/block-supports/elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
* @return string Filtered block content.
*/
function wp_render_elements_support( $block_content, $block ) {
$link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );
$link_color = null;
if ( ! empty( $block['attrs'] ) ) {
$link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );
}

/*
* For now we only care about link color.
Expand Down
32 changes: 17 additions & 15 deletions src/wp-includes/blocks/legacy-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@
* @return string Rendered block.
*/
function render_block_core_legacy_widget( $attributes ) {
global $wp_widget_factory;

if ( isset( $attributes['id'] ) ) {
$sidebar_id = gutenberg_find_widgets_sidebar( $attributes['id'] );
return gutenberg_render_widget( $attributes['id'], $sidebar_id );
$sidebar_id = wp_find_widgets_sidebar( $attributes['id'] );
return wp_render_widget( $attributes['id'], $sidebar_id );
}

if ( ! isset( $attributes['idBase'] ) ) {
return '';
}

$widget_object = gutenberg_get_widget_object( $attributes['idBase'] );
if ( method_exists( $wp_widget_factory, 'get_widget_object' ) ) {
$widget_object = $wp_widget_factory->get_widget_object( $attributes['idBase'] );
} else {
$widget_object = gutenberg_get_widget_object( $attributes['idBase'] );
}

if ( ! $widget_object ) {
return '';
Expand All @@ -44,25 +50,21 @@ function render_block_core_legacy_widget( $attributes ) {
}

/**
* Registers the 'core/legacy-widget' block.
* On application init this does two things:
*
* - Registers the 'core/legacy-widget' block.
* - Intercepts any request with legacy-widget-preview in the query param and,
* if set, renders a page containing a preview of the requested Legacy Widget
* block.
*/
function register_block_core_legacy_widget() {
function init_legacy_widget_block() {
register_block_type_from_metadata(
__DIR__ . '/legacy-widget',
array(
'render_callback' => 'render_block_core_legacy_widget',
)
);
}

add_action( 'init', 'register_block_core_legacy_widget', 20 );

/**
* Intercepts any request with legacy-widget-preview in the query param and, if
* set, renders a page containing a preview of the requested Legacy Widget
* block.
*/
function handle_legacy_widget_preview_iframe() {
if ( empty( $_GET['legacy-widget-preview'] ) ) {
return;
}
Expand Down Expand Up @@ -108,4 +110,4 @@ function handle_legacy_widget_preview_iframe() {
exit;
}

add_action( 'init', 'handle_legacy_widget_preview_iframe', 21 );
add_action( 'init', 'init_legacy_widget_block' );
3 changes: 2 additions & 1 deletion src/wp-includes/blocks/list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"color": {
"gradients": true
},
"__unstablePasteTextInline": true
"__unstablePasteTextInline": true,
"__experimentalSelector": "ol,ul"
},
"editorStyle": "wp-block-list-editor",
"style": "wp-block-list"
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/blocks/query-loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
function render_block_core_query_loop( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : filter_var( $_GET[ $page_key ], FILTER_VALIDATE_INT );
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];

$query_args = build_query_vars_from_query_block( $block, $page );
// Override the custom query with the global query if needed.
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/blocks/query-pagination-next.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
function render_block_core_query_pagination_next( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : filter_var( $_GET[ $page_key ], FILTER_VALIDATE_INT );
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;

$wrapper_attributes = get_block_wrapper_attributes();
$default_label = __( 'Next Page »', 'gutenberg' );
$default_label = __( 'Next Page »' );
$label = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
$content = '';

Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/blocks/query-pagination-numbers.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
function render_block_core_query_pagination_numbers( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : filter_var( $_GET[ $page_key ], FILTER_VALIDATE_INT );
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;

$wrapper_attributes = get_block_wrapper_attributes();
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/blocks/query-pagination-previous.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
function render_block_core_query_pagination_previous( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : filter_var( $_GET[ $page_key ], FILTER_VALIDATE_INT );
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];

$wrapper_attributes = get_block_wrapper_attributes();
$default_label = __( '« Previous Page', 'gutenberg' );
$default_label = __( '« Previous Page' );
$label = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
$content = '';
// Check if the pagination is for Query that inherits the global context
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/blocks/social-link.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function render_block_core_social_link( $attributes, $content, $block ) {
$url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false;
$label = ( isset( $attributes['label'] ) ) ? $attributes['label'] : sprintf(
/* translators: %1$s: Social-network name. %2$s: URL. */
__( '%1$s: %2$s', 'gutenberg' ),
__( '%1$s: %2$s' ),
block_core_social_link_get_name( $service ),
$url
);
Expand Down
24 changes: 23 additions & 1 deletion src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,28 @@ function ( $carry, $element ) {
return $selector . '{' . $declaration_block . '}';
}

/**
* Function that appends a sub-selector to a existing one.
*
* Given the compounded $selector "h1, h2, h3"
* and the $to_append selector ".some-class" the result will be
* "h1.some-class, h2.some-class, h3.some-class".
*
* @param string $selector Original selector.
* @param string $to_append Selector to append.
*
* @return string
*/
private static function append_to_selector( $selector, $to_append ) {
$new_selectors = array();
$selectors = explode( ',', $selector );
foreach ( $selectors as $sel ) {
$new_selectors[] = $sel . $to_append;
}

return implode( ',', $new_selectors );
}

/**
* Given a settings array, it returns the generated rulesets
* for the preset classes.
Expand All @@ -633,7 +655,7 @@ private static function compute_preset_classes( $settings, $selector ) {
foreach ( $values as $value ) {
foreach ( $preset['classes'] as $class ) {
$stylesheet .= self::to_ruleset(
$selector . '.has-' . $value['slug'] . '-' . $class['class_suffix'],
self::append_to_selector( $selector, '.has-' . $value['slug'] . '-' . $class['class_suffix'] ),
array(
array(
'name' => $class['property_name'],
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ function _unhook_block_registration() {
remove_action( 'init', 'register_block_core_loginout' );
remove_action( 'init', 'register_block_core_latest_comments' );
remove_action( 'init', 'register_block_core_latest_posts' );
remove_action( 'init', 'register_block_core_legacy_widget', 20 );
remove_action( 'init', 'register_block_core_post_author' );
remove_action( 'init', 'register_block_core_post_content' );
remove_action( 'init', 'register_block_core_post_date' );
Expand All @@ -334,5 +333,6 @@ function _unhook_block_registration() {
remove_action( 'init', 'register_block_core_social_link' );
remove_action( 'init', 'register_block_core_tag_cloud' );
remove_action( 'init', 'register_core_block_types_from_metadata' );
remove_action( 'init', 'init_legacy_widget_block' );
}
tests_add_filter( 'init', '_unhook_block_registration', 1000 );
22 changes: 22 additions & 0 deletions tests/phpunit/tests/theme/wpThemeJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,28 @@ function test_get_editor_settings_no_theme_support() {
$this->assertEqualSetsWithIndex( $expected, $actual );
}

/**
* Function that appends a sub-selector to a existing one.
*
* Given the compounded $selector "h1, h2, h3"
* and the $to_append selector ".some-class" the result will be
* "h1.some-class, h2.some-class, h3.some-class".
*
* @param string $selector Original selector.
* @param string $to_append Selector to append.
*
* @return string
*/
private static function append_to_selector( $selector, $to_append ) {
$new_selectors = array();
$selectors = explode( ',', $selector );
foreach ( $selectors as $sel ) {
$new_selectors[] = $sel . $to_append;
}

return implode( ',', $new_selectors );
}

/**
* @ticket 52991
*/
Expand Down

0 comments on commit 7d91668

Please sign in to comment.