Esempio n. 1
0
/**
 * Deletes a revision.
 *
 * Deletes the row from the posts table corresponding to the specified revision.
 *
 * @package NXTClass
 * @subpackage Post_Revisions
 * @since 2.6.0
 *
 * @uses nxt_get_post_revision()
 * @uses nxt_delete_post()
 *
 * @param int|object $revision_id Revision ID or revision object.
 * @return mixed Null or nxt_Error if error, deleted post if success.
 */
function nxt_delete_post_revision($revision_id)
{
    if (!($revision = nxt_get_post_revision($revision_id))) {
        return $revision;
    }
    $delete = nxt_delete_post($revision->ID);
    if (is_nxt_error($delete)) {
        return $delete;
    }
    if ($delete) {
        do_action('nxt_delete_post_revision', $revision->ID, $revision);
    }
    return $delete;
}
Esempio n. 2
0
             break;
         }
     }
     if ($left_revision->ID == $right_revision->ID || !nxt_get_post_revision($left_revision->ID) && !nxt_get_post_revision($right_revision->ID)) {
         break;
     }
     $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
     $h2 = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;'), $post_title);
     $title = __('Revisions');
     $left = $left_revision->ID;
     $right = $right_revision->ID;
     $redirect = false;
     break;
 case 'view':
 default:
     if (!($revision = nxt_get_post_revision($revision_id))) {
         break;
     }
     if (!($post = get_post($revision->post_parent))) {
         break;
     }
     if (!current_user_can('read_post', $revision->ID) || !current_user_can('read_post', $post->ID)) {
         break;
     }
     // Revisions disabled and we're not looking at an autosave
     if ((!nxt_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions')) && !nxt_is_post_autosave($revision)) {
         $redirect = 'edit.php?post_type=' . $post->post_type;
         break;
     }
     $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
     $revision_title = nxt_post_revision_title($revision, false);