Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: untrash_post

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
3655      /**
3656       * Fires before a post is restored from the Trash.
3657       *
3658       * @since 2.9.0
3659       * @since 5.6.0 The `$previous_status` parameter was added.
3660       *
3661       * @param int    $post_id         Post ID.
3662       * @param string $previous_status The status of the post at the point where it was trashed.
3663       */
3664      do_action( 'untrash_post', $post_id, $previous_status );
3665
3666      $new_status = ( 'attachment' === $post->post_type ) ? 'inherit' : 'draft';
3667
3668      /**
3669       * Filters the status that a post gets assigned when it is restored from the trash (untrashed).
3670       *
3671       * By default posts that are restored will be assigned a status of 'draft'. Return the value of `$previous_status`
3672       * in order to assign the status that the post had before it was trashed. The `wp_untrash_post_set_previous_status()`
3673       * function is available for this.