Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to the latest WP packages #1319

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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
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
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
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
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
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
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
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
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
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
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