]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/post.php
Wordpress 3.1.3
[autoinstalls/wordpress.git] / wp-admin / includes / post.php
index 12cbaa0f92c21f0688fd6c67422f6735bf910551..bb6f469fccaa362587f22e24784bf18936ae04f5 100644 (file)
@@ -138,6 +138,7 @@ function edit_post( $post_data = null ) {
        $post_ID = (int) $post_data['post_ID'];
        $post = get_post( $post_ID );
        $post_data['post_type'] = $post->post_type;
+       $post_data['post_mime_type'] = $post->post_mime_type;
 
        $ptype = get_post_type_object($post_data['post_type']);
        if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) {
@@ -199,6 +200,8 @@ function edit_post( $post_data = null ) {
                                continue;
                        if ( $meta->post_id != $post_ID )
                                continue;
+                       if ( is_protected_meta( $value['key'] ) )
+                               continue;
                        update_meta( $key, $value['key'], $value['value'] );
                }
        }
@@ -209,6 +212,8 @@ function edit_post( $post_data = null ) {
                                continue;
                        if ( $meta->post_id != $post_ID )
                                continue;
+                       if ( is_protected_meta( $meta->meta_key ) )
+                               continue;
                        delete_meta( $key );
                }
        }
@@ -527,6 +532,8 @@ function wp_write_post() {
                        return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
        }
 
+       $_POST['post_mime_type'] = '';
+
        // Check for autosave collisions
        // Does this need to be updated? ~ Mark
        $temp_id = false;
@@ -632,8 +639,6 @@ function add_meta( $post_ID ) {
        global $wpdb;
        $post_ID = (int) $post_ID;
 
-       $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
-
        $metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : '';
        $metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : '';
        $metavalue = isset($_POST['metavalue']) ? maybe_serialize( stripslashes_deep( $_POST['metavalue'] ) ) : '';
@@ -650,7 +655,7 @@ function add_meta( $post_ID ) {
                if ( $metakeyinput)
                        $metakey = $metakeyinput; // default
 
-               if ( in_array($metakey, $protected) )
+               if ( is_protected_meta( $metakey ) )
                        return false;
 
                wp_cache_delete($post_ID, 'post_meta');
@@ -756,11 +761,9 @@ function has_meta( $postid ) {
 function update_meta( $meta_id, $meta_key, $meta_value ) {
        global $wpdb;
 
-       $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
-
        $meta_key = stripslashes($meta_key);
 
-       if ( in_array($meta_key, $protected) )
+       if ( is_protected_meta( $meta_key ) )
                return false;
 
        if ( '' === trim( $meta_value ) )
@@ -993,7 +996,12 @@ function wp_edit_attachments_query( $q = false ) {
        $q['m']   = isset( $q['m'] ) ? (int) $q['m'] : 0;
        $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
        $q['post_type'] = 'attachment';
-       $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit';
+       $post_type = get_post_type_object( 'attachment' );
+       $states = array( 'inherit' );
+       if ( current_user_can( $post_type->cap->read_private_posts ) )
+               $states[] = 'private';
+
+       $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;
        $media_per_page = (int) get_user_option( 'upload_per_page' );
        if ( empty( $media_per_page ) || $media_per_page < 1 )
                $media_per_page = 20;