Make WordPress Core

Changeset 20381


Ignore:
Timestamp:
04/06/2012 07:52:34 PM (14 years ago)
Author:
duck_
Message:

Simplify caption cleanup callbacks; if the function was called we know that the 0 index is set. See #20369.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r20377 r20381  
    166166
    167167// Private, preg_replace callback used in image_add_caption()
    168 function _cleanup_image_add_caption($str) {
    169     if ( isset( $str[0] ) ) {
    170         // remove any line breaks from inside the tags
    171         $s = preg_replace( '/[\r\n\t]+/', ' ', $str[0] );
    172         // look for single quotes inside html attributes (for example in title)
    173         $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $s );
    174         return str_replace( '"', "'", $s );
    175     }
    176 
    177     return '';
     168function _cleanup_image_add_caption( $matches ) {
     169    // remove any line breaks from inside the tags
     170    $s = preg_replace( '/[\r\n\t]+/', ' ', $matches[0] );
     171    // look for single quotes inside html attributes (for example in title)
     172    $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $s );
     173    return str_replace( '"', "'", $s );
    178174}
    179175
    180176// Private, preg_replace callback used in image_add_caption()
    181 function _cleanup_image_add_caption2($str) {
    182     return ( isset( $str[0] ) ) ? str_replace( "'", ''', $str[0] ) : '';
     177function _cleanup_image_add_caption2( $matches ) {
     178    return str_replace( "'", ''', $matches[0] );
    183179}
    184180
Note: See TracChangeset for help on using the changeset viewer.