wp_untrash_post_comments

Definition:
function wp_untrash_post_comments($post = null) {}

Restore comments for a post from the trash

Parameters

  • int $post: Post ID or object.

Return values

returns:False on failure

Defined actions

  • untrash_post_comments
    do_action('untrash_post_comments', $post_id);
  • untrashed_post_comments
    do_action('untrashed_post_comments', $post_id);

Source code

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);

}

4209

wp_untrash_post

Definition:
function wp_untrash_post($post_id = 0) {}

Restores a post or page from the Trash

Parameters

  • int $post_id: Post ID.

Return values

returns:False on failure

Defined actions

  • untrash_post
    do_action('untrash_post', $post_id);
  • untrashed_post
    do_action('untrashed_post', $post_id);

Source code

function wp_untrash_post($post_id = 0) {

	if ( !$post = wp_get_single_post($post_id, ARRAY_A) )

		return $post;



	if ( $post['post_status'] != 'trash' )

		return false;



	do_action('untrash_post', $post_id);



	$post_status = get_post_meta($post_id, '_wp_trash_meta_status', true);



	$post['post_status'] = $post_status;



	delete_post_meta($post_id, '_wp_trash_meta_status');

	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);



	return $post;

}

4207

wp_untrash_comment

Definition:
function wp_untrash_comment($comment_id) {}

Removes a comment from the Trash

Parameters

  • int $comment_id: Comment ID.

Return values

returns:False on failure

Defined actions

  • untrash_comment
    do_action('untrash_comment', $comment_id);
  • untrashed_comment
    do_action('untrashed_comment', $comment_id);

Source code

function wp_untrash_comment($comment_id) {

	if ( ! (int)$comment_id )

		return false;



	do_action('untrash_comment', $comment_id);



	$status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);

	if ( empty($status) )

		$status = '0';



	if ( wp_set_comment_status($comment_id, $status) ) {

		delete_comment_meta($comment_id, '_wp_trash_meta_time');

		delete_comment_meta($comment_id, '_wp_trash_meta_status');

		do_action('untrashed_comment', $comment_id);

		return true;

	}



	return false;

}

4205

wp_unspam_comment

Definition:
function wp_unspam_comment($comment_id) {}

Removes a comment from the Spam

Parameters

  • int $comment_id: Comment ID.

Return values

returns:False on failure

Defined actions

  • unspam_comment
    do_action('unspam_comment', $comment_id);
  • unspammed_comment
    do_action('unspammed_comment', $comment_id);

Source code

function wp_unspam_comment($comment_id) {

	if ( ! (int)$comment_id )

		return false;



	do_action('unspam_comment', $comment_id);



	$status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);

	if ( empty($status) )

		$status = '0';



	if ( wp_set_comment_status($comment_id, $status) ) {

		delete_comment_meta($comment_id, '_wp_trash_meta_status');

		do_action('unspammed_comment', $comment_id);

		return true;

	}



	return false;

}

4203

wp_unschedule_event

Definition:
function wp_unschedule_event( $timestamp, $hook, $args = array() {}

Unschedule a previously scheduled cron job.
The $timestamp and $hook parameters are required, so that the event can be identified.

Parameters

  • int $timestamp: Timestamp for when to run the event.
  • string $hook: Action hook, the execution of which will be unscheduled.
  • array $args: Arguments to pass to the hook’s callback function. Although not passed to a callback function, these arguments are used to uniquely identify the scheduled event, so they should be the same as those used when originally scheduling the event.

Source code

function wp_unschedule_event( $timestamp, $hook, $args = array() ) {

	$crons = _get_cron_array();

	$key = md5(serialize($args));

	unset( $crons[$timestamp][$hook][$key] );

	if ( empty($crons[$timestamp][$hook]) )

		unset( $crons[$timestamp][$hook] );

	if ( empty($crons[$timestamp]) )

		unset( $crons[$timestamp] );

	_set_cron_array( $crons );

}

4201