Make WordPress Core

Changeset 9302


Ignore:
Timestamp:
10/23/2008 08:03:16 PM (15 years ago)
Author:
ryan
Message:

Introduce normalize_whitespace(). Use it instead of wp_text_diff() when checking for identical autosave revisions. Props tellyworth. fixes #7691

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r9291 r9302  
    4646    if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) {
    4747        foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
    48             if ( wp_text_diff( $autosave->$autosave_field, $post->$autosave_field ) ) {
     48            if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
    4949                $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
    5050                break;
  • trunk/wp-includes/formatting.php

    r9255 r9302  
    21452145}
    21462146
     2147// normalize EOL characters and strip duplicate whitespace
     2148function normalize_whitespace( $str ) {
     2149    $str  = trim($str);
     2150    $str  = str_replace("\r", "\n", $str);
     2151    $str  = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
     2152    return $str;
     2153}
     2154
    21472155?>
  • trunk/wp-includes/pluggable.php

    r9243 r9302  
    16641664        require( ABSPATH . WPINC . '/wp-diff.php' );
    16651665
    1666     // Normalize whitespace
    1667     $left_string  = trim($left_string);
    1668     $right_string = trim($right_string);
    1669     $left_string  = str_replace("\r", "\n", $left_string);
    1670     $right_string = str_replace("\r", "\n", $right_string);
    1671     $left_string  = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $left_string );
    1672     $right_string = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $right_string );
     1666    $left_string  = normalize_whitespace($left_string);
     1667    $right_string = normalize_whitespace($right_string);
    16731668
    16741669    $left_lines  = split("\n", $left_string);
Note: See TracChangeset for help on using the changeset viewer.