Ticket #24804: 24804.13.diff
File 24804.13.diff, 16.9 KB (added by , 11 years ago) |
---|
-
wp-admin/css/wp-admin.css
td.plugin-title p { 3539 3539 margin: 0 auto; 3540 3540 height: 0.8em; 3541 3541 top: 7px; 3542 width: 70%;3542 max-width: 70%; 3543 3543 -moz-box-sizing: border-box; 3544 3544 -webkit-box-sizing: border-box; 3545 3545 box-sizing: border-box; … … body.folded .revisions .loading-indicator { 3641 3641 .revisions-controls .author-card .date { 3642 3642 color: #777; 3643 3643 } 3644 3645 .revisions-controls .author-card.autosave { 3646 color: #d54e21; 3647 } 3648 3644 3649 .revisions-controls .author-card .author-name { 3645 3650 font-weight: bold; 3646 3651 } … … body.folded .revisions .loading-indicator { 3663 3668 float: right; 3664 3669 } 3665 3670 3666 . wp-slider {3667 width: 70%;3671 .revisions-controls .wp-slider { 3672 max-width: 70%; 3668 3673 margin: 0 auto; 3669 3674 top: -3px; 3670 3675 } -
wp-admin/edit-form-advanced.php
$post_type_object = get_post_type_object($post_type); 106 106 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). 107 107 require_once('./includes/meta-boxes.php'); 108 108 109 110 $publish_callback_args = null; 111 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) { 112 $revisions = wp_get_post_revisions( $post_ID ); 113 114 // Check if the revisions have been upgraded 115 if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 ) 116 _wp_upgrade_revisions_of_post( $post, $revisions ); 117 118 // We should aim to show the revisions metabox only when there are revisions. 119 if ( count( $revisions ) > 1 ) { 120 reset( $revisions ); // Reset pointer for key() 121 $publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) ); 122 // add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core'); 123 } 124 } 125 109 126 if ( 'attachment' == $post_type ) { 110 127 wp_enqueue_script( 'image-edit' ); 111 128 wp_enqueue_style( 'imgareaselect' ); 112 129 add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' ); 113 130 add_action( 'edit_form_after_title', 'edit_form_image_editor' ); 114 131 } else { 115 add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );132 add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); 116 133 } 117 134 118 135 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) … … if ( post_type_supports($post_type, 'author') ) { 169 186 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core'); 170 187 } 171 188 172 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {173 $revisions = wp_get_post_revisions( $post_ID );174 175 // Check if the revisions have been upgraded176 if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 )177 _wp_upgrade_revisions_of_post( $post, $revisions );178 179 // We should aim to show the revisions metabox only when there are revisions.180 if ( count( $revisions ) > 1 )181 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');182 }183 184 189 do_action('add_meta_boxes', $post_type, $post); 185 190 do_action('add_meta_boxes_' . $post_type, $post); 186 191 -
wp-admin/includes/ajax-actions.php
function wp_ajax_get_revision_diffs() { 2099 2099 wp_send_json_error(); 2100 2100 2101 2101 // Really just pre-loading the cache here. 2102 if ( ! $revisions = wp_get_post_revisions( $post->ID ) )2102 if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) 2103 2103 wp_send_json_error(); 2104 2104 2105 2105 $return = array(); -
wp-admin/includes/meta-boxes.php
9 9 * 10 10 * @param object $post 11 11 */ 12 function post_submit_meta_box($post ) {12 function post_submit_meta_box($post, $args = array() ) { 13 13 global $action; 14 14 15 15 $post_type = $post->post_type; … … if ( 0 != $post->ID ) { 171 171 $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); 172 172 } 173 173 174 if ( ! empty( $args['args']['revisions_count'] ) ) : 175 $revisions_to_keep = wp_revisions_to_keep( $post ); 176 ?> 177 <div class="misc-pub-section num-revisions"> 178 <?php 179 if ( $revisions_to_keep > 0 && $revisions_to_keep <= $args['args']['revisions_count'] ) { 180 echo '<span title="' . esc_attr( sprintf( __( 'Your site is configured to keep only the last %s revisions.' ), 181 number_format_i18n( $revisions_to_keep ) ) ) . '">'; 182 printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '+</b>' ); 183 echo '</span>'; 184 } else { 185 printf( 'Revisions: %s', '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' ); 186 } 187 ?> 188 <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><?php _ex( 'Browse', 'revisions' ); ?></a> 189 </div> 190 <?php endif; 191 174 192 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> 175 193 <div class="misc-pub-section curtime"> 176 194 <span id="timestamp"> -
wp-admin/includes/revision.php
function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) { 32 32 return false; 33 33 34 34 // If comparing revisions, make sure we're dealing with the right post parent. 35 if ( $compare_from && $compare_from->post_parent !== $post->ID ) 35 // The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves. 36 if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID ) 36 37 return false; 37 if ( $compare_to->post_parent !== $post->ID )38 if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID ) 38 39 return false; 39 40 40 41 if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) { … … function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null 91 92 $revisions = $authors = array(); 92 93 $now_gmt = time(); 93 94 94 $revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC' ) ); 95 $revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC', 'check_enabled' => false ) ); 96 // If revisions are disabled, we only want autosaves and the current post. 97 if ( ! wp_revisions_enabled( $post ) ) { 98 foreach ( $revisions as $revision_id => $revision ) { 99 if ( ! wp_is_post_autosave( $revision ) ) 100 unset( $revisions[ $revision_id ] ); 101 } 102 $revisions = array( $post->ID => $post ) + $revisions; 103 } 104 95 105 $show_avatars = get_option( 'show_avatars' ); 96 106 97 107 cache_users( wp_list_pluck( $revisions, 'post_author' ) ); 98 108 109 $can_restore = current_user_can( 'edit_post', $post->ID ); 110 99 111 foreach ( $revisions as $revision ) { 100 112 $modified = strtotime( $revision->post_modified ); 101 113 $modified_gmt = strtotime( $revision->post_modified_gmt ); 102 $restore_link = str_replace( '&', '&', wp_nonce_url( 103 add_query_arg( 104 array( 'revision' => $revision->ID, 105 'action' => 'restore' ), 106 admin_url( 'revision.php' ) 107 ), 108 "restore-post_{$revision->ID}" 109 ) ); 114 if ( $can_restore ) { 115 $restore_link = str_replace( '&', '&', wp_nonce_url( 116 add_query_arg( 117 array( 'revision' => $revision->ID, 118 'action' => 'restore' ), 119 admin_url( 'revision.php' ) 120 ), 121 "restore-post_{$revision->ID}" 122 ) ); 123 } 110 124 111 125 if ( ! isset( $authors[ $revision->post_author ] ) ) { 112 126 $authors[ $revision->post_author ] = array( … … function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null 116 130 ); 117 131 } 118 132 119 $autosave = wp_is_post_autosave( $revision );133 $autosave = (bool) wp_is_post_autosave( $revision ); 120 134 $current = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt; 121 135 if ( $current && ! empty( $current_id ) ) { 136 // If multiple revisions have the same post_modified_gmt, highest ID is current. 122 137 if ( $current_id < $revision->ID ) { 123 138 $revisions[ $current_id ]['current'] = false; 124 139 $current_id = $revision->ID; … … function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null 138 153 'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ), 139 154 'autosave' => $autosave, 140 155 'current' => $current, 141 'restoreUrl' => urldecode( $restore_link ),156 'restoreUrl' => $can_restore ? $restore_link : false, 142 157 ); 143 158 } 144 159 145 160 // If a post has been saved since the last revision (no revisioned fields were changed) 146 161 // we may not have a "current" revision. Mark the latest revision as "current". 147 if ( empty( $current_id ) ) 148 $revisions[ $revision->ID ]['current'] = true; 162 if ( empty( $current_id ) ) { 163 if ( $revisions[ $revision->ID ]['autosave'] ) { 164 $revision = end( $revisions ); 165 while ( $revision['autosave'] ) { 166 $revision = prev( $revisions ); 167 } 168 $current_id = $revision['id']; 169 } else { 170 $current_id = $revision->ID; 171 } 172 $revisions[ $current_id ]['current'] = true; 173 } 149 174 150 175 // Now, grab the initial diff 151 176 $compare_two_mode = is_numeric( $from ); -
wp-admin/js/revisions.js
window.wp = window.wp || {}; 651 651 var tickCount, tickWidth; 652 652 tickCount = this.model.revisions.length - 1; 653 653 tickWidth = 1 / tickCount; 654 this.$el.css('width', ( this.model.revisions.length * 50 ) + 'px'); 654 655 655 656 _(tickCount).times( function( index ){ 656 this.$el.append( '<div style="' + this.direction + ': ' + ( 100 * tickWidth * index ) + '%"></div>' ); }, this ); 657 this.$el.append( '<div style="' + this.direction + ': ' + ( 100 * tickWidth * index ) + '%"></div>' ); 658 }, this ); 657 659 } 658 660 }); 659 661 … … window.wp = window.wp || {}; 831 833 }, 832 834 833 835 ready: function() { 836 this.$el.css('width', ( this.model.revisions.length * 50 ) + 'px'); 834 837 this.$el.slider( _.extend( this.model.toJSON(), { 835 838 start: this.start, 836 839 slide: this.slide, -
wp-admin/revision.php
case 'restore' : 31 31 if ( ! $post = get_post( $revision->post_parent ) ) 32 32 break; 33 33 34 // Revisions disabled (previously checked autosave gs && ! wp_is_post_autosave( $revision ))34 // Revisions disabled (previously checked autosaves && ! wp_is_post_autosave( $revision )) 35 35 if ( ! wp_revisions_enabled( $post ) ) { 36 36 $redirect = 'edit.php?post_type=' . $post->post_type; 37 37 break; … … require_once( './admin-header.php' ); 133 133 <script id="tmpl-revisions-tooltip" type="text/html"> 134 134 <div class="author-card"> 135 135 <# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #> 136 {{{ data.author.avatar }}} 137 <div class="author-info"> 138 139 <span class="byline"><?php printf( __( 'Revision by %s' ), 140 '<span class="author-name">{{ data.author.name }}</span>' ); ?></span> 141 <span class="time-ago">{{ data.timeAgo }}</span> 142 <span class="date">({{ data.dateShort }})</span> 143 </div> 136 <div class="author-card<# if ( data.autosave ) { #> autosave<# } #>"> 137 {{{ data.author.avatar }}} 138 <div class="author-info"> 139 <# if ( data.autosave ) { #> 140 <span class="byline"><?php printf( __( 'Autosave by %s' ), 141 '<span class="author-name">{{ data.author.name }}</span>' ); ?></span> 142 <# } else if ( data.current ) { #> 143 <span class="byline"><?php printf( __( 'Current Revision by %s' ), 144 '<span class="author-name">{{ data.author.name }}</span>' ); ?></span> 145 <# } else { #> 146 <span class="byline"><?php printf( __( 'Revision by %s' ), 147 '<span class="author-name">{{ data.author.name }}</span>' ); ?></span> 148 <# } #> 149 <span class="time-ago">{{ data.timeAgo }}</span> 150 <span class="date">({{ data.dateShort }})</span> 151 </div> 152 </div> 144 153 <# } #> 145 154 </div> 146 155 <div class="revisions-tooltip-arrow"><span></span></div> … … require_once( './admin-header.php' ); 166 175 <div class="diff-title"> 167 176 <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong> 168 177 <# if ( 'undefined' !== typeof data.from ) { #> 169 <div class="author-card ">178 <div class="author-card<# if ( data.from.attributes.autosave ) { #> autosave<# } #>"> 170 179 {{{ data.from.attributes.author.avatar }}} 171 180 <div class="author-info"> 181 <# if ( data.from.attributes.autosave ) { #> 182 <span class="byline"><?php printf( __( 'Autosave by %s' ), 183 '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span> 184 <# } else if ( data.from.attributes.current ) { #> 185 <span class="byline"><?php printf( __( 'Current Revision by %s' ), 186 '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span> 187 <# } else { #> 172 188 <span class="byline"><?php printf( __( 'Revision by %s' ), 173 189 '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span> 190 <# } #> 174 191 <span class="time-ago">{{ data.from.attributes.timeAgo }}</span> 175 192 <span class="date">({{ data.from.attributes.dateShort }})</span> 176 193 </div> … … require_once( './admin-header.php' ); 183 200 <div class="diff-title"> 184 201 <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong> 185 202 <# if ( 'undefined' !== typeof data.to ) { #> 186 <div class="author-card ">203 <div class="author-card<# if ( data.to.attributes.autosave ) { #> autosave<# } #>"> 187 204 {{{ data.to.attributes.author.avatar }}} 188 205 <div class="author-info"> 206 <# if ( data.to.attributes.autosave ) { #> 207 <span class="byline"><?php printf( __( 'Autosave by %s' ), 208 '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span> 209 <# } else if ( data.to.attributes.current ) { #> 210 <span class="byline"><?php printf( __( 'Current Revision by %s' ), 211 '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span> 212 <# } else { #> 189 213 <span class="byline"><?php printf( __( 'Revision by %s' ), 190 214 '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span> 215 <# } #> 191 216 <span class="time-ago">{{ data.to.attributes.timeAgo }}</span> 192 217 <span class="date">({{ data.to.attributes.dateShort }})</span> 193 218 </div> 194 219 <# } #> 220 <# if ( data.to.attributes.restoreUrl ) { #> 195 221 <input 196 222 <# if ( data.to.attributes.current ) { #> 197 223 disabled="disabled" 198 224 <# } #> 199 type="button" class="restore-revision button button-primary" data-restore-link="{{{ data.restoreLink }}}" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" /> 225 <# if ( data.to.attributes.autosave ) { #> 226 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" /> 227 <# } else { #> 228 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" /> 229 <# } #> 230 <# } #> 200 231 </div> 201 232 </div> 202 233 </script> -
wp-includes/revision.php
function wp_save_post_revision( $post_id ) { 157 157 * @return object|bool The autosaved data or false on failure or when no autosave exists. 158 158 */ 159 159 function wp_get_post_autosave( $post_id, $user_id = 0 ) { 160 $revisions = wp_get_post_revisions( $post_id);160 $revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false ) ); 161 161 162 162 foreach ( $revisions as $revision ) { 163 163 if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) { … … function wp_delete_post_revision( $revision_id ) { 369 369 */ 370 370 function wp_get_post_revisions( $post_id = 0, $args = null ) { 371 371 $post = get_post( $post_id ); 372 if ( ! $post || empty( $post->ID ) || ! wp_revisions_enabled( $post ))372 if ( ! $post || empty( $post->ID ) ) 373 373 return array(); 374 374 375 $defaults = array( 'order' => 'DESC', 'orderby' => 'date' );375 $defaults = array( 'order' => 'DESC', 'orderby' => 'date', 'check_enabled' => true ); 376 376 $args = wp_parse_args( $args, $defaults ); 377 378 if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) 379 return array(); 380 377 381 $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ); 378 382 379 383 if ( ! $revisions = get_children( $args ) )