From 80df7fe2cf47cf94c4edb35f54c5a6d16f6303b4 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 6 Apr 2012 17:38:49 +0000 Subject: [PATCH] Fix second callback when filtering caption text for shortcode, props SergeyBiryukov, fixes #20369 git-svn-id: https://develop.svn.wordpress.org/trunk@20376 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 9be8e23924..9f5d270efe 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -166,9 +166,9 @@ 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]) ) { + if ( isset( $str[0] ) ) { // remove any line breaks from inside the tags - $s = preg_replace( '/[\r\n\t]+/', ' ', $str[0]); + $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 ); @@ -179,7 +179,7 @@ function _cleanup_image_add_caption($str) { // Private, preg_replace callback used in image_add_caption() function _cleanup_image_add_caption2($str) { - return str_replace( "'", ''', $str ); + return ( isset( $str[0] ) ) ? str_replace( "'", ''', $str[0] ) : ''; } /**