Changeset 20679 for trunk/wp-admin/includes/media.php
- Timestamp:
- 05/02/2012 01:14:52 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r20544 r20679 146 146 $caption = str_replace( array("\r\n", "\r"), "\n", $caption); 147 147 $caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption ); 148 $caption = preg_replace( '/\n+/', '<br />', str_replace('"', '"', $caption) ); 148 // convert any remaining line breaks to <br> 149 $caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption ); 149 150 150 151 $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); … … 152 153 $align = 'none'; 153 154 154 $shcode = '[caption id="' . $id . '" align="align' . $align 155 . '" width="' . $width . '" caption="' . $caption . '"]' . $html . '[/caption]'; 155 $shcode = '[caption id="' . $id . '" align="align' . $align . '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]'; 156 156 157 157 return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); … … 167 167 function _cleanup_image_add_caption( $matches ) { 168 168 // remove any line breaks from inside the tags 169 $s = preg_replace( '/[\r\n\t]+/', ' ', $matches[0] ); 170 // look for single quotes inside html attributes (for example in title) 171 $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption_callback', $s ); 172 return str_replace( '"', "'", $s ); 173 } 174 175 /** 176 * Private preg_replace callback used in _cleanup_image_add_caption() 177 * 178 * @access private 179 * @since 3.4.0 180 */ 181 function _cleanup_image_add_caption_callback( $matches ) { 182 return str_replace( "'", ''', $matches[0] ); 169 return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] ); 183 170 } 184 171 … … 1542 1529 caption = f.caption.value.replace(/\r\n|\r/g, '\n'); 1543 1530 caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){ 1544 a = a.replace(/[\r\n\t]+/, ' ').replace(/="[^"]+"/, function(b){ 1545 return b.replace(/'/g, '''); 1546 }); 1547 return a.replace(/"/g, "'"); 1531 return a.replace(/[\r\n\t]+/, ' '); 1548 1532 }); 1549 1533 1550 caption = caption.replace(/\ n+/g, '<br />').replace(/"/g, '"');1534 caption = caption.replace(/\s*\n\s*/g, '<br />'); 1551 1535 } 1552 1536 <?php } ?> … … 1562 1546 1563 1547 if ( caption ) 1564 html = '[caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/caption]';1548 html = '[caption id="" align="'+t.align+'" width="'+t.width+'"]'+html+caption+'[/caption]'; 1565 1549 1566 1550 var win = window.dialogArguments || opener || parent || top;
Note: See TracChangeset
for help on using the changeset viewer.