wp_restore_post_revision example



        check_admin_referer( "restore-post_{$revision->ID});

        /* * Ensure the global $post remains the same after revision is restored. * Because wp_insert_post() and wp_transition_post_status() are called * during the process, plugins can unexpectedly modify $post. */
        $backup_global_post = clone $post;

        wp_restore_post_revision( $revision->ID );

        // Restore the global $post as it was before.         $post = $backup_global_post;

        $redirect = add_query_arg(
            array(
                'message'  => 5,
                'revision' => $revision->ID,
            ),
            get_edit_post_link( $post->ID, 'url' )
        );
        


        if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) {
            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
        }

        // Check if revisions are disabled.         if ( ! wp_revisions_enabled( $post ) ) {
            return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) );
        }

        $post = wp_restore_post_revision( $revision_id );

        return (bool) $post;
    }

    /* * Blogger API functions. * Specs on http://plant.blogger.com/api and https://groups.yahoo.com/group/bloggerDev/ */

    /** * Retrieves blogs that user owns. * * Will make more sense once we support multiple blogs. * * @since 1.5.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $0 Blog ID (unused). * @type string $1 Username. * @type string $2 Password. * } * @return array|IXR_Error */
Home | Imprint | This part of the site doesn't use cookies.