WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

wp_untrash_post() WP 2.9.0

Restore a post or page from the Trash.

Хуки из функции
Возвращает

WP_Post/false/null. Post data on success, false or null on failure.

Использование

wp_untrash_post( $post_id );
$post_id(число)
Post ID.
По умолчанию: ID of the global $post

Список изменений

С версии 2.9.0 Введена.

Код wp_untrash_post() WP 5.5.2

<?php
function wp_untrash_post( $post_id = 0 ) {
	$post = get_post( $post_id );

	if ( ! $post ) {
		return $post;
	}

	if ( 'trash' !== $post->post_status ) {
		return false;
	}

	/**
	 * Filters whether a post untrashing should take place.
	 *
	 * @since 4.9.0
	 *
	 * @param bool|null $untrash Whether to go forward with untrashing.
	 * @param WP_Post   $post    Post object.
	 */
	$check = apply_filters( 'pre_untrash_post', null, $post );
	if ( null !== $check ) {
		return $check;
	}

	/**
	 * Fires before a post is restored from the Trash.
	 *
	 * @since 2.9.0
	 *
	 * @param int $post_id Post ID.
	 */
	do_action( 'untrash_post', $post_id );

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

	delete_post_meta( $post_id, '_wp_trash_meta_status' );
	delete_post_meta( $post_id, '_wp_trash_meta_time' );

	$post_updated = wp_update_post(
		array(
			'ID'          => $post_id,
			'post_status' => $post_status,
		)
	);

	if ( ! $post_updated ) {
		return false;
	}

	wp_untrash_post_comments( $post_id );

	/**
	 * Fires after a post is restored from the Trash.
	 *
	 * @since 2.9.0
	 *
	 * @param int $post_id Post ID.
	 */
	do_action( 'untrashed_post', $post_id );

	return $post;
}