]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/post.php
WordPress 4.3-scripts
[autoinstalls/wordpress.git] / wp-admin / post.php
index 805c46e6edf6e0461112c1d5196859eb567aba6a..89bdc38ce0476ac79469b8921478eea8cd8745c4 100644 (file)
@@ -23,7 +23,12 @@ elseif ( isset( $_POST['post_ID'] ) )
 else
        $post_id = $post_ID = 0;
 
-$post = $post_type = $post_type_object = null;
+/**
+ * @global string  $post_type
+ * @global object  $post_type_object
+ * @global WP_Post $post
+ */
+global $post_type, $post_type_object, $post;
 
 if ( $post_id )
        $post = get_post( $post_id );
@@ -54,7 +59,7 @@ function redirect_post($post_id = '') {
                                        $message = 6;
                        }
                } else {
-                               $message = 'draft' == $status ? 10 : 1;
+                       $message = 'draft' == $status ? 10 : 1;
                }
 
                $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
@@ -95,7 +100,9 @@ if ( ! $sendback ||
                $sendback = admin_url( 'upload.php' );
        } else {
                $sendback = admin_url( 'edit.php' );
-               $sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : '';
+               if ( ! empty( $post_type ) ) {
+                       $sendback = add_query_arg( 'post_type', $post_type, $sendback );
+               }
        }
 } else {
        $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
@@ -113,8 +120,9 @@ case 'post-quickdraft-save':
        if ( ! wp_verify_nonce( $nonce, 'add-post' ) )
                $error_msg = __( 'Unable to submit this form, please refresh and try again.' );
 
-       if ( ! current_user_can( 'edit_posts' ) )
-               $error_msg = __( 'Oops, you don’t have access to add new drafts.' );
+       if ( ! current_user_can( 'edit_posts' ) ) {
+               exit;
+       }
 
        if ( $error_msg )
                return wp_dashboard_quick_press( $error_msg );
@@ -122,8 +130,8 @@ case 'post-quickdraft-save':
        $post = get_post( $_REQUEST['post_ID'] );
        check_admin_referer( 'add-' . $post->post_type );
 
-       $_POST['comment_status'] = get_option( 'default_comment_status' );
-       $_POST['ping_status'] = get_option( 'default_ping_status' );
+       $_POST['comment_status'] = get_default_comment_status( $post->post_type );
+       $_POST['ping_status']    = get_default_comment_status( $post->post_type, 'pingback' );
 
        edit_post();
        wp_dashboard_quick_press();
@@ -157,6 +165,7 @@ case 'edit':
                wp_die( __( 'You can’t edit this item because it is in the Trash. Please restore it and try again.' ) );
 
        if ( ! empty( $_GET['get-post-lock'] ) ) {
+               check_admin_referer( 'lock-post_' . $post_id );
                wp_set_post_lock( $post_id );
                wp_redirect( get_edit_post_link( $post_id, 'url' ) );
                exit();
@@ -270,7 +279,7 @@ case 'untrash':
                wp_die( __( 'Unknown post type.' ) );
 
        if ( ! current_user_can( 'delete_post', $post_id ) )
-               wp_die( __( 'You are not allowed to move this item out of the Trash.' ) );
+               wp_die( __( 'You are not allowed to restore this item from the Trash.' ) );
 
        if ( ! wp_untrash_post( $post_id ) )
                wp_die( __( 'Error in restoring from Trash.' ) );