Ticket #7894: 7894.2.patch
| File 7894.2.patch, 4.0 KB (added by , 18 years ago) |
|---|
-
wp-includes/comment.php
598 598 * @uses $wpdb 599 599 * @uses do_action() Calls 'delete_comment' hook on comment ID 600 600 * @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter 601 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object 601 602 * 602 603 * @param int $comment_id Comment ID 603 604 * @return bool False if delete comment query failure, true on success. … … 618 619 clean_comment_cache($comment_id); 619 620 620 621 do_action('wp_set_comment_status', $comment_id, 'delete'); 622 wp_transition_comment_status('delete', $comment->comment_approved, $comment); 621 623 return true; 622 624 } 623 625 … … 649 651 } 650 652 651 653 /** 654 * Call hooks for when a comment status transition occurs. 655 * 656 * Calls hooks for comment status transitions. If the new comment status is not the same 657 * as the previous comment status, then two hooks will be ran, the first is 658 * 'transition_comment_status' with new status, old status, and comment data. The 659 * next action called is 'comment_OLDSTATUS_to_NEWSTATUS' the NEWSTATUS is the 660 * $new_status parameter and the OLDSTATUS is $old_status parameter; it has the 661 * comment data. 662 * 663 * The final action will run whether or not the comment statuses are the same. The 664 * action is named 'comment_NEWSTATUS_COMMENTTYPE', NEWSTATUS is from the $new_status 665 * parameter and COMMENTTYPE is comment_type comment data. 666 * 667 * @since 2.7.0 668 * 669 * @param string $new_status New comment status. 670 * @param string $old_status Previous comment status. 671 * @param object $comment Comment data. 672 */ 673 function wp_transition_comment_status($new_status, $old_status, $comment) { 674 // Translate raw statuses to human readable formats for the hooks 675 // This is not a complete list of comment status, it's only the ones that need to be renamed 676 $comment_statuses = array( 677 0 => 'unapproved', 678 'hold' => 'unapproved', // wp_set_comment_status() uses "hold" 679 1 => 'approved', 680 'approve' => 'approved', // wp_set_comment_status() uses "approve" 681 ); 682 if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status]; 683 if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status]; 684 685 // Call the hooks 686 if ( $new_status != $old_status ) { 687 do_action('transition_comment_status', $new_status, $old_status, $comment); 688 do_action("comment_${old_status}_to_$new_status", $comment); 689 } 690 do_action("comment_${new_status}_$comment->comment_type", $comment->ID, $comment); 691 } 692 693 /** 652 694 * Get current commenter's name, email, and URL. 653 695 * 654 696 * Expects cookies content to already be sanitized. User of this function might … … 834 876 * action. 835 877 * 836 878 * @since 1.0.0 879 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object 837 880 * 838 881 * @param int $comment_id Comment ID. 839 882 * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'delete'. … … 868 911 869 912 clean_comment_cache($comment_id); 870 913 914 $comment = get_comment($comment_id); 915 871 916 do_action('wp_set_comment_status', $comment_id, $comment_status); 872 $comment = get_comment($comment_id); 917 wp_transition_comment_status($comment_status, $comment->comment_approved, $comment); 918 873 919 wp_update_comment_count($comment->comment_post_ID); 874 920 875 921 return true; … … 882 928 * 883 929 * @since 2.0.0 884 930 * @uses $wpdb 931 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object 885 932 * 886 933 * @param array $commentarr Contains information on the comment. 887 934 * @return int Comment was updated if value is 1, or was not updated if value is 0. … … 938 985 clean_comment_cache($comment_ID); 939 986 wp_update_comment_count($comment_post_ID); 940 987 do_action('edit_comment', $comment_ID); 988 wp_transition_comment_status($comment_approved, $comment->comment_approved, $comment); 941 989 return $rval; 942 990 } 943 991
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)