Editor: Update WordPress packages for 6.0 Beta 4

Included cherry-picked commits from the Gutenberg plugin that fix bugs discovere after WordPress 6.0 Beta 3.

Props zieladam, ndiego, darerodz.
See #55567.




git-svn-id: https://develop.svn.wordpress.org/trunk@53329 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski
2022-05-02 10:36:45 +00:00
parent 1b9551de27
commit e0837a8b18
11 changed files with 625 additions and 540 deletions

File diff suppressed because one or more lines are too long

View File

@@ -18,17 +18,16 @@ function render_block_core_comment_author_name( $attributes, $content, $block )
return '';
}
$comment = get_comment( $block->context['commentId'] );
$comment = get_comment( $block->context['commentId'] );
$commenter = wp_get_current_commenter();
$show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author'];
if ( empty( $comment ) ) {
return '';
}
$classes = '';
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . esc_attr( $attributes['textAlign'] );
}
if ( isset( $attributes['fontSize'] ) ) {
$classes .= 'has-' . esc_attr( $attributes['fontSize'] ) . '-font-size';
$classes .= 'has-text-align-' . $attributes['textAlign'];
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
@@ -38,6 +37,9 @@ function render_block_core_comment_author_name( $attributes, $content, $block )
if ( ! empty( $attributes['isLink'] ) && ! empty( $attributes['linkTarget'] ) ) {
$comment_author = sprintf( '<a rel="external nofollow ugc" href="%1s" target="%2s" >%3s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $comment_author );
}
if ( '0' === $comment->comment_approved && ! $show_pending_links ) {
$comment_author = wp_kses( $comment_author, array() );
}
return sprintf(
'<div %1$s>%2$s</div>',

View File

@@ -18,16 +18,37 @@ function render_block_core_comment_content( $attributes, $content, $block ) {
return '';
}
$comment = get_comment( $block->context['commentId'] );
$comment = get_comment( $block->context['commentId'] );
$commenter = wp_get_current_commenter();
$show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author'];
if ( empty( $comment ) ) {
return '';
}
$comment_text = get_comment_text( $comment );
$args = array();
$comment_text = get_comment_text( $comment, $args );
if ( ! $comment_text ) {
return '';
}
/** This filter is documented in wp-includes/comment-template.php */
$comment_text = apply_filters( 'comment_text', $comment_text, $comment, $args );
$moderation_note = '';
if ( '0' === $comment->comment_approved ) {
$commenter = wp_get_current_commenter();
if ( $commenter['comment_author_email'] ) {
$moderation_note = __( 'Your comment is awaiting moderation.' );
} else {
$moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.' );
}
$moderation_note = '<p><em class="comment-awaiting-moderation">' . $moderation_note . '</em></p>';
if ( ! $show_pending_links ) {
$comment_text = wp_kses( $comment_text, array() );
}
}
$classes = '';
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . $attributes['textAlign'];
@@ -36,8 +57,9 @@ function render_block_core_comment_content( $attributes, $content, $block ) {
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
return sprintf(
'<div %1$s>%2$s</div>',
'<div %1$s>%2$s%3$s</div>',
$wrapper_attributes,
$moderation_note,
$comment_text
);
}

View File

@@ -29,11 +29,18 @@ function render_block_core_comments_title( $attributes ) {
return;
}
$single_default_comment_label = $show_post_title ? __( 'One response to' ) : __( 'One response' );
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;
$single_default_comment_label = $show_post_title ? __( 'Response to' ) : __( 'Response' );
if ( $show_comments_count ) {
$single_default_comment_label = $show_post_title ? __( 'One response to' ) : __( 'One response' );
}
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;
$multiple_default_comment_label = $show_post_title ? __( 'Responses to' ) : __( 'Responses' );
$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;
if ( $show_comments_count ) {
$multiple_default_comment_label = $show_post_title ? __( 'responses to' ) : __( 'responses' );
}
$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;
$comments_title = '%1$s %2$s %3$s';
@@ -53,9 +60,9 @@ function render_block_core_comments_title( $attributes ) {
);
}
/**
* Registers the `core/comments-title` block on the server.
*/
/**
* Registers the `core/comments-title` block on the server.
*/
function register_block_core_comments_title() {
register_block_type_from_metadata(
__DIR__ . '/comments-title',
@@ -65,4 +72,4 @@ function register_block_core_comments_title() {
);
}
add_action( 'init', 'register_block_core_comments_title' );
add_action( 'init', 'register_block_core_comments_title' );

View File

@@ -40,7 +40,7 @@ function render_block_core_cover( $attributes, $content ) {
$object_position = '';
if ( isset( $attributes['focalPoint'] ) ) {
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' .
round( $attributes['focalPoint']['x'] * 100 ) . '%';
round( $attributes['focalPoint']['y'] * 100 ) . '%';
}
$image_template = '<img

View File

@@ -25,10 +25,14 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) {
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );
ob_start();
comment_form( array(), $block->context['postId'] );
$form = ob_get_clean();
remove_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );
// We use the outermost wrapping `<div />` returned by `comment_form()`
// which is identified by its default classname `comment-respond` to inject
// our wrapper attributes. This way, it is guaranteed that all styling applied
@@ -70,4 +74,3 @@ function post_comments_form_block_form_defaults( $fields ) {
return $fields;
}
add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );