-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Update @wordpress JavaScript packages for WordPress 6.0 Beta1 release #2564
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
Closed
adamziel
wants to merge
21
commits into
WordPress:trunk
from
adamziel:update/packages-for-6.0-beta-1
Closed
Changes from all 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 1c63bca
Adjust webpack configuration to reflect changes from Gutenberg
adamziel c50d107
Regenerate package-lock.json after rebasing
adamziel 219118a
Normalize the HTML to replace wp_unique_id in certain classnames with 1
adamziel be58de1
Normalize the gallery block classname of wp_unique_id( 'wp-block-gall…
adamziel c46bb9c
Add the newly expected wp-container-1 CSS class to column block fixtures
adamziel 64b6316
Add the newly expected wp-container-1 CSS class to columns block fixt…
adamziel 69e816f
Add the newly expected wp-container-1 CSS class to gallery block fix…
adamziel c2d2786
Add the newly expected wp-iblock-gallery-1 CSS class to gallery bloc…
adamziel 900cc89
Add the missing CSS classes to the gallery columns fixture
adamziel 7210e61
Add the newly expected wp-container-1 CSS class to the deprecated co…
adamziel ea0ebab
Update the packages to their latest versions
adamziel a36b1ec
Update script-loader-packages.php
adamziel 8b62f1a
Update React to 17.0.2
adamziel 735f987
Set IS_GUTENBERG_PLUGIN to false
adamziel e639a16
Rebuild dev packages
adamziel 5e0bbf4
Add the missing post-author-biography block
adamziel c81b6a3
Add the missing blocks to blocks/index.php
adamziel 2b5dc92
Remove unnecessary self-require
adamziel 2aa44a3
remove reinitialization of block registration
adamziel afa9ad8
Add two missing remove_action hooks
adamziel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.