Make WordPress Core

Changeset 24615


Ignore:
Timestamp:
07/09/2013 07:21:25 PM (9 years ago)
Author:
markjaquith
Message:

Pass back dateUnix (a unix timestamp) for better sorting of revisions in Backbone.

Props duck_. See #24425.

Location:
trunk/wp-admin
Files:
2 edited

Legend:

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

    r24611 r24615  
    9191            'date'         => date_i18n( __( 'M j, Y @ G:i' ), $modified_gmt ),
    9292            'dateShort'    => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified_gmt ),
     93            'dateUnix'     => $modified_gmt,
    9394            'timeAgo'      => human_time_diff( $modified_gmt, $current ),
    9495            'autosave'     => wp_is_post_autosave( $revision ),
  • trunk/wp-admin/js/revisions.js

    r24613 r24615  
    1515        if ( revisions.debug )
    1616            console.log.apply( console, arguments );
    17     }
     17    };
    1818
    1919    // wp_localize_script transforms top-level numbers into strings. Undo that.
     
    4848        model: revisions.model.Revision,
    4949
    50         comparator: function( revision ) {
    51             return revision.id;
     50        comparator: function( a, b ) {
     51            var a_ = a.get('dateUnix');
     52            var b_ = b.get('dateUnix');
     53            var cmp = (a_ > b_) - (a_ < b_);
     54            if (cmp === 0 && a.id != b.id)
     55                cmp = a.id < b.id ? -1 : 1;
     56            return cmp;
    5257        },
    5358
Note: See TracChangeset for help on using the changeset viewer.