wp_untrash_post_comments [ WordPress Function ]
wp_untrash_post_comments ( $post = null )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_trash_post_comments, wp_untrash_comment, wp_trash_comment, wp_untrash_post, wp_unspam_comment
Restore comments for a post from the trash
Source
<?php
function wp_untrash_post_comments($post = null) {
global $wpdb;
$post = get_post($post);
if ( empty($post) )
return;
$post_id = $post->ID;
$statuses = get_post_meta($post_id, '_wp_trash_meta_comments_status', true);
if ( empty($statuses) )
return true;
do_action('untrash_post_comments', $post_id);
// Restore each comment to its original status
$group_by_status = array();
foreach ( $statuses as $comment_id => $comment_status )
$group_by_status[$comment_status][] = $comment_id;
foreach ( $group_by_status as $status => $comments ) {
// Sanity check. This shouldn't happen.
if ( 'post-trashed' == $status )
$status = '0';
$comments_in = implode( "', '", $comments );
$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = '$status' WHERE comment_ID IN ('" . $comments_in . "')" );
}
clean_comment_cache( array_keys($statuses) );
delete_post_meta($post_id, '_wp_trash_meta_comments_status');
do_action('untrashed_post_comments', $post_id);
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- wp_untrash_post_comments() WordPress function reference ...
wp_untrash_post_comments(). Restore comments for a post from the trash. Signature. wp_untrash_post_comments( $post = null ). post: (int) Post ID or object.
queryposts.com - wp_untrash_post() WordPress function reference, arguments and ...
... delete_post_meta($post_id, '_wp_trash_meta_time'); wp_insert_post($post); wp_untrash_post_comments($post_id); do_action('untrashed_post', $post_id); ...
queryposts.com - wp_untrash_post (WordPress Function) - WPSeek.com
delete_post_meta($post_id, '_wp_trash_meta_time'); wp_insert_post($post); wp_untrash_post_comments($post_id); do_action('untrashed_post', $post_id); ...
wpseek.com - actions - Is there a recover_post hook to go with trash_post hook ...
May 4, 2012... wp_insert_post($post); wp_untrash_post_comments($post_id); do_action(' untrashed_post', $post_id); return $post; } ...
wordpress.stackexchange.com