source/php/Unpublish.php
public function unpublishPost($postId, $action = 'trash')
    {
        $postStatus = get_post_status($postId);
        if (!in_array($postStatus, array('publish', 'private', 'password', 'draft'))) {
            return false;
        }

        switch ($action) {
            case 'draft':
                wp_update_post(array(
                    'ID' => (int)$postId,
                    'post_status' => 'draft'
                ));
                break;

            default:
                wp_trash_post($postId);
                break;
        }

        return true;
    }
public function unpublishPost($postId, $action = 'trash')
    {
        $postStatus = get_post_status($postId);
        if (!in_array($postStatus, array('publish', 'private', 'password', 'draft'))) {
            return false;
        }

        switch ($action) {
            case 'draft':
                wp_update_post(array(
                    'ID' => (int)$postId,
                    'post_status' => 'draft'
                ));
                break;

            default:
                wp_trash_post($postId);
                break;
        }

        return true;
    }
Does the actual unpublishing, called from cron
@param  integer $postId The post to unpublisch
@param  string $action  What to do with it (trash or draft)
@return boolean