Version Description
Belorussian Translation, 3.2.x styling, Compare/Delete toggle fix, properly delete Taxonomy relationships.
=
Download this release
Release Info
| Developer | dd32 |
| Plugin | |
| Version | 2.1 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0.1 to 2.1
- readme.txt +13 -9
- revision-control.css +22 -1
- revision-control.js +12 -11
- revision-control.php +88 -68
readme.txt
CHANGED
|
@@ -1,32 +1,36 @@
|
|
| 1 |
=== Revision Control ===
|
| 2 |
Contributors: dd32
|
| 3 |
-
Tags:
|
| 4 |
-
Requires at least: 2
|
| 5 |
-
|
| 6 |
-
Stable tag: 2.0.1
|
| 7 |
|
| 8 |
Revision Control allows finer control over the Post Revision system included with WordPress
|
| 9 |
|
| 10 |
== Description ==
|
| 11 |
|
| 12 |
-
Revision Control is a plugin for WordPress
|
| 13 |
|
| 14 |
The plugin allows the user to set a site-global setting (Settings -> Revisions) for pages/posts to enable/disable/limit the number of revisions which are saved for the page/post. The user may change this setting on a per-page/post basis from the Revisions Meta box.
|
| 15 |
|
| 16 |
The plugin also allows the deletion of specific revisions via the Revisions post metabox.
|
| 17 |
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
A. At present, The only way to delete revisions is either, Individually on the Post/Page edit screen, Or by changing to Bulk deletion mode by clicking on the "Compare Delete" column header.
|
| 22 |
|
| 23 |
== Changelog ==
|
| 24 |
|
| 25 |
-
=
|
| 26 |
* Belorussian Translation from MarcisG
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
= 2.0.1 =
|
| 29 |
* Small IE bug fix, Table formatting was a bit wacky.
|
|
|
|
| 30 |
|
| 31 |
= 2.0 =
|
| 32 |
* Rewrite from scratch(99%) utilising 2.9 only functionality
|
| 1 |
=== Revision Control ===
|
| 2 |
Contributors: dd32
|
| 3 |
+
Tags: revisions, post, admin
|
| 4 |
+
Requires at least: 3.2
|
| 5 |
+
Stable tag: 2.1
|
|
|
|
| 6 |
|
| 7 |
Revision Control allows finer control over the Post Revision system included with WordPress
|
| 8 |
|
| 9 |
== Description ==
|
| 10 |
|
| 11 |
+
Revision Control is a plugin for WordPress which gives the user more control over the Revision functionality.
|
| 12 |
|
| 13 |
The plugin allows the user to set a site-global setting (Settings -> Revisions) for pages/posts to enable/disable/limit the number of revisions which are saved for the page/post. The user may change this setting on a per-page/post basis from the Revisions Meta box.
|
| 14 |
|
| 15 |
The plugin also allows the deletion of specific revisions via the Revisions post metabox.
|
| 16 |
|
| 17 |
+
== Ugrade Notice ==
|
| 18 |
|
| 19 |
+
= 2.1 =
|
| 20 |
+
Belorussian Translation, 3.2.x styling, Compare/Delete toggle fix, properly delete Taxonomy relationships.
|
|
|
|
| 21 |
|
| 22 |
== Changelog ==
|
| 23 |
|
| 24 |
+
= 2.1 =
|
| 25 |
* Belorussian Translation from MarcisG
|
| 26 |
+
* Bugfix: Delete Taxonomy relations for Revisions upon revision deletion
|
| 27 |
+
* Bigfix: Compare/Delete toggling
|
| 28 |
+
* Correct styling for WordPress 3.2+
|
| 29 |
+
*
|
| 30 |
|
| 31 |
= 2.0.1 =
|
| 32 |
* Small IE bug fix, Table formatting was a bit wacky.
|
| 33 |
+
* RECALLED update, Had brought up some issues in other browsers
|
| 34 |
|
| 35 |
= 2.0 =
|
| 36 |
* Rewrite from scratch(99%) utilising 2.9 only functionality
|
revision-control.css
CHANGED
|
@@ -4,10 +4,31 @@ table.post-revisions tr.current-revision{
|
|
| 4 |
}
|
| 5 |
|
| 6 |
table.post-revisions a.lock,
|
| 7 |
-
table.post-revisions a.unlock
|
|
|
|
| 8 |
color:#F00;
|
| 9 |
}
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
h2.center {
|
| 12 |
text-align: center !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 4 |
}
|
| 5 |
|
| 6 |
table.post-revisions a.lock,
|
| 7 |
+
table.post-revisions a.unlock,
|
| 8 |
+
table.post-revisions a.delete {
|
| 9 |
color:#F00;
|
| 10 |
}
|
| 11 |
|
| 12 |
+
table.post-revisions th.check-column {
|
| 13 |
+
margin: 0 5px;
|
| 14 |
+
}
|
| 15 |
+
table.post-revisions th.delete-column {
|
| 16 |
+
margin-left: 0;
|
| 17 |
+
padding-left: 0;
|
| 18 |
+
}
|
| 19 |
+
table.post-revisions .check-column {
|
| 20 |
+
font-size: 14px;
|
| 21 |
+
line-height: 1.3em;
|
| 22 |
+
padding-bottom: 8px;
|
| 23 |
+
padding-left: 7px;
|
| 24 |
+
padding-right: 7px;
|
| 25 |
+
padding-top: 7px;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
h2.center {
|
| 29 |
text-align: center !important;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
body.revision-control.iframe .wrap {
|
| 33 |
+
padding: 10px;
|
| 34 |
}
|
revision-control.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
| 1 |
-
jQuery( function($) {
|
| 2 |
|
| 3 |
-
$('a#revision-compare-delete-label').bind('click',
|
| 4 |
-
|
| 5 |
-
$(this).parents('table').find('.check-column input.toggle-type').toggle();
|
| 6 |
});
|
| 7 |
-
|
| 8 |
-
$('#revisions
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
if ( !confirm( RevisionControl.deleterevisions ) )
|
| 11 |
return;
|
| 12 |
|
|
@@ -28,7 +30,7 @@ jQuery( function($) {
|
|
| 28 |
var success = r.responses[0].data;
|
| 29 |
if ( -1 == success ) {
|
| 30 |
//Error - Failed to delete.
|
| 31 |
-
alert("
|
| 32 |
} else {
|
| 33 |
//Removed OK
|
| 34 |
var revs = r.responses[0].supplemental.revisions.split(',');
|
|
@@ -38,12 +40,11 @@ jQuery( function($) {
|
|
| 38 |
}
|
| 39 |
});
|
| 40 |
});
|
| 41 |
-
$('#revisions-compare').
|
| 42 |
-
function () {
|
| 43 |
var left = $(this).parents('table').find('input.left:checked').val();
|
| 44 |
var right = $(this).parents('table').find('input.right:checked').val();
|
| 45 |
if ( undefined == left || undefined == right ) {
|
| 46 |
-
alert(RevisionControl.selectbothradio);
|
| 47 |
return;
|
| 48 |
}
|
| 49 |
|
| 1 |
+
jQuery(document).ready( function($) {
|
| 2 |
|
| 3 |
+
$('a#revision-compare-delete-label').bind('click', function () {
|
| 4 |
+
$(this).parents('table').find('.check-column input.toggle-type, tfoot input.toggle-type').toggle();
|
|
|
|
| 5 |
});
|
| 6 |
+
|
| 7 |
+
$('#post-revisions a.delete').click( function() {
|
| 8 |
+
return confirm( RevisionControl.deleterevisions );
|
| 9 |
+
});
|
| 10 |
+
|
| 11 |
+
$('#revisions-delete').bind('click', function () {
|
| 12 |
if ( !confirm( RevisionControl.deleterevisions ) )
|
| 13 |
return;
|
| 14 |
|
| 30 |
var success = r.responses[0].data;
|
| 31 |
if ( -1 == success ) {
|
| 32 |
//Error - Failed to delete.
|
| 33 |
+
alert("The AJAX request has Failed, Please try again;\n The unexpected data was: " + xml);
|
| 34 |
} else {
|
| 35 |
//Removed OK
|
| 36 |
var revs = r.responses[0].supplemental.revisions.split(',');
|
| 40 |
}
|
| 41 |
});
|
| 42 |
});
|
| 43 |
+
$('#revisions-compare').click( function () {
|
|
|
|
| 44 |
var left = $(this).parents('table').find('input.left:checked').val();
|
| 45 |
var right = $(this).parents('table').find('input.right:checked').val();
|
| 46 |
if ( undefined == left || undefined == right ) {
|
| 47 |
+
alert( RevisionControl.selectbothradio );
|
| 48 |
return;
|
| 49 |
}
|
| 50 |
|
revision-control.php
CHANGED
|
@@ -4,42 +4,43 @@ Plugin Name: Revision Control
|
|
| 4 |
Plugin URI: http://dd32.id.au/wordpress-plugins/revision-control/
|
| 5 |
Description: Allows finer control over the number of Revisions stored on a global & per-type/page basis.
|
| 6 |
Author: Dion Hulse
|
| 7 |
-
Version: 2.
|
| 8 |
*/
|
| 9 |
|
| 10 |
-
$GLOBALS['revision_control'] = new Plugin_Revision_Control();
|
| 11 |
class Plugin_Revision_Control {
|
| 12 |
var $basename = '';
|
| 13 |
var $folder = '';
|
| 14 |
-
var $version = '2.
|
| 15 |
|
| 16 |
var $define_failure = false;
|
| 17 |
var $options = array( 'per-type' => array('post' => 'unlimited', 'page' => 'unlimited', 'all' => 'unlimited'), 'revision-range' => '2..5,10,20,50,100' );
|
| 18 |
|
| 19 |
-
function
|
| 20 |
//Set the directory of the plugin:
|
| 21 |
-
$this->basename =
|
| 22 |
-
$this->folder = dirname($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
//Register general hooks.
|
| 25 |
add_action('init', array(&$this, 'load_translations')); // Needs to be done before admin_menu.
|
| 26 |
-
add_action('plugins_loaded', array(&$this, 'define_WP_POST_REVISIONS'));
|
| 27 |
add_action('admin_menu', array(&$this, 'admin_menu'));
|
| 28 |
add_action('admin_init', array(&$this, 'admin_init'));
|
| 29 |
-
|
| 30 |
-
// Load options - Must be done on inclusion as they're needed by plugins_loaded
|
| 31 |
-
$this->load_options();
|
| 32 |
-
|
| 33 |
}
|
|
|
|
| 34 |
function load_translations() {
|
| 35 |
-
if ( ! is_admin() )
|
| 36 |
-
return;
|
| 37 |
//Load any translations.
|
| 38 |
load_plugin_textdomain( 'revision-control', false, $this->folder . '/langs/');
|
| 39 |
}
|
| 40 |
|
| 41 |
function admin_init() {
|
| 42 |
-
|
| 43 |
// Register post/page hook:
|
| 44 |
foreach ( array('load-post-new.php', 'load-post.php', 'load-page-new.php', 'load-page.php') as $page )
|
| 45 |
add_action($page, array(&$this, 'meta_box'));
|
|
@@ -63,6 +64,12 @@ class Plugin_Revision_Control {
|
|
| 63 |
|
| 64 |
// Version the terms.
|
| 65 |
add_action('_wp_put_post_revision', array(&$this, 'version_terms') );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
}
|
| 67 |
|
| 68 |
function admin_menu() {
|
|
@@ -70,22 +77,13 @@ class Plugin_Revision_Control {
|
|
| 70 |
}
|
| 71 |
|
| 72 |
function meta_box() {
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
if ( post_type_supports($type, 'revisions') )
|
| 78 |
-
$types[] = $type;
|
| 79 |
}
|
| 80 |
-
} else {
|
| 81 |
-
$types = array('post', 'page');
|
| 82 |
}
|
| 83 |
|
| 84 |
-
foreach ( $types as $post_type ) {
|
| 85 |
-
remove_meta_box('revisionsdiv', $post_type, 'normal');
|
| 86 |
-
add_meta_box('revisionsdiv', __('Post Revisions'), array('Plugin_Revision_Control_UI', 'revisions_meta_box'), $post_type, 'normal');
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
//enqueue that Stylin' script!
|
| 90 |
wp_enqueue_script('revision-control');
|
| 91 |
wp_enqueue_style('revision-control');
|
|
@@ -101,10 +99,9 @@ class Plugin_Revision_Control {
|
|
| 101 |
if ( false !== $new )
|
| 102 |
$this->delete_old_revisions($id, $new);
|
| 103 |
|
| 104 |
-
if ( false === $new || false === $old )
|
| 105 |
-
return;
|
| 106 |
-
if ( $new == $old )
|
| 107 |
return;
|
|
|
|
| 108 |
update_metadata('post', $id, '_revision-control', $new, $old);
|
| 109 |
}
|
| 110 |
|
|
@@ -190,9 +187,7 @@ class Plugin_Revision_Control {
|
|
| 190 |
} else {
|
| 191 |
$keep = $new;
|
| 192 |
}
|
| 193 |
-
|
| 194 |
-
// wp_redirect('');
|
| 195 |
-
// die();
|
| 196 |
while ( count($items) > $keep ) {
|
| 197 |
$item = array_shift($items);
|
| 198 |
wp_delete_post_revision($item->ID);
|
|
@@ -206,7 +201,7 @@ class Plugin_Revision_Control {
|
|
| 206 |
|
| 207 |
if ( isset($_REQUEST['revision']) )
|
| 208 |
if ( $post = get_post( $id = absint($_REQUEST['revision']) ) )
|
| 209 |
-
return get_post(
|
| 210 |
|
| 211 |
return false;
|
| 212 |
}
|
|
@@ -228,8 +223,25 @@ class Plugin_Revision_Control {
|
|
| 228 |
wp_set_object_terms($revision_id, $terms, $taxonomy);
|
| 229 |
}
|
| 230 |
}
|
| 231 |
-
|
| 232 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
|
| 234 |
function sort_revisions_by_time($a, $b) {
|
| 235 |
return strtotime($a->post_modified_gmt) < strtotime($b->post_modified_gmt);
|
|
@@ -351,7 +363,7 @@ class Plugin_Revision_Control_Ajax {
|
|
| 351 |
|
| 352 |
foreach ( $revisions as $revision_id ) {
|
| 353 |
$revision = get_post($revision_id);
|
| 354 |
-
if ( current_user_can('delete_post', $revision->post_parent) )
|
| 355 |
if ( wp_delete_post_revision($revision_id) )
|
| 356 |
$deleted[] = $revision_id;
|
| 357 |
}
|
|
@@ -378,13 +390,9 @@ class Plugin_Revision_Control_Ajax {
|
|
| 378 |
|
| 379 |
class Plugin_Revision_Control_UI {
|
| 380 |
function compare_revisions_iframe() {
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
// Hard coded translation strings here as the translations are not required, just the name and stlesheet.
|
| 385 |
-
wp_admin_css_color('classic', 'Blue', admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7'));
|
| 386 |
-
wp_admin_css_color('fresh', 'Gray', admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF'));
|
| 387 |
-
}
|
| 388 |
|
| 389 |
$left = isset($_GET['left']) ? absint($_GET['left']) : false;
|
| 390 |
$right = isset($_GET['right']) ? absint($_GET['right']) : false;
|
|
@@ -433,6 +441,9 @@ class Plugin_Revision_Control_UI {
|
|
| 433 |
$left = $left_revision->ID;
|
| 434 |
$right = $right_revision->ID;
|
| 435 |
|
|
|
|
|
|
|
|
|
|
| 436 |
iframe_header();
|
| 437 |
|
| 438 |
?>
|
|
@@ -464,9 +475,23 @@ class Plugin_Revision_Control_UI {
|
|
| 464 |
|
| 465 |
$left_revision->$taxonomy = ( empty($left_terms) ? '' : "* " ) . join("\n* ", $left_terms);
|
| 466 |
$right_revision->$taxonomy = ( empty($right_terms) ? '' : "* " ) . join("\n* ", $right_terms);
|
| 467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
}
|
| 469 |
|
|
|
|
|
|
|
|
|
|
| 470 |
$identical = true;
|
| 471 |
foreach ( $fields as $field => $field_title ) :
|
| 472 |
if ( !$content = wp_text_diff( $left_revision->$field, $right_revision->$field ) )
|
|
@@ -517,13 +542,15 @@ class Plugin_Revision_Control_UI {
|
|
| 517 |
<noscript><div class="updated"><p><?php _e('<strong>Please Note</strong>: This module requires the use of Javascript.', 'revision-control') ?></p></div></noscript>
|
| 518 |
<input type="hidden" id="revision-control-delete-nonce" value="<?php echo wp_create_nonce( 'revision-control-delete' ) ?>" />
|
| 519 |
<table class="widefat post-revisions" id="post-revisions" cellspacing="0">
|
| 520 |
-
<col class="
|
| 521 |
-
<col
|
|
|
|
| 522 |
<col style="width: 15%" />
|
| 523 |
<col style="width: 15" />
|
| 524 |
<thead>
|
| 525 |
<tr>
|
| 526 |
-
<th scope="col" class="check-column
|
|
|
|
| 527 |
<th scope="col"><?php _e( 'Date Created', 'revision-control' ); ?></th>
|
| 528 |
<th scope="col"><?php _e( 'Author', 'revision-control' ); ?></th>
|
| 529 |
<th scope="col" class="action-links"><?php _e( 'Actions', 'revision-control' ); ?></th>
|
|
@@ -544,16 +571,9 @@ class Plugin_Revision_Control_UI {
|
|
| 544 |
|
| 545 |
if ( empty($revisions) ) {
|
| 546 |
echo "<tr class='no-revisions'>\n";
|
| 547 |
-
echo "\t<td style='text-align: center' colspan='
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
$obj_name = $p_obj->label;
|
| 551 |
-
} else {
|
| 552 |
-
if ( 'post' == $post->post_type )
|
| 553 |
-
$obj_name = _n('Post', 'Posts', 5, 'revision-control');
|
| 554 |
-
elseif ( 'page' == $post->post_type )
|
| 555 |
-
$obj_name = _n('Page', 'Pages', 5, 'revision-control');
|
| 556 |
-
}
|
| 557 |
printf(_x('Revisions are currently enabled for %s, However there are no current Autosaves or Revisions created.<br />They\'ll be listed here once you Save. Happy Writing!', '1: the Post_Type - Posts, Pages, etc. (plural always)', 'revision-control'), $obj_name);
|
| 558 |
echo "</td>\n";
|
| 559 |
echo "</tr>\n";
|
|
@@ -581,20 +601,22 @@ class Plugin_Revision_Control_UI {
|
|
| 581 |
$actions[] = '<a href="#" class="lock" title="' . esc_attr__('Locks the selected revision to be the published copy. This allows you to work on modifications without making them public.', 'revision-control') . '">' . __('Lock', 'revision-control') . '</a>';
|
| 582 |
else
|
| 583 |
$actions[] = '<a href="#" class="unlock">' . __('Unlock', 'revision-control') . '</a>';*/
|
| 584 |
-
if ( $
|
| 585 |
$actions[] = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'diff' => false, 'action' => 'restore' ), 'revision.php' ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore', 'revision-control' ) . '</a>';
|
| 586 |
-
//$actions[] = '<a href="#" class="hide-if-no-js">' . __( '
|
| 587 |
}
|
| 588 |
|
| 589 |
-
$deletedisabled = $revision_is_current ? 'disabled="disabled"' : ''; //$revision_is_locked || ($revision_is_current && false === $locked_revision)
|
| 590 |
$lefthidden = $revision == end($revisions) ? ' style="visibility: hidden" ' : '';
|
| 591 |
$righthidden = $revision == $revisions[0] ? ' style="visibility: hidden" ' : '';
|
| 592 |
|
| 593 |
echo "<tr class='$class' id='revision-row-$revision->ID'>\n";
|
| 594 |
echo "\t<th style='white-space: nowrap' scope='row' class='check-column hide-if-no-js'>
|
| 595 |
<span class='delete'>
|
| 596 |
-
<input type='checkbox' name='checked[]' class='checklist toggle-type'
|
| 597 |
</span>
|
|
|
|
|
|
|
| 598 |
<span class='compare'>
|
| 599 |
<input type='radio' name='left' class='left toggle-type' value='$revision->ID' $lefthidden />
|
| 600 |
<input type='radio' name='right' class='right toggle-type' value='$revision->ID' $righthidden />
|
|
@@ -610,10 +632,10 @@ class Plugin_Revision_Control_UI {
|
|
| 610 |
</tbody>
|
| 611 |
<tfoot>
|
| 612 |
<tr>
|
| 613 |
-
<td colspan="
|
|
|
|
| 614 |
<span class="hide-if-no-js">
|
| 615 |
-
<input type="button" class="button-secondary
|
| 616 |
-
<input type="button" class="button-secondary toggle-type" value="<?php esc_attr_e('Compare', 'revision-control') ?>" id="revisions-compare" />
|
| 617 |
</span>
|
| 618 |
<span class="alignright">
|
| 619 |
<?php if ( $revision_control->define_failure ) {
|
|
@@ -720,10 +742,8 @@ class Plugin_Revision_Control_UI {
|
|
| 720 |
</td>
|
| 721 |
</tr>';
|
| 722 |
echo '</table>';
|
|
|
|
| 723 |
echo '
|
| 724 |
-
<p class="submit">
|
| 725 |
-
<input type="submit" name="Submit" value="' . __('Save Changes', 'revision-control') . '" />
|
| 726 |
-
</p>
|
| 727 |
</form>';
|
| 728 |
echo '</div>';
|
| 729 |
}
|
| 4 |
Plugin URI: http://dd32.id.au/wordpress-plugins/revision-control/
|
| 5 |
Description: Allows finer control over the number of Revisions stored on a global & per-type/page basis.
|
| 6 |
Author: Dion Hulse
|
| 7 |
+
Version: 2.1
|
| 8 |
*/
|
| 9 |
|
| 10 |
+
$GLOBALS['revision_control'] = new Plugin_Revision_Control( plugin_basename(__FILE__) );
|
| 11 |
class Plugin_Revision_Control {
|
| 12 |
var $basename = '';
|
| 13 |
var $folder = '';
|
| 14 |
+
var $version = '2.1';
|
| 15 |
|
| 16 |
var $define_failure = false;
|
| 17 |
var $options = array( 'per-type' => array('post' => 'unlimited', 'page' => 'unlimited', 'all' => 'unlimited'), 'revision-range' => '2..5,10,20,50,100' );
|
| 18 |
|
| 19 |
+
function __construct($plugin) {
|
| 20 |
//Set the directory of the plugin:
|
| 21 |
+
$this->basename = $plugin;
|
| 22 |
+
$this->folder = dirname($plugin);
|
| 23 |
+
|
| 24 |
+
// Load options - Must be done on inclusion as they're needed by plugins_loaded
|
| 25 |
+
$this->load_options();
|
| 26 |
+
|
| 27 |
+
add_action('plugins_loaded', array(&$this, 'define_WP_POST_REVISIONS'));
|
| 28 |
+
|
| 29 |
+
if ( ! is_admin() )
|
| 30 |
+
return;
|
| 31 |
|
| 32 |
//Register general hooks.
|
| 33 |
add_action('init', array(&$this, 'load_translations')); // Needs to be done before admin_menu.
|
|
|
|
| 34 |
add_action('admin_menu', array(&$this, 'admin_menu'));
|
| 35 |
add_action('admin_init', array(&$this, 'admin_init'));
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
}
|
| 37 |
+
|
| 38 |
function load_translations() {
|
|
|
|
|
|
|
| 39 |
//Load any translations.
|
| 40 |
load_plugin_textdomain( 'revision-control', false, $this->folder . '/langs/');
|
| 41 |
}
|
| 42 |
|
| 43 |
function admin_init() {
|
|
|
|
| 44 |
// Register post/page hook:
|
| 45 |
foreach ( array('load-post-new.php', 'load-post.php', 'load-page-new.php', 'load-page.php') as $page )
|
| 46 |
add_action($page, array(&$this, 'meta_box'));
|
| 64 |
|
| 65 |
// Version the terms.
|
| 66 |
add_action('_wp_put_post_revision', array(&$this, 'version_terms') );
|
| 67 |
+
//Delete the terms
|
| 68 |
+
add_action('wp_delete_post_revision', array(&$this, 'delete_terms'), 10, 2 );
|
| 69 |
+
|
| 70 |
+
// Version the postmeta
|
| 71 |
+
add_action('_wp_put_post_revision', array(&$this, 'version_postmeta') );
|
| 72 |
+
// Postmeta deletion is handled by core.
|
| 73 |
}
|
| 74 |
|
| 75 |
function admin_menu() {
|
| 77 |
}
|
| 78 |
|
| 79 |
function meta_box() {
|
| 80 |
+
foreach ( get_post_types() as $type ) {
|
| 81 |
+
if ( post_type_supports($type, 'revisions') ) {
|
| 82 |
+
remove_meta_box('revisionsdiv', $type, 'normal');
|
| 83 |
+
add_meta_box('revisionsdiv', __('Post Revisions'), array('Plugin_Revision_Control_UI', 'revisions_meta_box'), $type, 'normal');
|
|
|
|
|
|
|
| 84 |
}
|
|
|
|
|
|
|
| 85 |
}
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
//enqueue that Stylin' script!
|
| 88 |
wp_enqueue_script('revision-control');
|
| 89 |
wp_enqueue_style('revision-control');
|
| 99 |
if ( false !== $new )
|
| 100 |
$this->delete_old_revisions($id, $new);
|
| 101 |
|
| 102 |
+
if ( false === $new || false === $old || $new == $old)
|
|
|
|
|
|
|
| 103 |
return;
|
| 104 |
+
|
| 105 |
update_metadata('post', $id, '_revision-control', $new, $old);
|
| 106 |
}
|
| 107 |
|
| 187 |
} else {
|
| 188 |
$keep = $new;
|
| 189 |
}
|
| 190 |
+
|
|
|
|
|
|
|
| 191 |
while ( count($items) > $keep ) {
|
| 192 |
$item = array_shift($items);
|
| 193 |
wp_delete_post_revision($item->ID);
|
| 201 |
|
| 202 |
if ( isset($_REQUEST['revision']) )
|
| 203 |
if ( $post = get_post( $id = absint($_REQUEST['revision']) ) )
|
| 204 |
+
return get_post($post->post_parent);
|
| 205 |
|
| 206 |
return false;
|
| 207 |
}
|
| 223 |
wp_set_object_terms($revision_id, $terms, $taxonomy);
|
| 224 |
}
|
| 225 |
}
|
| 226 |
+
|
| 227 |
+
function delete_terms($revision_id, $rev) {
|
| 228 |
+
if ( ! $post = get_post($rev->post_parent) )
|
| 229 |
+
return;
|
| 230 |
+
|
| 231 |
+
// Delete the parent posts taxonomies from the revision.
|
| 232 |
+
wp_delete_object_term_relationships($revision_id, get_object_taxonomies($post->post_type) );
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
function version_postmeta($revision_id) {
|
| 236 |
+
// Attach all the terms from the parent to the revision.
|
| 237 |
+
if ( ! $rev = get_post($revision_id) )
|
| 238 |
+
return;
|
| 239 |
+
if ( ! $post = get_post($rev->post_parent) )
|
| 240 |
+
return;
|
| 241 |
+
|
| 242 |
+
// Only worry about taxonomies which are specifically linked.
|
| 243 |
+
|
| 244 |
+
}
|
| 245 |
|
| 246 |
function sort_revisions_by_time($a, $b) {
|
| 247 |
return strtotime($a->post_modified_gmt) < strtotime($b->post_modified_gmt);
|
| 363 |
|
| 364 |
foreach ( $revisions as $revision_id ) {
|
| 365 |
$revision = get_post($revision_id);
|
| 366 |
+
if ( wp_is_post_revision($revision) && !wp_is_post_autosave($revision) && current_user_can('delete_post', $revision->post_parent) )
|
| 367 |
if ( wp_delete_post_revision($revision_id) )
|
| 368 |
$deleted[] = $revision_id;
|
| 369 |
}
|
| 390 |
|
| 391 |
class Plugin_Revision_Control_UI {
|
| 392 |
function compare_revisions_iframe() {
|
| 393 |
+
//add_action('admin_init', 'register_admin_colors', 1);
|
| 394 |
+
|
| 395 |
+
set_current_screen('revision-edit');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
|
| 397 |
$left = isset($_GET['left']) ? absint($_GET['left']) : false;
|
| 398 |
$right = isset($_GET['right']) ? absint($_GET['right']) : false;
|
| 441 |
$left = $left_revision->ID;
|
| 442 |
$right = $right_revision->ID;
|
| 443 |
|
| 444 |
+
$GLOBALS['hook_suffix'] = 'revision-control';
|
| 445 |
+
wp_enqueue_style('revision-control');
|
| 446 |
+
|
| 447 |
iframe_header();
|
| 448 |
|
| 449 |
?>
|
| 475 |
|
| 476 |
$left_revision->$taxonomy = ( empty($left_terms) ? '' : "* " ) . join("\n* ", $left_terms);
|
| 477 |
$right_revision->$taxonomy = ( empty($right_terms) ? '' : "* " ) . join("\n* ", $right_terms);
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
$fields['postmeta'] = __('Post Meta', 'revision-control');
|
| 481 |
+
$left_revision->postmeta = $right_revision->postmeta = array();
|
| 482 |
+
foreach ( (array)has_meta($right_revision->ID) as $meta ) {
|
| 483 |
+
if ( '_' == $meta['meta_key'][0] )
|
| 484 |
+
continue;
|
| 485 |
+
|
| 486 |
+
$right_revision->postmeta[] = $meta['meta_key'] . ': ' . $meta['meta_value'];
|
| 487 |
+
$left_val = get_post_meta('post', $left_revision->ID, $meta['meta_key'], true);
|
| 488 |
+
if ( !empty( $left_val ) )
|
| 489 |
+
$left_revision->postmeta[] = $meta['meta_key'] . ': ' . $left_val;
|
| 490 |
}
|
| 491 |
|
| 492 |
+
$right_revision->postmeta = implode("\n", $right_revision->postmeta);
|
| 493 |
+
$left_revision->postmeta = implode("\n", $left_revision->postmeta);
|
| 494 |
+
|
| 495 |
$identical = true;
|
| 496 |
foreach ( $fields as $field => $field_title ) :
|
| 497 |
if ( !$content = wp_text_diff( $left_revision->$field, $right_revision->$field ) )
|
| 542 |
<noscript><div class="updated"><p><?php _e('<strong>Please Note</strong>: This module requires the use of Javascript.', 'revision-control') ?></p></div></noscript>
|
| 543 |
<input type="hidden" id="revision-control-delete-nonce" value="<?php echo wp_create_nonce( 'revision-control-delete' ) ?>" />
|
| 544 |
<table class="widefat post-revisions" id="post-revisions" cellspacing="0">
|
| 545 |
+
<col class="check-column" />
|
| 546 |
+
<col class="check-column hide-if-no-js" />
|
| 547 |
+
<col />
|
| 548 |
<col style="width: 15%" />
|
| 549 |
<col style="width: 15" />
|
| 550 |
<thead>
|
| 551 |
<tr>
|
| 552 |
+
<th scope="col" class="check-column delete-column" style="text-align:center; white-space:nowrap;"><input type='checkbox' name='checked[]' class='checklist' /><?php _e( 'Delete', 'revision-control' ); ?></th>
|
| 553 |
+
<th scope="col" class="check-column hide-if-no-js" style="text-align:center; white-space:nowrap;"><?php _e( 'Compare', 'revision-control' ); ?></th>
|
| 554 |
<th scope="col"><?php _e( 'Date Created', 'revision-control' ); ?></th>
|
| 555 |
<th scope="col"><?php _e( 'Author', 'revision-control' ); ?></th>
|
| 556 |
<th scope="col" class="action-links"><?php _e( 'Actions', 'revision-control' ); ?></th>
|
| 571 |
|
| 572 |
if ( empty($revisions) ) {
|
| 573 |
echo "<tr class='no-revisions'>\n";
|
| 574 |
+
echo "\t<td style='text-align: center' colspan='5'>\n";
|
| 575 |
+
$p_obj = get_post_type_object($post->post_type);
|
| 576 |
+
$obj_name = $p_obj->label;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
printf(_x('Revisions are currently enabled for %s, However there are no current Autosaves or Revisions created.<br />They\'ll be listed here once you Save. Happy Writing!', '1: the Post_Type - Posts, Pages, etc. (plural always)', 'revision-control'), $obj_name);
|
| 578 |
echo "</td>\n";
|
| 579 |
echo "</tr>\n";
|
| 601 |
$actions[] = '<a href="#" class="lock" title="' . esc_attr__('Locks the selected revision to be the published copy. This allows you to work on modifications without making them public.', 'revision-control') . '">' . __('Lock', 'revision-control') . '</a>';
|
| 602 |
else
|
| 603 |
$actions[] = '<a href="#" class="unlock">' . __('Unlock', 'revision-control') . '</a>';*/
|
| 604 |
+
if ( ! $revision_is_current && !wp_is_post_autosave($revision) && $can_edit_post ) {
|
| 605 |
$actions[] = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'diff' => false, 'action' => 'restore' ), 'revision.php' ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore', 'revision-control' ) . '</a>';
|
| 606 |
+
//$actions[] = '<a href="#" class="hide-if-no-js delete">' . __( 'Delete', 'revision-control' ) . '</a>';
|
| 607 |
}
|
| 608 |
|
| 609 |
+
$deletedisabled = ( $revision_is_current || wp_is_post_autosave($revision) || ! $can_edit_post ) ? 'disabled="disabled"' : ''; //$revision_is_locked || ($revision_is_current && false === $locked_revision)
|
| 610 |
$lefthidden = $revision == end($revisions) ? ' style="visibility: hidden" ' : '';
|
| 611 |
$righthidden = $revision == $revisions[0] ? ' style="visibility: hidden" ' : '';
|
| 612 |
|
| 613 |
echo "<tr class='$class' id='revision-row-$revision->ID'>\n";
|
| 614 |
echo "\t<th style='white-space: nowrap' scope='row' class='check-column hide-if-no-js'>
|
| 615 |
<span class='delete'>
|
| 616 |
+
<input type='checkbox' name='checked[]' class='checklist toggle-type' value='$revision->ID' $deletedisabled />
|
| 617 |
</span>
|
| 618 |
+
</th>
|
| 619 |
+
<th style='white-space: nowrap' scope='row' class='check-column'>
|
| 620 |
<span class='compare'>
|
| 621 |
<input type='radio' name='left' class='left toggle-type' value='$revision->ID' $lefthidden />
|
| 622 |
<input type='radio' name='right' class='right toggle-type' value='$revision->ID' $righthidden />
|
| 632 |
</tbody>
|
| 633 |
<tfoot>
|
| 634 |
<tr>
|
| 635 |
+
<td colspan="5">
|
| 636 |
+
<input type="button" class="button-secondary" value="<?php esc_attr_e('Delete', 'revision-control') ?>" id="revisions-delete" />
|
| 637 |
<span class="hide-if-no-js">
|
| 638 |
+
<input type="button" class="button-secondary" value="<?php esc_attr_e('Compare', 'revision-control') ?>" id="revisions-compare" />
|
|
|
|
| 639 |
</span>
|
| 640 |
<span class="alignright">
|
| 641 |
<?php if ( $revision_control->define_failure ) {
|
| 742 |
</td>
|
| 743 |
</tr>';
|
| 744 |
echo '</table>';
|
| 745 |
+
submit_button( __('Save Changes', 'revision-control') );
|
| 746 |
echo '
|
|
|
|
|
|
|
|
|
|
| 747 |
</form>';
|
| 748 |
echo '</div>';
|
| 749 |
}
|
