mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Attachment cleanups from skeltoac.
git-svn-id: https://develop.svn.wordpress.org/trunk@3251 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user