Attachment cleanups from skeltoac.

git-svn-id: https://develop.svn.wordpress.org/trunk@3251 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2005-11-30 22:44:00 +00:00
parent ba38c0c3c4
commit aa5674dc27
3 changed files with 105 additions and 1 deletions
+8
View File
@@ -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;