| @@ -17,18 +17,39 @@ | ||
| 17 | 17 | if ( ! isset( $block->context['commentId'] ) ) { |
| 18 | 18 | return ''; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - $comment = get_comment( $block->context['commentId'] ); | |
| 21 | + $comment = get_comment( $block->context['commentId'] ); | |
| 22 | + $commenter = wp_get_current_commenter(); | |
| 23 | + $show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author']; | |
| 22 | 24 | if ( empty( $comment ) ) { |
| 23 | 25 | return ''; |
| 24 | 26 | } |
| 25 | 27 | |
| 26 | - $comment_text = get_comment_text( $comment ); | |
| 28 | + $args = array(); | |
| 29 | + $comment_text = get_comment_text( $comment, $args ); | |
| 27 | 30 | if ( ! $comment_text ) { |
| 28 | 31 | return ''; |
| 29 | 32 | } |
| 30 | 33 | |
| 34 | + /** This filter is documented in wp-includes/comment-template.php */ | |
| 35 | + $comment_text = apply_filters( 'comment_text', $comment_text, $comment, $args ); | |
| 36 | + | |
| 37 | + $moderation_note = ''; | |
| 38 | + if ( '0' === $comment->comment_approved ) { | |
| 39 | + $commenter = wp_get_current_commenter(); | |
| 40 | + | |
| 41 | + if ( $commenter['comment_author_email'] ) { | |
| 42 | + $moderation_note = __( 'Your comment is awaiting moderation.' ); | |
| 43 | + } else { | |
| 44 | + $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.' ); | |
| 45 | + } | |
| 46 | + $moderation_note = '<p><em class="comment-awaiting-moderation">' . $moderation_note . '</em></p>'; | |
| 47 | + if ( ! $show_pending_links ) { | |
| 48 | + $comment_text = wp_kses( $comment_text, array() ); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + | |
| 31 | 52 | $classes = ''; |
| 32 | 53 | if ( isset( $attributes['textAlign'] ) ) { |
| 33 | 54 | $classes .= 'has-text-align-' . $attributes['textAlign']; |
| 34 | 55 | } |
| @@ -35,10 +56,11 @@ | ||
| 35 | 56 | |
| 36 | 57 | $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); |
| 37 | 58 | |
| 38 | 59 | return sprintf( |
| 39 | - '<div %1$s>%2$s</div>', | |
| 60 | + '<div %1$s>%2$s%3$s</div>', | |
| 40 | 61 | $wrapper_attributes, |
| 62 | + $moderation_note, | |
| 41 | 63 | $comment_text |
| 42 | 64 | ); |
| 43 | 65 | } |
| 44 | 66 | |