Use preg_replace_callback to eliminate eval. Props BenBE1987. fixes #10896
git-svn-id: http://svn.automattic.com/wordpress/trunk@12198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
28723e1d9f
commit
cb8cc5ffb6
|
@ -713,6 +713,7 @@ function update_meta( $meta_id, $meta_key, $meta_value ) {
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function _fix_attachment_links( $post_ID ) {
|
function _fix_attachment_links( $post_ID ) {
|
||||||
|
global $_fix_attachment_link_id;
|
||||||
|
|
||||||
$post = & get_post( $post_ID, ARRAY_A );
|
$post = & get_post( $post_ID, ARRAY_A );
|
||||||
|
|
||||||
|
@ -740,7 +741,8 @@ function _fix_attachment_links( $post_ID ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_search[$i] = $anchor;
|
$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;
|
++$i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,6 +754,11 @@ function _fix_attachment_links( $post_ID ) {
|
||||||
return wp_update_post( $post);
|
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.
|
* Move child posts to a new parent.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue