X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/3e7fab96d7874067884348df10bbdcdefa4a89ad..9c40b4d36daed9e28e48a5fe9205c32557195a4b:/wp-admin/post.php
diff --git a/wp-admin/post.php b/wp-admin/post.php
index 680f8abe..008778fa 100644
--- a/wp-admin/post.php
+++ b/wp-admin/post.php
@@ -1,4 +1,14 @@
ID) ) wp_die( __("You attempted to edit a post that doesn't exist. Perhaps it was deleted?") );
+ if ( empty($post->ID) ) wp_die( __('You attempted to edit a post that doesn’t exist. Perhaps it was deleted?') );
- if ( 'page' == $post->post_type ) {
- wp_redirect("page.php?action=edit&post=$post_ID");
+ if ( 'post' != $post->post_type ) {
+ wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
exit();
}
- if($post->post_status == 'draft') {
- wp_enqueue_script('prototype');
- wp_enqueue_script('autosave');
+ wp_enqueue_script('post');
+ if ( user_can_richedit() )
+ wp_enqueue_script('editor');
+ add_thickbox();
+ wp_enqueue_script('media-upload');
+ wp_enqueue_script('word-count');
+ wp_enqueue_script( 'admin-comments' );
+ enqueue_comment_hotkeys_js();
+
+ if ( current_user_can('edit_post', $post_ID) ) {
+ if ( $last = wp_check_post_lock( $post->ID ) ) {
+ $last_user = get_userdata( $last );
+ $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
+ $message = sprintf( __( 'Warning: %s is currently editing this post' ), esc_html( $last_user_name ) );
+ $message = str_replace( "'", "\'", "
" );
+ add_action('admin_notices', create_function( '', "echo '$message';" ) );
+ } else {
+ wp_set_post_lock( $post->ID );
+ wp_enqueue_script('autosave');
+ }
}
- require_once('admin-header.php');
+
+ $title = __('Edit Post');
if ( !current_user_can('edit_post', $post_ID) )
die ( __('You are not allowed to edit this post.') );
@@ -94,49 +176,7 @@ case 'editpost':
$post_ID = edit_post();
- if ( 'post' == $_POST['originalaction'] ) {
- if (!empty($_POST['mode'])) {
- switch($_POST['mode']) {
- case 'bookmarklet':
- $location = $_POST['referredby'];
- break;
- case 'sidebar':
- $location = 'sidebar.php?a=b';
- break;
- default:
- $location = 'post-new.php';
- break;
- }
- } else {
- $location = "post-new.php?posted=$post_ID";
- }
-
- if ( isset($_POST['save']) )
- $location = "post.php?action=edit&post=$post_ID";
- } else {
- $referredby = '';
- if ( !empty($_POST['referredby']) )
- $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']);
- $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
-
- if ($_POST['save']) {
- $location = "post.php?action=edit&post=$post_ID";
- } elseif ($_POST['updatemeta']) {
- $location = wp_get_referer() . '&message=2#postcustom';
- } elseif ($_POST['deletemeta']) {
- $location = wp_get_referer() . '&message=3#postcustom';
- } elseif (!empty($referredby) && $referredby != $referer) {
- $location = $_POST['referredby'];
- if ( $_POST['referredby'] == 'redo' )
- $location = get_permalink( $post_ID );
- } elseif ($action == 'editattachment') {
- $location = 'attachments.php';
- } else {
- $location = 'post-new.php';
- }
- }
-
- wp_redirect($location); // Send user on their way while we keep working
+ redirect_post($post_ID); // Send user on their way while we keep working
exit();
break;
@@ -159,13 +199,22 @@ case 'delete':
}
$sendback = wp_get_referer();
- if (strpos($sendback, 'post.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/post-new.php';
- elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
- $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
+ if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?deleted=1');
+ elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
+ else $sendback = add_query_arg('deleted', 1, $sendback);
wp_redirect($sendback);
exit();
break;
+case 'preview':
+ check_admin_referer( 'autosave', 'autosavenonce' );
+
+ $url = post_preview();
+
+ wp_redirect($url);
+ exit();
+ break;
+
default:
wp_redirect('edit.php');
exit();