Undelete post (untrash)?

There is not wp_undelete_post but you have other choices:

  • wp_untrash_post(): when post is trashed, the previous status is stored in _wp_trash_meta_status meta field. wp_untrash_post() restore trashed posts to previous status whatever it was; for example, private, inherit, publish. I’ve not tested it but it should work with a custom post status as well.
  • wp_publish_post(): if you want to move from trash to publish status.
  • wp_update_post(): to move from trash to any other status.

For example, for a given post ID (of any post type, including pages):

if( get_post_status( $post_ID ) == "trash" ) {
    wp_update_post( array(
                   'ID'           => $post_ID,
                   'post_status'  => 'publish'
               )
    );
}

or:

if( get_post_status( $post_ID ) == "trash" ) {
    wp_publish_post( $post_ID );
}

or:

if( get_post_status( $post_ID ) == "trash" ) {
    wp_untrash_post( $post_ID );
}