]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/post.php
WordPress 4.0.1
[autoinstalls/wordpress.git] / wp-includes / post.php
index d9d48a56fe28d01c9617b67dac2e193490010bc5..94ec8f2c506fbf5b71ec35a1533e46dee86c8df6 100644 (file)
@@ -4719,10 +4719,15 @@ function is_local_attachment($url) {
 function wp_insert_attachment( $args, $file = false, $parent = 0 ) {
        $defaults = array(
                'file'        => $file,
 function wp_insert_attachment( $args, $file = false, $parent = 0 ) {
        $defaults = array(
                'file'        => $file,
-               'post_parent' => $parent
+               'post_parent' => 0
        );
        );
+
        $data = wp_parse_args( $args, $defaults );
 
        $data = wp_parse_args( $args, $defaults );
 
+       if ( ! empty( $parent ) ) {
+               $data['post_parent'] = $parent;
+       }
+
        $data['post_type'] = 'attachment';
 
        return wp_insert_post( $data );
        $data['post_type'] = 'attachment';
 
        return wp_insert_post( $data );