From ca460de5458e35b012e643b2af4880312c06d0f6 Mon Sep 17 00:00:00 2001 From: donncha Date: Thu, 1 Dec 2005 15:28:34 +0000 Subject: WP Merge git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@454 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-inst/wp-admin/admin-functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'wp-inst/wp-admin/admin-functions.php') diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php index cfce700..d89f5b1 100644 --- a/wp-inst/wp-admin/admin-functions.php +++ b/wp-inst/wp-admin/admin-functions.php @@ -97,6 +97,14 @@ function fix_attachment_links($post_ID) { continue; $id = $id_matches[2]; + + // While we have the attachment ID, let's adopt any orphans. + $attachment = & get_post($id); + if ( ! is_object(get_post($attachment->post_parent)) ) { + $attachment->post_parent = $post_ID; + wp_update_post($attachment); + } + $post_search[$i] = $anchor; $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor); ++$i; -- cgit