Make WordPress Core

Ticket #30220: 30220.diff

File 30220.diff, 7.7 KB (added by ericlewis, 11 years ago)
  • src/wp-admin/includes/revision.php

    diff --git src/wp-admin/includes/revision.php src/wp-admin/includes/revision.php
    index 4e20f2d..9e8b6e3 100644
    function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null 
    237237                'revisionIds'      => array_keys( $revisions ),
    238238        );
    239239}
     240
     241/**
     242 * Print Javascript templates required for the revisions experience.
     243 *
     244 * @since 4.1.0
     245 */
     246function wp_print_revision_templates() {
     247        global $post;
     248        ?><script id="tmpl-revisions-frame" type="text/html">
     249                <div class="revisions-control-frame"></div>
     250                <div class="revisions-diff-frame"></div>
     251        </script>
     252
     253        <script id="tmpl-revisions-buttons" type="text/html">
     254                <div class="revisions-previous">
     255                        <input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" />
     256                </div>
     257
     258                <div class="revisions-next">
     259                        <input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
     260                </div>
     261        </script>
     262
     263        <script id="tmpl-revisions-checkbox" type="text/html">
     264                <div class="revision-toggle-compare-mode">
     265                        <label>
     266                                <input type="checkbox" class="compare-two-revisions"
     267                                <#
     268                                if ( 'undefined' !== typeof data && data.model.attributes.compareTwoMode ) {
     269                                        #> checked="checked"<#
     270                                }
     271                                #>
     272                                />
     273                                <?php esc_attr_e( 'Compare any two revisions' ); ?>
     274                        </label>
     275                </div>
     276        </script>
     277
     278        <script id="tmpl-revisions-meta" type="text/html">
     279                <# if ( ! _.isUndefined( data.attributes ) ) { #>
     280                        <div class="diff-title">
     281                                <# if ( 'from' === data.type ) { #>
     282                                        <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
     283                                <# } else if ( 'to' === data.type ) { #>
     284                                        <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
     285                                <# } #>
     286                                <div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
     287                                        {{{ data.attributes.author.avatar }}}
     288                                        <div class="author-info">
     289                                        <# if ( data.attributes.autosave ) { #>
     290                                                <span class="byline"><?php printf( __( 'Autosave by %s' ),
     291                                                        '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
     292                                        <# } else if ( data.attributes.current ) { #>
     293                                                <span class="byline"><?php printf( __( 'Current Revision by %s' ),
     294                                                        '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
     295                                        <# } else { #>
     296                                                <span class="byline"><?php printf( __( 'Revision by %s' ),
     297                                                        '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
     298                                        <# } #>
     299                                                <span class="time-ago">{{ data.attributes.timeAgo }}</span>
     300                                                <span class="date">({{ data.attributes.dateShort }})</span>
     301                                        </div>
     302                                <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
     303                                        <input  <?php if ( wp_check_post_lock( $post->ID ) ) { ?>
     304                                                disabled="disabled"
     305                                        <?php } else { ?>
     306                                                <# if ( data.attributes.current ) { #>
     307                                                        disabled="disabled"
     308                                                <# } #>
     309                                        <?php } ?>
     310                                        <# if ( data.attributes.autosave ) { #>
     311                                                type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
     312                                        <# } else { #>
     313                                                type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
     314                                        <# } #>
     315                                <# } #>
     316                        </div>
     317                <# if ( 'tooltip' === data.type ) { #>
     318                        <div class="revisions-tooltip-arrow"><span></span></div>
     319                <# } #>
     320        <# } #>
     321        </script>
     322
     323        <script id="tmpl-revisions-diff" type="text/html">
     324                <div class="loading-indicator"><span class="spinner"></span></div>
     325                <div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div>
     326                <div class="diff">
     327                <# _.each( data.fields, function( field ) { #>
     328                        <h3>{{ field.name }}</h3>
     329                        {{{ field.diff }}}
     330                <# }); #>
     331                </div>
     332        </script><?php
     333}
     334 No newline at end of file
  • src/wp-admin/revision.php

    diff --git src/wp-admin/revision.php src/wp-admin/revision.php
    index ba954b8..f65ae6a 100644
    require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    129129        <h2 class="long-header"><?php echo $h2; ?></h2>
    130130        <?php echo $return_to_post; ?>
    131131</div>
    132 
    133 <script id="tmpl-revisions-frame" type="text/html">
    134         <div class="revisions-control-frame"></div>
    135         <div class="revisions-diff-frame"></div>
    136 </script>
    137 
    138 <script id="tmpl-revisions-buttons" type="text/html">
    139         <div class="revisions-previous">
    140                 <input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" />
    141         </div>
    142 
    143         <div class="revisions-next">
    144                 <input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
    145         </div>
    146 </script>
    147 
    148 <script id="tmpl-revisions-checkbox" type="text/html">
    149         <div class="revision-toggle-compare-mode">
    150                 <label>
    151                         <input type="checkbox" class="compare-two-revisions"
    152                         <#
    153                         if ( 'undefined' !== typeof data && data.model.attributes.compareTwoMode ) {
    154                                 #> checked="checked"<#
    155                         }
    156                         #>
    157                         />
    158                         <?php esc_attr_e( 'Compare any two revisions' ); ?>
    159                 </label>
    160         </div>
    161 </script>
    162 
    163 <script id="tmpl-revisions-meta" type="text/html">
    164         <# if ( ! _.isUndefined( data.attributes ) ) { #>
    165                 <div class="diff-title">
    166                         <# if ( 'from' === data.type ) { #>
    167                                 <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
    168                         <# } else if ( 'to' === data.type ) { #>
    169                                 <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
    170                         <# } #>
    171                         <div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
    172                                 {{{ data.attributes.author.avatar }}}
    173                                 <div class="author-info">
    174                                 <# if ( data.attributes.autosave ) { #>
    175                                         <span class="byline"><?php printf( __( 'Autosave by %s' ),
    176                                                 '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
    177                                 <# } else if ( data.attributes.current ) { #>
    178                                         <span class="byline"><?php printf( __( 'Current Revision by %s' ),
    179                                                 '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
    180                                 <# } else { #>
    181                                         <span class="byline"><?php printf( __( 'Revision by %s' ),
    182                                                 '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
    183                                 <# } #>
    184                                         <span class="time-ago">{{ data.attributes.timeAgo }}</span>
    185                                         <span class="date">({{ data.attributes.dateShort }})</span>
    186                                 </div>
    187                         <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
    188                                 <input  <?php if ( wp_check_post_lock( $post->ID ) ) { ?>
    189                                         disabled="disabled"
    190                                 <?php } else { ?>
    191                                         <# if ( data.attributes.current ) { #>
    192                                                 disabled="disabled"
    193                                         <# } #>
    194                                 <?php } ?>
    195                                 <# if ( data.attributes.autosave ) { #>
    196                                         type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
    197                                 <# } else { #>
    198                                         type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
    199                                 <# } #>
    200                         <# } #>
    201                 </div>
    202         <# if ( 'tooltip' === data.type ) { #>
    203                 <div class="revisions-tooltip-arrow"><span></span></div>
    204         <# } #>
    205 <# } #>
    206 </script>
    207 
    208 <script id="tmpl-revisions-diff" type="text/html">
    209         <div class="loading-indicator"><span class="spinner"></span></div>
    210         <div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div>
    211         <div class="diff">
    212         <# _.each( data.fields, function( field ) { #>
    213                 <h3>{{ field.name }}</h3>
    214                 {{{ field.diff }}}
    215         <# }); #>
    216         </div>
    217 </script>
    218 
    219 
    220132<?php
     133wp_print_revision_templates();
     134
    221135require_once( ABSPATH . 'wp-admin/admin-footer.php' );