]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/post.php
Wordpress 3.1.3
[autoinstalls/wordpress.git] / wp-includes / post.php
index 0acf6414e7aebfd9e32725223db09b3f7c180490..d859473b482b788590afd6bc687c23ac1d0ee1e1 100644 (file)
@@ -557,12 +557,18 @@ function get_post_status($ID = '') {
        if ( !is_object($post) )
                return false;
 
-       // Unattached attachments are assumed to be published.
-       if ( ('attachment' == $post->post_type) && ('inherit' == $post->post_status) && ( 0 == $post->post_parent) )
-               return 'publish';
+       if ( 'attachment' == $post->post_type ) {
+               if ( 'private' == $post->post_status )
+                       return 'private';
 
-       if ( ('attachment' == $post->post_type) && $post->post_parent && ($post->ID != $post->post_parent) )
-               return get_post_status($post->post_parent);
+               // Unattached attachments are assumed to be published
+               if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) )
+                       return 'publish';
+
+               // Inherit status from the parent
+               if ( $post->post_parent && ( $post->ID != $post->post_parent ) )
+                       return get_post_status($post->post_parent);
+       }
 
        return $post->post_status;
 }
@@ -985,6 +991,11 @@ function register_post_type($post_type, $args = array()) {
 
                if ( $args->has_archive ) {
                        $archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
+                       if ( $args->rewrite['with_front'] )
+                               $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
+                       else
+                               $archive_slug = $wp_rewrite->root . $archive_slug;
+
                        $wp_rewrite->add_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );
                        if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {
                                $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
@@ -3527,10 +3538,10 @@ function is_local_attachment($url) {
 function wp_insert_attachment($object, $file = false, $parent = 0) {
        global $wpdb, $user_ID;
 
-       $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
+       $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID,
                'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
                'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
-               'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0);
+               'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');
 
        $object = wp_parse_args($object, $defaults);
        if ( !empty($parent) )
@@ -3545,7 +3556,9 @@ function wp_insert_attachment($object, $file = false, $parent = 0) {
                $post_author = $user_ID;
 
        $post_type = 'attachment';
-       $post_status = 'inherit';
+
+       if ( ! in_array( $post_status, array( 'inherit', 'private' ) ) )
+               $post_status = 'inherit';
 
        // Make sure we set a valid category.
        if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
@@ -3648,6 +3661,9 @@ function wp_insert_attachment($object, $file = false, $parent = 0) {
        if ( isset($post_parent) && $post_parent < 0 )
                add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true);
 
+       if ( ! empty( $context ) )
+               add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
+
        if ( $update) {
                do_action('edit_attachment', $post_ID);
        } else {
@@ -5236,4 +5252,4 @@ function _post_format_wp_get_object_terms( $terms ) {
 }
 add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
 
-?>
\ No newline at end of file
+?>