wp_transition_comment_status [ WordPress Function ]
| Parameters: |
|
| Defined at: |
|
Call hooks for when a comment status transition occurs.
Calls hooks for comment status transitions. If the new comment status is not the same as the previous comment status, then two hooks will be ran, the first is 'transition_comment_status' with new status, old status, and comment data. The next action called is 'comment_OLDSTATUS_to_NEWSTATUS' the NEWSTATUS is the $new_status parameter and the OLDSTATUS is $old_status parameter; it has the comment data.
The final action will run whether or not the comment statuses are the same. The action is named 'comment_NEWSTATUS_COMMENTTYPE', NEWSTATUS is from the $new_status parameter and COMMENTTYPE is comment_type comment data.
Source
<?php
function wp_transition_comment_status($new_status, $old_status, $comment) {
// Translate raw statuses to human readable formats for the hooks
// This is not a complete list of comment status, it's only the ones that need to be renamed
$comment_statuses = array(
0 => 'unapproved',
'hold' => 'unapproved', // wp_set_comment_status() uses "hold"
1 => 'approved',
'approve' => 'approved', // wp_set_comment_status() uses "approve"
);
if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status];
if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status];
// Call the hooks
if ( $new_status != $old_status ) {
do_action('transition_comment_status', $new_status, $old_status, $comment);
do_action("comment_{$old_status}_to_{$new_status}", $comment);
}
do_action("comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment);
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/wp transition comment status « WordPress Codex
Description. Call hooks for when a comment status transition occurs. Calls hooks for comment status transitions. If the new comment status is not the same as the ...
codex.wordpress.org - Function Reference/wp set comment status « WordPress Codex
Uses: wp_transition_comment_status() Passes new and old comment status along with $comment object; Uses: wp_notify_postauthor(); Uses: get_option() ...
codex.wordpress.org - #16365 (Comment transition for new comments) – WordPress Trac
So here's why I said maybe regarding 3.3, and definite no regarding 3.2: I'm not sure I like it. wp_transition_comment_status() is for transitioning a comment ...
core.trac.wordpress.org - wp_set_comment_status (WordPress Function) - WPSeek.com
(bool) $wp_error Whether to return a WP_Error object if there is a failure. Default is false. Uses: wp_transition_comment_status(). Returns: (bool) False on failure ...
wpseek.com