Skip to content
Browse files

Don't reset parent when updating attachment. Props filosofo and miche…

…lwp. fixes #5010

git-svn-id: http://svn.automattic.com/wordpress/trunk@6155 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent e56c1c2 commit 72e74add8df70439b246362a3740b866a62a4ec9 ryan committed Sep 22, 2007
Showing with 5 additions and 1 deletion.
  1. +1 −0 wp-admin/js/upload.js
  2. +4 −1 wp-includes/post.php
View
1 wp-admin/js/upload.js
@@ -201,6 +201,7 @@ addLoadEvent( function() {
h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>";
h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='" + this.deleteText + "' onclick='theFileList.deleteFile(" + id + ");' />";
h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />";
+ h += "<input type='hidden' name='post_parent' value='" + parseInt(this.postID,10) + "' />";
h += "<input type='hidden' name='action' id='action-value' value='save' />";
h += "<input type='hidden' name='ID' value='" + id + "' />";
h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />";
View
5 wp-includes/post.php
@@ -1272,14 +1272,17 @@ function is_local_attachment($url) {
return false;
}
-function wp_insert_attachment($object, $file = false, $post_parent = 0) {
+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,
'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '');
$object = wp_parse_args($object, $defaults);
+ if ( !empty($parent) )
+ $object['post_parent'] = $parent;
+
$object = sanitize_post($object, 'db');
// export array as variables

0 comments on commit 72e74ad

Please sign in to comment.
Something went wrong with that request. Please try again.