Changeset 23506 for trunk/wp-admin/revision.php
- Timestamp:
- 02/28/2013 03:14:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/revision.php
r23404 r23506 9 9 /** WordPress Administration Bootstrap */ 10 10 require_once('./admin.php'); 11 12 wp_enqueue_script('list-revisions'); 13 14 wp_reset_vars(array('revision', 'left', 'right', 'action')); 11 wp_reset_vars( array( 'revision', 'action' ) ); 15 12 16 13 $revision_id = absint($revision); 17 $left = absint($left);18 $right = absint($right);19 20 14 $redirect = 'edit.php'; 21 15 … … 34 28 break; 35 29 } 36 37 check_admin_referer( "restore-post_$post->ID|$revision->ID" ); 30 check_admin_referer( "restore-post_{$post->ID}|{$revision->ID}" ); 38 31 39 32 wp_restore_post_revision( $revision->ID ); 40 33 $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ); 41 34 break; 42 case 'diff' :43 if ( !$left_revision = get_post( $left ) )44 break;45 if ( !$right_revision = get_post( $right ) )46 break;47 48 if ( !current_user_can( 'read_post', $left_revision->ID ) || !current_user_can( 'read_post', $right_revision->ID ) )49 break;50 51 // If we're comparing a revision to itself, redirect to the 'view' page for that revision or the edit page for that post52 if ( $left_revision->ID == $right_revision->ID ) {53 $redirect = get_edit_post_link( $left_revision->ID );54 include( './js/revisions-js.php' );55 break;56 }57 58 // Don't allow reverse diffs?59 if ( strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt) ) {60 $redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );61 break;62 }63 64 if ( $left_revision->ID == $right_revision->post_parent ) // right is a revision of left65 $post =& $left_revision;66 elseif ( $left_revision->post_parent == $right_revision->ID ) // left is a revision of right67 $post =& $right_revision;68 elseif ( $left_revision->post_parent == $right_revision->post_parent ) // both are revisions of common parent69 $post = get_post( $left_revision->post_parent );70 else71 break; // Don't diff two unrelated revisions72 73 if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled74 if (75 // we're not looking at an autosave76 ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) )77 ||78 // we're not comparing an autosave to the current post79 ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID )80 ) {81 $redirect = 'edit.php?post_type=' . $post->post_type;82 break;83 }84 }85 86 if (87 // They're the same88 $left_revision->ID == $right_revision->ID89 ||90 // Neither is a revision91 ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )92 )93 break;94 95 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';96 $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title );97 $title = __( 'Revisions' );98 99 $left = $left_revision->ID;100 $right = $right_revision->ID;101 102 $redirect = false;103 break;104 35 case 'view' : 36 case 'edit' : 105 37 default : 106 38 if ( !$revision = wp_get_post_revision( $revision_id ) ) … … 120 52 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; 121 53 $revision_title = wp_post_revision_title( $revision, false ); 122 $h2 = sprintf( __( ' Revision for “%1$s” created on %2$s' ), $post_title, $revision_title );54 $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); 123 55 $title = __( 'Revisions' ); 124 125 // Sets up the diff radio buttons126 $left = $revision->ID;127 $right = $post->ID;128 56 129 57 $redirect = false; … … 146 74 $parent_file = $submenu_file = 'edit.php'; 147 75 76 wp_enqueue_style( 'revisions' ); 77 wp_enqueue_script( 'revisions' ); 78 148 79 require_once( './admin-header.php' ); 149 80 81 //TODO - Some of the translations below split things into multiple strings that are contextually related and this makes it pretty impossible for RTL translation. 82 //TODO can we pass the context in a better way 150 83 ?> 84 <script type="text/javascript"> 85 var wpRevisionsSettings = <?php echo json_encode( array( 'post_id' => $post->ID, 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ) ) ); ?>; 86 </script> 151 87 88 <div id="backbonerevisionsoptions"></div> 89 90 <br class="clear"/> 152 91 <div class="wrap"> 153 154 <h2 class="long-header"><?php echo $h2; ?></h2> 155 156 <table class="form-table ie-fixed"> 157 <col class="th" /> 158 <?php if ( 'diff' == $action ) : ?> 159 <tr id="revision"> 160 <th scope="row"></th> 161 <th scope="col" class="th-full"> 162 <span class="alignleft"><?php printf( __('Older: %s'), wp_post_revision_title( $left_revision ) ); ?></span> 163 <span class="alignright"><?php printf( __('Newer: %s'), wp_post_revision_title( $right_revision ) ); ?></span> 164 </th> 165 </tr> 166 <?php endif; 167 168 // use get_post_to_edit filters? 169 $identical = true; 170 foreach ( _wp_post_revision_fields() as $field => $field_title ) : 171 if ( 'diff' == $action ) { 172 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' ); 173 $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' ); 174 if ( !$content = wp_text_diff( $left_content, $right_content ) ) 175 continue; // There is no difference between left and right 176 $identical = false; 177 } else { 178 add_filter( "_wp_post_revision_field_$field", 'htmlspecialchars' ); 179 $content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field, $revision, '' ); 180 } 181 ?> 182 183 <tr id="revision-field-<?php echo $field; ?>"> 184 <th scope="row"><?php echo esc_html( $field_title ); ?></th> 185 <td><div class="pre"><?php echo $content; ?></div></td> 186 </tr> 187 188 <?php 189 190 endforeach; 191 192 if ( 'diff' == $action && $identical ) : 193 194 ?> 195 196 <tr><td colspan="2"><div class="updated"><p><?php _e( 'These revisions are identical.' ); ?></p></div></td></tr> 197 198 <?php 199 200 endif; 201 92 <div class="icon32 icon32-posts-post" id="icon-edit"><br></div> 93 <div class="revisiondiffcontainer diffsplit currentversion rightmodelloading"> 94 <div id="modelsloading" class="updated message"><span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?></div> 95 <h2 class="long-header"><?php echo $h2; ?></h2> 96 <div id="backbonerevisionsinteract"></div> 97 <div id="backbonerevisionsdiff"></div> 98 <hr /> 99 <?php 100 $comparetworevisionslink = get_edit_post_link( $revision->ID ); 202 101 ?> 203 204 </table> 205 206 <br class="clear" /> 207 208 <h3><?php echo $title; ?></h3> 209 210 <?php 211 212 $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); 213 if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) 214 $args['type'] = 'autosave'; 215 216 wp_list_post_revisions( $post, $args ); 217 218 ?> 219 102 </div> 220 103 </div> 221 104 105 <script id="tmpl-revision" type="text/html"> 106 <div id="diffsubheader"> 107 <span id="diff_from_current_revision"><?php _e( 'Current version' ); ?><?php _e( '- compared to -' ); ?></span> 108 <div id="difftitlefrom">{{{ data.revision_from_date_author }}} <?php _e( '- compared to -' ); ?></div> 109 <div id="difftitle">{{{ data.revision_date_author }}}</div> 110 <div id="diffcancel"><input class="button" onClick="document.location='<?php echo get_edit_post_link( $post->ID ); ?>'" type="submit" id="cancel" value="<?php esc_attr_e( 'Cancel' )?>" /></div> 111 <div id="diffrestore"><input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore' )?>" /></div> 112 <div id="comparetworevisions"><input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> <?php esc_attr_e( 'Compare two revisions' )?></div> 113 </div> 114 <div id="removedandadded"> 115 <div id="removed"><?php _e( 'Removed -' ); ?></div> 116 <div id="added"><?php _e( 'Added +' ); ?></div> 117 </div 118 <div>{{{ data.revisiondiff }}}</div> 119 </script> 120 121 <script id="tmpl-revisionvinteract" type="text/html"> 122 <div id="diffheader"> 123 <div id="diffprevious"><input class="button" type="submit" id="previous" value="Previous" /></div> 124 <div id="diffnext"><input class="button" type="submit" id="next" value="Next" /></div> 125 <div id="diffslider"> 126 <div id="revisioncount"> 127 <?php _e( 'Comparing' ); ?> 128 <span id="diff_left_count"> <?php _e( 'revision' ); ?></span> <span id="diff_left_count_inner"></span> 129 <span id="diff_left_current_revision"><?php _e( 'current version' ); ?></span> 130 <span id="diff_revision_from">{{{ data.diff_revision_from }}}</span> 131 <?php _e( ' to revision' ); ?> 132 <span id="diff_count">{{{ data.current_diff }}}</span> 133 <?php _e( ' of ' ); ?> 134 <span id="diff_max" ></span> 135 </div> 136 137 <div id="slider"></div> 138 </div> 139 </div> 140 </script> 222 141 <?php 142 /* 143 TODO Convert these into screen options 144 <script id="tmpl-revisionoptions" type="text/html"> 145 <div id="revisionoptions"> 146 <div id="showsplitviewoption"> 147 <input type='checkbox' id="show_split_view" checked="checked" value="1" /> <?php _e( 'Show split diff view' ); ?> 148 </div> 149 <div id="toggleshowautosavesoption"> 150 <input type='checkbox' id="toggleshowautosaves" value="1" /> <?php _e( 'Show autosaves' ); ?> 151 </div> 152 </div> 153 </script> 154 */ 223 155 require_once( './admin-footer.php' );
Note: See TracChangeset
for help on using the changeset viewer.