Changeset 50109
- Timestamp:
- 01/31/2021 12:48:24 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-comments-post.php
r49108 r50109 23 23 nocache_headers(); 24 24 25 $comment = wp_handle_comment_submission( wp_unslash( $_POST ) ); 26 if ( is_wp_error( $comment ) ) { 27 $data = (int) $comment->get_error_data(); 28 if ( ! empty( $data ) ) { 25 if ( isset( $_POST['wp-comment-approved-notification-optin'], $_POST['comment_ID'], $_POST['moderation-hash'] ) ) { 26 $comment = get_comment( $_POST['comment_ID'] ); 27 28 if ( $comment && hash_equals( $_POST['moderation-hash'], wp_hash( $comment->comment_date_gmt ) ) ) { 29 update_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ); 30 } else { 29 31 wp_die( 30 '<p>' . $comment->get_error_message() . '</p>',31 __( 'Comment Submission Failure' ),32 '<p>' . ) . '</p>', 33 __( 'Comment n Failure' ), 32 34 array( 33 'response' => $data,35 'response' => , 34 36 'back_link' => true, 35 37 ) 36 38 ); 37 } else {38 exit;39 39 } 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 40 72 } 41 42 $user = wp_get_current_user();43 $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) );44 45 /**46 * Perform other actions when comment cookies are set.47 *48 * @since 3.4.049 * @since 4.9.6 The `$cookies_consent` parameter was added.50 *51 * @param WP_Comment $comment Comment object.52 * @param WP_User $user Comment author's user object. The user may not exist.53 * @param bool $cookies_consent Comment author's consent to store cookies.54 */55 do_action( 'set_comment_cookies', $comment, $user, $cookies_consent );56 73 57 74 $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID; -
trunk/src/wp-includes/class-walker-comment.php
r49160 r50109 40 40 'id' => 'comment_ID', 41 41 ); 42 43 44 45 46 47 48 49 50 51 42 52 43 53 /** … … 256 266 * Filters the comment text. 257 267 * 258 * Removes links from the pending comment's text if the commenter did not consent 259 * to the comment cookies. 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 260 271 * 261 272 * @since 5.4.2 273 274 262 275 * 263 276 * @param string $comment_text Text of the current comment. … … 273 286 } 274 287 288 289 290 291 292 293 294 295 296 275 297 return $comment_text; 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 276 370 } 277 371 … … 298 392 $commenter = wp_get_current_commenter(); 299 393 $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 }306 394 ?> 307 395 <<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?> id="comment-<?php comment_ID(); ?>"> … … 329 417 ?> 330 418 </div> 331 <?php if ( '0' == $comment->comment_approved ) : ?> 332 <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em> 333 <br /> 334 <?php endif; ?> 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 ?> 335 427 336 428 <div class="comment-meta commentmetadata"> … … 402 494 $commenter = wp_get_current_commenter(); 403 495 $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 }410 496 ?> 411 497 <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>> … … 451 537 </div><!-- .comment-metadata --> 452 538 453 <?php if ( '0' == $comment->comment_approved ) : ?> 454 <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em> 455 <?php endif; ?> 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 ?> 456 546 </footer><!-- .comment-meta --> 457 547 -
trunk/src/wp-includes/comment.php
r49936 r50109 2350 2350 2351 2351 /** 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2352 2460 * Sets the status of a comment. 2353 2461 * -
trunk/src/wp-includes/default-filters.php
r50078 r50109 469 469 add_action( 'register_new_user', 'wp_send_new_user_notifications' ); 470 470 add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); 471 471 472 472 473 // REST API actions. -
trunk/tests/phpunit/tests/comment.php
r49603 r50109 553 553 self::$notify_message = $notify_message; 554 554 return $notify_message; 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 555 607 } 556 608
Note: See TracChangeset
for help on using the changeset viewer.