mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user