Changeset 50375 for trunk/src/wp-includes/class-walker-comment.php
- Timestamp:
- 02/17/2021 01:06:43 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-walker-comment.php
r50109 r50375 40 40 'id' => 'comment_ID', 41 41 ); 42 43 /**44 * Whether the comment approval notification opt-in form or message needs to be45 * output automatically.46 *47 * @since 5.7.048 *49 * @var bool50 */51 protected $needs_comment_approval_notification_output = true;52 42 53 43 /** … … 266 256 * Filters the comment text. 267 257 * 268 * - Removes links from the pending comment's text if the commenter did not consent 269 * to the comment cookies 270 * - Prepends the approval notification opt-in form or message to pending comments 258 * Removes links from the pending comment's text if the commenter did not consent 259 * to the comment cookies. 271 260 * 272 261 * @since 5.4.2 273 * @since 5.7.0 Comment approval notification opt-in form is now automatically274 * appended if necessary.275 262 * 276 263 * @param string $comment_text Text of the current comment. … … 286 273 } 287 274 288 /*289 * Checks if we need to output the comment approval notification opt-in form.290 */291 if ( $this->needs_comment_approval_notification_output ) {292 $comment_text = $this->comment_approval_notification_form( $comment ) . "\n" . $comment_text;293 }294 295 $this->needs_comment_approval_notification_output = true;296 297 275 return $comment_text; 298 }299 300 /**301 * Outputs the awaiting moderation text.302 *303 * @since 5.7.0304 *305 * @param WP_Comment $comment Comment to display.306 */307 protected function awaiting_moderation_text( $comment ) {308 if ( '0' !== $comment->comment_approved ) {309 return;310 }311 312 $commenter = wp_get_current_commenter();313 314 if ( $commenter['comment_author_email'] ) {315 $moderation_note = __( 'Your comment is awaiting moderation.' );316 } else {317 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.' );318 }319 320 printf(321 '<em class="comment-awaiting-moderation">%s</em>',322 esc_html( $moderation_note )323 );324 }325 326 /**327 * Gets the comment approval notification opt-in form or message for a pending comment.328 *329 * @since 5.7.0330 *331 * @param WP_Comment $comment Comment to display.332 * @return string HTML output.333 */334 protected function comment_approval_notification_form( $comment ) {335 $comment_approval_output = '';336 337 if ( '0' === $comment->comment_approved && has_action( 'comment_unapproved_to_approved', 'wp_new_comment_notify_comment_author' ) ) {338 if ( get_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ) ) {339 $comment_approval_output = sprintf(340 '<p><em class="wp-comment-approved-notification-optedin">%s</em></p>',341 esc_html__( 'You will receive an email when your comment is approved.' )342 );343 } else {344 $comment_approval_output = sprintf(345 '<form action="%1$s" method="post">346 <p>347 <input type="checkbox" id="wp-comment-approved-notification-optin" name="wp-comment-approved-notification-optin">348 <label for="wp-comment-approved-notification-optin">349 %2$s350 </label>351 </p>352 <input type="hidden" name="comment_ID" value="%3$s">353 <input type="hidden" name="moderation-hash" value="%4$s">354 <input type="submit" class="button" value="%5$s">355 </form>',356 esc_url( site_url( '/wp-comments-post.php' ) ),357 esc_html__( 'I want to be notified by email when my comment is approved.' ),358 absint( $comment->comment_ID ),359 wp_hash( $comment->comment_date_gmt ),360 esc_html_x( 'Save', 'comment approval notification form' )361 );362 }363 }364 365 // Disable the backcompat output.366 $this->needs_comment_approval_notification_output = false;367 368 // Return the approval notification opt-in form.369 return $comment_approval_output;370 276 } 371 277 … … 392 298 $commenter = wp_get_current_commenter(); 393 299 $show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author']; 300 301 if ( $commenter['comment_author_email'] ) { 302 $moderation_note = __( 'Your comment is awaiting moderation.' ); 303 } else { 304 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.' ); 305 } 394 306 ?> 395 307 <<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?> id="comment-<?php comment_ID(); ?>"> … … 417 329 ?> 418 330 </div> 419 420 <?php 421 // Output the comment moderation feedback if needed. 422 $this->awaiting_moderation_text( $comment ); 423 424 // Output the comment approval notification opt-in form if needed. 425 echo $this->comment_approval_notification_form( $comment ); 426 ?> 331 <?php if ( '0' == $comment->comment_approved ) : ?> 332 <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em> 333 <br /> 334 <?php endif; ?> 427 335 428 336 <div class="comment-meta commentmetadata"> … … 494 402 $commenter = wp_get_current_commenter(); 495 403 $show_pending_links = ! empty( $commenter['comment_author'] ); 404 405 if ( $commenter['comment_author_email'] ) { 406 $moderation_note = __( 'Your comment is awaiting moderation.' ); 407 } else { 408 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.' ); 409 } 496 410 ?> 497 411 <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>> … … 537 451 </div><!-- .comment-metadata --> 538 452 539 <?php 540 // Output the comment moderation feedback if needed. 541 $this->awaiting_moderation_text( $comment ); 542 543 // Output the comment approval notification opt-in form if needed. 544 echo $this->comment_approval_notification_form( $comment ); 545 ?> 453 <?php if ( '0' == $comment->comment_approved ) : ?> 454 <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em> 455 <?php endif; ?> 546 456 </footer><!-- .comment-meta --> 547 457
Note: See TracChangeset
for help on using the changeset viewer.