Use preg_replace_callback to eliminate eval. Props BenBE1987. fixes #10896

git-svn-id: https://develop.svn.wordpress.org/trunk@12198 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-11-17 19:25:01 +00:00
parent 6266cbaf3b
commit a4912dccf2
1 changed files with 8 additions and 1 deletions

View File

@ -713,6 +713,7 @@ function update_meta( $meta_id, $meta_key, $meta_value ) {
* @return unknown
*/
function _fix_attachment_links( $post_ID ) {
global $_fix_attachment_link_id;
$post = & get_post( $post_ID, ARRAY_A );
@ -740,7 +741,8 @@ function _fix_attachment_links( $post_ID ) {
}
$post_search[$i] = $anchor;
$post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor );
$_fix_attachment_link_id = $id;
$post_replace[$i] = preg_replace_callback( "#href=(\"|')[^'\"]*\\1#", '_fix_attachment_links_replace_cb', $anchor );
++$i;
}
@ -752,6 +754,11 @@ function _fix_attachment_links( $post_ID ) {
return wp_update_post( $post);
}
function _fix_attachment_links_replace_cb($match) {
global $_fix_attachment_link_id;
return stripslashes( 'href='.$m[1] ).get_attachment_link( $_fix_attachment_link_id ).stripslashes( $m[1] );
}
/**
* Move child posts to a new parent.
*