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 @wordpress JavaScript packages for WordPress 6.0 Beta1 release #2564

Closed
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
df05315
Update WordPress packages, backport new blocks and updates to the exi…
adamziel Apr 11, 2022
1c63bca
Adjust webpack configuration to reflect changes from Gutenberg
adamziel Apr 11, 2022
c50d107
Regenerate package-lock.json after rebasing
adamziel Apr 11, 2022
219118a
Normalize the HTML to replace wp_unique_id in certain classnames with 1
adamziel Apr 12, 2022
be58de1
Normalize the gallery block classname of wp_unique_id( 'wp-block-gall…
adamziel Apr 12, 2022
c46bb9c
Add the newly expected wp-container-1 CSS class to column block fixtures
adamziel Apr 12, 2022
64b6316
Add the newly expected wp-container-1 CSS class to columns block fixt…
adamziel Apr 12, 2022
69e816f
Add the newly expected wp-container-1 CSS class to gallery block fix…
adamziel Apr 12, 2022
c2d2786
Add the newly expected wp-iblock-gallery-1 CSS class to gallery bloc…
adamziel Apr 12, 2022
900cc89
Add the missing CSS classes to the gallery columns fixture
adamziel Apr 12, 2022
7210e61
Add the newly expected wp-container-1 CSS class to the deprecated co…
adamziel Apr 12, 2022
ea0ebab
Update the packages to their latest versions
adamziel Apr 12, 2022
a36b1ec
Update script-loader-packages.php
adamziel Apr 12, 2022
8b62f1a
Update React to 17.0.2
adamziel Apr 12, 2022
735f987
Set IS_GUTENBERG_PLUGIN to false
adamziel Apr 12, 2022
e639a16
Rebuild dev packages
adamziel Apr 12, 2022
5e0bbf4
Add the missing post-author-biography block
adamziel Apr 12, 2022
c81b6a3
Add the missing blocks to blocks/index.php
adamziel Apr 12, 2022
2b5dc92
Remove unnecessary self-require
adamziel Apr 12, 2022
2aa44a3
remove reinitialization of block registration
adamziel Apr 12, 2022
afa9ad8
Add two missing remove_action hooks
adamziel Apr 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,624 changes: 1,585 additions & 2,039 deletions package-lock.json

Large diffs are not rendered by default.

113 changes: 57 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
"@wordpress/babel-preset-default": "6.8.0",
"@wordpress/dependency-extraction-webpack-plugin": "3.4.1",
"@wordpress/e2e-test-utils": "5.4.10",
"@wordpress/e2e-test-utils": "7.2.0",
"@wordpress/scripts": "22.4.0",
"autoprefixer": "^9.8.8",
"chalk": "4.1.2",
Expand Down Expand Up @@ -76,59 +76,60 @@
"webpack-livereload-plugin": "3.0.2"
},
"dependencies": {
"@wordpress/a11y": "3.2.4",
"@wordpress/annotations": "2.2.9",
"@wordpress/api-fetch": "5.2.6",
"@wordpress/autop": "3.2.3",
"@wordpress/blob": "3.2.2",
"@wordpress/block-directory": "3.0.27",
"@wordpress/block-editor": "8.0.17",
"@wordpress/block-library": "6.0.26",
"@wordpress/block-serialization-default-parser": "4.2.3",
"@wordpress/blocks": "11.1.5",
"@wordpress/components": "19.2.3",
"@wordpress/compose": "5.0.7",
"@wordpress/core-data": "4.0.10",
"@wordpress/customize-widgets": "2.0.27",
"@wordpress/data": "6.1.5",
"@wordpress/data-controls": "2.2.8",
"@wordpress/date": "4.2.3",
"@wordpress/deprecated": "3.2.3",
"@wordpress/dom": "3.2.7",
"@wordpress/dom-ready": "3.2.3",
"@wordpress/edit-post": "5.0.27",
"@wordpress/edit-site": "3.0.27",
"@wordpress/edit-widgets": "3.1.22",
"@wordpress/editor": "12.0.21",
"@wordpress/element": "4.0.4",
"@wordpress/escape-html": "2.2.3",
"@wordpress/format-library": "3.0.23",
"@wordpress/hooks": "3.2.2",
"@wordpress/html-entities": "3.2.3",
"@wordpress/i18n": "4.2.4",
"@wordpress/icons": "6.1.1",
"@wordpress/interface": "4.1.18",
"@wordpress/is-shallow-equal": "4.2.1",
"@wordpress/keyboard-shortcuts": "3.0.7",
"@wordpress/keycodes": "3.2.4",
"@wordpress/list-reusable-blocks": "3.0.20",
"@wordpress/media-utils": "3.0.5",
"@wordpress/notices": "3.2.8",
"@wordpress/nux": "5.0.20",
"@wordpress/plugins": "4.0.7",
"@wordpress/primitives": "3.0.4",
"@wordpress/priority-queue": "2.2.3",
"@wordpress/redux-routine": "4.2.2",
"@wordpress/reusable-blocks": "3.0.23",
"@wordpress/rich-text": "5.0.8",
"@wordpress/server-side-render": "3.0.20",
"@wordpress/shortcode": "3.2.3",
"@wordpress/token-list": "2.2.2",
"@wordpress/url": "3.3.1",
"@wordpress/viewport": "4.0.7",
"@wordpress/warning": "2.2.2",
"@wordpress/widgets": "2.0.23",
"@wordpress/wordcount": "3.2.3",
"@wordpress/a11y": "3.6.0",
"@wordpress/annotations": "2.6.0",
"@wordpress/api-fetch": "6.3.0",
"@wordpress/autop": "3.6.0",
"@wordpress/blob": "3.6.0",
"@wordpress/block-directory": "3.4.1",
"@wordpress/block-editor": "8.5.1",
"@wordpress/block-library": "7.3.1",
"@wordpress/block-serialization-default-parser": "4.6.0",
"@wordpress/blocks": "11.5.1",
"@wordpress/components": "19.8.0",
"@wordpress/compose": "5.4.0",
"@wordpress/core-data": "4.4.1",
"@wordpress/customize-widgets": "3.3.1",
"@wordpress/data": "6.6.0",
"@wordpress/data-controls": "2.6.0",
"@wordpress/date": "4.6.0",
"@wordpress/deprecated": "3.6.0",
"@wordpress/dom": "3.6.0",
"@wordpress/dom-ready": "3.6.0",
"@wordpress/edit-post": "6.3.1",
"@wordpress/edit-site": "4.3.1",
"@wordpress/edit-widgets": "4.3.1",
"@wordpress/editor": "12.5.1",
"@wordpress/element": "4.4.0",
"@wordpress/escape-html": "2.6.0",
"@wordpress/format-library": "3.4.1",
"@wordpress/hooks": "3.6.0",
"@wordpress/html-entities": "3.6.0",
"@wordpress/i18n": "4.6.0",
"@wordpress/icons": "8.2.0",
"@wordpress/interface": "4.5.0",
"@wordpress/is-shallow-equal": "4.6.0",
"@wordpress/keyboard-shortcuts": "3.4.0",
"@wordpress/keycodes": "3.6.0",
"@wordpress/list-reusable-blocks": "3.4.0",
"@wordpress/media-utils": "3.4.0",
"@wordpress/notices": "3.6.0",
"@wordpress/nux": "5.4.0",
"@wordpress/plugins": "4.4.0",
"@wordpress/preferences": "1.2.0",
"@wordpress/primitives": "3.4.0",
"@wordpress/priority-queue": "2.6.0",
"@wordpress/redux-routine": "4.6.0",
"@wordpress/reusable-blocks": "3.4.1",
"@wordpress/rich-text": "5.4.0",
"@wordpress/server-side-render": "3.4.1",
"@wordpress/shortcode": "3.6.0",
"@wordpress/token-list": "2.6.0",
"@wordpress/url": "3.7.0",
"@wordpress/viewport": "4.4.0",
"@wordpress/warning": "2.6.0",
"@wordpress/widgets": "2.4.1",
"@wordpress/wordcount": "3.6.0",
adamziel marked this conversation as resolved.
Show resolved Hide resolved
"backbone": "1.4.0",
"clipboard": "2.0.8",
"core-js-url-browser": "3.6.4",
Expand All @@ -145,8 +146,8 @@
"moment": "2.29.1",
"objectFitPolyfill": "2.3.5",
"polyfill-library": "3.105.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"regenerator-runtime": "0.13.9",
"twemoji": "14.0.2",
"underscore": "1.13.1",
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/assets/script-loader-packages.php

Large diffs are not rendered by default.

22 changes: 9 additions & 13 deletions src/wp-includes/blocks/archives.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
*/
function render_block_core_archives( $attributes ) {
$show_post_count = ! empty( $attributes['showPostCounts'] );

$class = '';
$type = isset( $attributes['type'] ) ? $attributes['type'] : 'monthly';
$class = '';

if ( ! empty( $attributes['displayAsDropdown'] ) ) {

$class .= ' wp-block-archives-dropdown';

$dropdown_id = esc_attr( uniqid( 'wp-block-archives-' ) );
$dropdown_id = wp_unique_id( 'wp-block-archives-' );
$title = __( 'Archives' );

/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
$dropdown_args = apply_filters(
'widget_archives_dropdown_args',
array(
'type' => 'monthly',
'type' => $type,
'format' => 'option',
'show_post_count' => $show_post_count,
)
Expand Down Expand Up @@ -62,11 +62,9 @@ function render_block_core_archives( $attributes ) {
break;
}

$label = esc_html( $label );

$block_content = '<label for="' . $dropdown_id . '">' . $title . '</label>
<select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">' . $label . '</option>' . $archives . '</select>';
$block_content = '<label for="' . esc_attr( $dropdown_id ) . '">' . esc_html( $title ) . '</label>
<select id="' . esc_attr( $dropdown_id ) . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">' . esc_html( $label ) . '</option>' . $archives . '</select>';

return sprintf(
'<div %1$s>%2$s</div>',
Expand All @@ -81,7 +79,7 @@ function render_block_core_archives( $attributes ) {
$archives_args = apply_filters(
'widget_archives_args',
array(
'type' => 'monthly',
'type' => $type,
'show_post_count' => $show_post_count,
)
);
Expand All @@ -90,9 +88,7 @@ function render_block_core_archives( $attributes ) {

$archives = wp_get_archives( $archives_args );

$classnames = esc_attr( $class );

$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );

if ( empty( $archives ) ) {
return sprintf(
Expand Down
7 changes: 6 additions & 1 deletion src/wp-includes/blocks/archives/block.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/archives",
"title": "Archives",
"category": "widgets",
"description": "Display a monthly archive of your posts.",
"description": "Display a date archive of your posts.",
"textdomain": "default",
"attributes": {
"displayAsDropdown": {
Expand All @@ -13,6 +14,10 @@
"showPostCounts": {
"type": "boolean",
"default": false
},
"type": {
"type": "string",
"default": "monthly"
}
},
"supports": {
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/blocks/audio/block.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/audio",
"title": "Audio",
Expand Down
146 changes: 146 additions & 0 deletions src/wp-includes/blocks/avatar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
/**
* Server-side rendering of the `core/avatar` block.
*
* @package WordPress
*/

/**
* Renders the `core/avatar` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Return the avatar.
*/
function render_block_core_avatar( $attributes, $content, $block ) {
$size = isset( $attributes['size'] ) ? $attributes['size'] : 96;
$wrapper_attributes = get_block_wrapper_attributes();

$image_styles = array();

// Add border width styles.
$has_border_width = ! empty( $attributes['style']['border']['width'] );

if ( $has_border_width ) {
$border_width = $attributes['style']['border']['width'];
$image_styles[] = sprintf( 'border-width: %s;', esc_attr( $border_width ) );
}

// Add border radius styles.
$has_border_radius = ! empty( $attributes['style']['border']['radius'] );

if ( $has_border_radius ) {
$border_radius = $attributes['style']['border']['radius'];

if ( is_array( $border_radius ) ) {
// Apply styles for individual corner border radii.
foreach ( $border_radius as $key => $value ) {
if ( null !== $value ) {
$name = _wp_to_kebab_case( $key );
// Add shared styles for individual border radii.
$border_style = sprintf(
'border-%s-radius: %s;',
esc_attr( $name ),
esc_attr( $value )
);
$image_styles[] = $border_style;
}
}
} else {
$border_style = sprintf( 'border-radius: %s;', esc_attr( $border_radius ) );
$image_styles[] = $border_style;
}
}

// Add border color styles.
$has_border_color = ! empty( $attributes['style']['border']['color'] );

if ( $has_border_color ) {
$border_color = $attributes['style']['border']['color'];
$image_styles[] = sprintf( 'border-color: %s;', esc_attr( $border_color ) );
}

// Add border style (solid, dashed, dotted ).
$has_border_style = ! empty( $attributes['style']['border']['style'] );

if ( $has_border_style ) {
$border_style = $attributes['style']['border']['style'];
$image_styles[] = sprintf( 'border-style: %s;', esc_attr( $border_style ) );
}

// Add border classes to the avatar image for both custom colors and palette colors.
$image_classes = '';
if ( $has_border_color || isset( $attributes['borderColor'] ) ) {
$image_classes .= 'has-border-color';
}
if ( isset( $attributes['borderColor'] ) ) {
$image_classes .= ' has-' . $attributes['borderColor'] . '-border-color';
}

if ( ! isset( $block->context['commentId'] ) ) {
$author_id = isset( $attributes['userId'] ) ? $attributes['userId'] : get_post_field( 'post_author', $block->context['postId'] );
$author_name = get_the_author_meta( 'display_name', $author_id );
// translators: %s is the Author name.
$alt = sprintf( __( '%s Avatar' ), $author_name );
$avatar_block = get_avatar(
$author_id,
$size,
'',
$alt,
array(
'extra_attr' => isset( $image_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $image_styles ) ) ) : '',
'class' => "wp-block-avatar__image $image_classes ",
)
);
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$label = '';
if ( '_blank' === $attributes['linkTarget'] ) {
// translators: %s is the Author name.
$label = 'aria-label="' . sprintf( esc_attr__( '(%s author archive, opens in a new tab)' ), $author_name ) . '"';
}
// translators: %1$s: Author archive link. %2$s: Link target. %3$s Aria label. %4$s Avatar image.
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', get_author_posts_url( $author_id ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
}
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
}
$comment = get_comment( $block->context['commentId'] );
/* translators: %s is the Comment Author name */
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
if ( ! $comment ) {
return '';
}
$avatar_block = get_avatar(
$comment,
$size,
'',
$alt,
array(
'extra_attr' => isset( $image_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $image_styles ) ) ) : '',
'class' => "wp-block-avatar__image $image_classes",
)
);
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $comment->comment_author_url ) && '' !== $comment->comment_author_url ) {
$label = '';
if ( '_blank' === $attributes['linkTarget'] ) {
// translators: %s is the Comment Author name.
$label = 'aria-label="' . sprintf( esc_attr__( '(%s website link, opens in a new tab)' ), $comment->comment_author ) . '"';
}
// translators: %1$s: Comment Author website link. %2$s: Link target. %3$s Aria label. %4$s Avatar image.
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', $comment->comment_author_url, esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
}
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
}

/**
* Registers the `core/avatar` block on the server.
*/
function register_block_core_avatar() {
register_block_type_from_metadata(
__DIR__ . '/avatar',
array(
'render_callback' => 'render_block_core_avatar',
)
);
}
add_action( 'init', 'register_block_core_avatar' );
Loading