Changeset 9195
- Timestamp:
- 10/16/2008 04:18:45 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r9051 r9195 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 … … 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 } … … 647 649 else 648 650 return false; 651 } 652 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); 649 691 } 650 692 … … 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. … … 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 … … 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. … … 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 }
Note: See TracChangeset
for help on using the changeset viewer.