Preview for both drafts and published posts/pages

git-svn-id: https://develop.svn.wordpress.org/trunk@9451 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2008-10-31 22:47:07 +00:00
parent faf3019a0b
commit 78b8de31b6
11 changed files with 154 additions and 9 deletions
+24
View File
@@ -80,6 +80,8 @@ function redirect_post($post_ID = '') {
if ( isset( $_POST['deletepost'] ) )
$action = 'delete';
elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
$action = 'preview';
switch($action) {
case 'postajaxpost':
@@ -218,6 +220,28 @@ case 'delete':
exit();
break;
case 'preview':
check_admin_referer( 'autosave', 'autosavenonce' );
if ( empty($_POST['post_title']) )
wp_die( __('Please enter a title before previewing this post.') );
$id = post_preview();
if ( is_wp_error($id) )
wp_die( $id->get_error_message() );
if ( $_POST['post_status'] == 'publish' ) {
$nonce = wp_create_nonce('post_preview_' . $id);
$url = site_url('?wp_preview=' . $id . '&preview_nonce=' . $nonce);
} else {
$url = site_url('?p=' . $id . '&preview=true');
}
wp_redirect($url);
exit();
break;
default:
wp_redirect('edit.php');
exit();