From 1480a33d25deebac893e9b203462c71e9a5739c9 Mon Sep 17 00:00:00 2001 From: duck_ Date: Fri, 6 Apr 2012 19:52:34 +0000 Subject: [PATCH] Simplify caption cleanup callbacks; if the function was called we know that the 0 index is set. See #20369. git-svn-id: http://svn.automattic.com/wordpress/trunk@20381 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index ce97d5035..f7ec9aa58 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -165,21 +165,17 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $ add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); // Private, preg_replace callback used in image_add_caption() -function _cleanup_image_add_caption($str) { - if ( isset( $str[0] ) ) { - // remove any line breaks from inside the tags - $s = preg_replace( '/[\r\n\t]+/', ' ', $str[0] ); - // look for single quotes inside html attributes (for example in title) - $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $s ); - return str_replace( '"', "'", $s ); - } - - return ''; +function _cleanup_image_add_caption( $matches ) { + // remove any line breaks from inside the tags + $s = preg_replace( '/[\r\n\t]+/', ' ', $matches[0] ); + // look for single quotes inside html attributes (for example in title) + $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $s ); + return str_replace( '"', "'", $s ); } // Private, preg_replace callback used in image_add_caption() -function _cleanup_image_add_caption2($str) { - return ( isset( $str[0] ) ) ? str_replace( "'", ''', $str[0] ) : ''; +function _cleanup_image_add_caption2( $matches ) { + return str_replace( "'", ''', $matches[0] ); } /**