mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
Post revisions from mdawaffe. see #6775
git-svn-id: https://develop.svn.wordpress.org/trunk@7747 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -460,6 +460,8 @@ case 'add-user' :
|
||||
$x->send();
|
||||
break;
|
||||
case 'autosave' : // The name of this action is hardcoded in edit_post()
|
||||
define( 'DOING_AUTOSAVE', true );
|
||||
|
||||
$nonce_age = check_ajax_referer( 'autosave', 'autosavenonce');
|
||||
global $current_user;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ a.page-numbers:hover {
|
||||
border-color: #999;
|
||||
}
|
||||
|
||||
body {
|
||||
body, .form-table pre {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
}
|
||||
@@ -713,3 +713,18 @@ div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover
|
||||
background-color: #ddd;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* Diff */
|
||||
|
||||
table.diff .diff-deletedline {
|
||||
background-color: #ffdddd;
|
||||
}
|
||||
table.diff .diff-deletedline del {
|
||||
background-color: #ff9999;
|
||||
}
|
||||
table.diff .diff-addedline {
|
||||
background-color: #ddffdd;
|
||||
}
|
||||
table.diff .diff-addedline ins {
|
||||
background-color: #99ff99;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ a.page-numbers:hover {
|
||||
border-color: #999;
|
||||
}
|
||||
|
||||
body {
|
||||
body, .form-table pre {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
}
|
||||
@@ -684,3 +684,18 @@ div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover
|
||||
background-color: #ddd;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* Diff */
|
||||
|
||||
table.diff .diff-deletedline {
|
||||
background-color: #ffdddd;
|
||||
}
|
||||
table.diff .diff-deletedline del {
|
||||
background-color: #ff9999;
|
||||
}
|
||||
table.diff .diff-addedline {
|
||||
background-color: #ddffdd;
|
||||
}
|
||||
table.diff .diff-addedline ins {
|
||||
background-color: #99ff99;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,10 @@ div#dashboard-widgets {
|
||||
.tablenav-pages {
|
||||
display: block;
|
||||
margin-top: -3px;
|
||||
}
|
||||
|
||||
table.ie-fixed {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
#post-search .button, #widget-search .button {
|
||||
|
||||
@@ -6,6 +6,7 @@ $messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s
|
||||
$messages[2] = __('Custom field updated.');
|
||||
$messages[3] = __('Custom field deleted.');
|
||||
$messages[4] = __('Post updated.');
|
||||
$messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_time( $_GET['revision'] ) );
|
||||
?>
|
||||
<?php if (isset($_GET['message'])) : ?>
|
||||
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
|
||||
@@ -336,6 +337,15 @@ if ( $authors && count( $authors ) > 1 ) :
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : ?>
|
||||
<div id="revisionsdiv" class="postbox <?php echo postbox_classes('revisionsdiv', 'post'); ?>">
|
||||
<h3><?php _e('Post Revisions'); ?></h3>
|
||||
<div class="inside">
|
||||
<?php wp_list_post_revisions(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_meta_boxes('post', 'advanced', $post); ?>
|
||||
|
||||
<?php do_action('dbx_post_sidebar'); ?>
|
||||
|
||||
+2
-2
@@ -70,8 +70,8 @@ case 'edit':
|
||||
|
||||
if ( empty($post->ID) ) wp_die( __("You attempted to edit a page that doesn't exist. Perhaps it was deleted?") );
|
||||
|
||||
if ( 'post' == $post->post_type ) {
|
||||
wp_redirect("post.php?action=edit&post=$post_ID");
|
||||
if ( 'page' != $post->post_type ) {
|
||||
wp_redirect( get_edit_post_link( $post_ID, 'url' ) );
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -77,8 +77,8 @@ case 'edit':
|
||||
|
||||
if ( empty($post->ID) ) wp_die( __("You attempted to edit a post that doesn't exist. Perhaps it was deleted?") );
|
||||
|
||||
if ( 'page' == $post->post_type ) {
|
||||
wp_redirect("page.php?action=edit&post=$post_ID");
|
||||
if ( 'post' != $post->post_type ) {
|
||||
wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
require_once('admin.php');
|
||||
|
||||
$parent_file = 'edit.php';
|
||||
$submenu_file = 'edit.php';
|
||||
|
||||
wp_reset_vars(array('revision', 'diff', 'restore'));
|
||||
|
||||
$revision_id = absint($revision);
|
||||
$diff = absint($diff);
|
||||
|
||||
if ( $diff ) {
|
||||
$restore = false;
|
||||
$revision = get_post( $revision_id );
|
||||
$post = 'revision' == $revision->post_type ? get_post( $revision->post_parent ) : get_post( $revision_id );
|
||||
$left_revision = get_post( $diff );
|
||||
|
||||
// Don't allow reverse diffs?
|
||||
if ( strtotime($revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt) ) {
|
||||
wp_redirect( add_query_arg( array( 'diff' => $revision->ID, 'revision' => $diff ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$h2 = __( 'Compare Revisions of “%1$s”' );
|
||||
$right = $revision->ID;
|
||||
$left = $left_revision->ID;
|
||||
|
||||
if (
|
||||
// They're the same
|
||||
$left_revision->ID == $revision->ID
|
||||
||
|
||||
// They don't have a comment parent (and we're not comparing a revision to it's post)
|
||||
( $left_revision->ID != $revision->post_parent && $left_revision->post_parent != $revision->ID && $left_revision->post_parent != $revision->post_parent )
|
||||
||
|
||||
// Neither is a revision
|
||||
( !wp_get_revision( $left_revision->ID ) && !wp_get_revision( $revision->ID ) )
|
||||
) {
|
||||
wp_redirect( get_edit_post_link( $revision->ID, 'url' ) );
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
$revision = wp_get_revision( $revision_id );
|
||||
$post = get_post( $revision->post_parent );
|
||||
$h2 = __( 'Post Revision for “%1$s” created on %2$s' );
|
||||
$right = $post->ID;
|
||||
$left = $revision->ID;
|
||||
}
|
||||
|
||||
if ( !$revision || !$post ) {
|
||||
wp_redirect("edit.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
if ( $restore && current_user_can( 'edit_post', $revision->post_parent ) ) {
|
||||
check_admin_referer( "restore-post_$post->ID|$revision->ID" );
|
||||
wp_restore_revision( $revision->ID );
|
||||
wp_redirect( add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
add_filter( '_wp_revision_field_post_author', 'get_author_name' );
|
||||
|
||||
$title = __( 'Post Revision' );
|
||||
|
||||
require_once( 'admin-header.php' );
|
||||
|
||||
$post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
|
||||
$revision_time = wp_post_revision_time( $revision );
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<h2 style="padding-right: 0"><?php printf( $h2, $post_title, $revision_time ); ?></h2>
|
||||
|
||||
<table class="form-table ie-fixed">
|
||||
<col class="th" />
|
||||
<?php if ( $diff ) : ?>
|
||||
|
||||
<tr id="revision">
|
||||
<th scope="row"></th>
|
||||
<th scope="col" class="th-full"><?php printf( __('Older: %s'), wp_post_revision_time( $left_revision ) ); ?></td>
|
||||
<th scope="col" class="th-full"><?php printf( __('Newer: %s'), wp_post_revision_time( $revision ) ); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php endif;
|
||||
|
||||
// use get_post_to_edit ?
|
||||
$identical = true;
|
||||
foreach ( _wp_revision_fields() as $field => $field_title ) :
|
||||
if ( !$diff )
|
||||
add_filter( "_wp_revision_field_$field", 'htmlspecialchars' );
|
||||
$content = apply_filters( "_wp_revision_field_$field", $revision->$field, $field );
|
||||
if ( $diff ) {
|
||||
$left_content = apply_filters( "_wp_revision_field_$field", $left_revision->$field, $field );
|
||||
if ( !$content = wp_text_diff( $left_content, $content ) )
|
||||
continue;
|
||||
}
|
||||
$identical = false;
|
||||
?>
|
||||
|
||||
<tr id="revision-field-<?php echo $field; ?>"?>
|
||||
<th scope="row"><?php echo wp_specialchars( $field_title ); ?></th>
|
||||
<td colspan="2"><pre><?php echo $content; ?></pre></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
endforeach;
|
||||
|
||||
if ( $diff && $identical ) :
|
||||
|
||||
?>
|
||||
|
||||
<tr><td colspan="3"><div class="updated"><p><?php _e( 'These revisions are identical' ); ?></p></div></td></tr>
|
||||
|
||||
<?php
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
||||
</table>
|
||||
|
||||
<br class="clear" />
|
||||
|
||||
<h2><?php _e( 'Post Revisions' ); ?></h2>
|
||||
|
||||
<?php
|
||||
wp_list_post_revisions( $post, array( 'format' => 'form-table', 'exclude' => $revision->ID, 'parent' => true, 'right' => $right, 'left' => $left ) );
|
||||
|
||||
require_once( 'admin-footer.php' );
|
||||
@@ -894,6 +894,21 @@ html, body {
|
||||
margin-right: 5px
|
||||
}
|
||||
|
||||
.form-table pre {
|
||||
padding: 8px;
|
||||
margin: 0;
|
||||
/* http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/ */
|
||||
white-space: pre-wrap; /* css-3 */
|
||||
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
white-space: -o-pre-wrap; /* Opera 7 */
|
||||
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
||||
}
|
||||
|
||||
table.form-table td .updated {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* Post Screen */
|
||||
|
||||
#tagsdiv #newtag {
|
||||
@@ -1464,3 +1479,27 @@ td.action-links, th.action-links {
|
||||
.hide-if-no-js {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Diff */
|
||||
|
||||
table.diff {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.diff col.content {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
table.diff tr {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
table.diff td, table.diff th {
|
||||
padding: .5em;
|
||||
font-family: monospace;
|
||||
border: none;
|
||||
}
|
||||
|
||||
table.diff .diff-deletedline del, table.diff .diff-addedline ins {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user