Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/wp-includes/post.php

    r17519 r18023  
    558558                return false;
    559559
    560         // Unattached attachments are assumed to be published.
    561         if ( ('attachment' == $post->post_type) && ('inherit' == $post->post_status) && ( 0 == $post->post_parent) )
    562                 return 'publish';
    563 
    564         if ( ('attachment' == $post->post_type) && $post->post_parent && ($post->ID != $post->post_parent) )
    565                 return get_post_status($post->post_parent);
     560        if ( 'attachment' == $post->post_type ) {
     561                if ( 'private' == $post->post_status )
     562                        return 'private';
     563
     564                // Unattached attachments are assumed to be published
     565                if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) )
     566                        return 'publish';
     567
     568                // Inherit status from the parent
     569                if ( $post->post_parent && ( $post->ID != $post->post_parent ) )
     570                        return get_post_status($post->post_parent);
     571        }
    566572
    567573        return $post->post_status;
    … …  
    35333539        global $wpdb, $user_ID;
    35343540
    3535         $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
     3541        $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID,
    35363542                'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    35373543                'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
    3538                 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0);
     3544                'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');
    35393545
    35403546        $object = wp_parse_args($object, $defaults);
    … …  
    35513557
    35523558        $post_type = 'attachment';
    3553         $post_status = 'inherit';
     3559
     3560        if ( ! in_array( $post_status, array( 'inherit', 'private' ) ) )
     3561                $post_status = 'inherit';
    35543562
    35553563        // Make sure we set a valid category.
    … …  
    36533661        if ( isset($post_parent) && $post_parent < 0 )
    36543662                add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true);
     3663
     3664        if ( ! empty( $context ) )
     3665                add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    36553666
    36563667        if ( $update) {
Note: See TracChangeset for help on using the changeset viewer.