Make WordPress Core

Ticket #8252: int_aware_trim.diff

File int_aware_trim.diff, 1.4 KB (added by tott, 18 years ago)

patch against revision 9797

  • wp-includes/post.php

     
    16771677        if ( empty($tags) )
    16781678                $tags = array();
    16791679        $tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") );
    1680         $tags = array_map('trim', $tags); //Trim whitespace from around the tags.
     1680        $tags = array_map('wp_type_aware_trim', $tags); //Trim whitespace from around the tags.
    16811681        wp_set_object_terms($post_id, $tags, 'post_tag', $append);
    16821682}
    16831683
  • wp-includes/functions.php

     
    28952895        return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object);
    28962896}
    28972897
    2898 
     2898/**
     2899 * Trim without making integers to strings
     2900 *
     2901 * Returns a trimmed string or a integer
     2902 *
     2903 * @since 2.7.0
     2904 *
     2905 * @param string $string The string to be trimmed
     2906 * @param string $charlist Possible charlist parameter for trim command
     2907 * @return string/integer Trimmed string or integer value
     2908 */
     2909function wp_type_aware_trim( $string, $charlist = false ) {
     2910    if ( is_int( $string ) )
     2911        return $string;
     2912    else {
     2913        if ( $charlist )
     2914            return trim( $string, $charlist );
     2915        else
     2916            return trim( $string );
     2917    }
     2918    return $string;
     2919}
    28992920?>