From bdeba45d760c7bf6ed24c99318b85bd4ad234b13 Mon Sep 17 00:00:00 2001
From: Kevin Behrens <43488774+agapetry@users.noreply.github.com>
Date: Thu, 17 Mar 2022 16:08:37 -0400
Subject: [PATCH 01/11] Revision submission in Classic displays "Undefined"
link
Fixes #653
---
admin/rvy_revision-classic-edit.dev.js | 5 -----
admin/rvy_revision-classic-edit.js | 4 +---
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/admin/rvy_revision-classic-edit.dev.js b/admin/rvy_revision-classic-edit.dev.js
index 00353b7b..e5c40917 100644
--- a/admin/rvy_revision-classic-edit.dev.js
+++ b/admin/rvy_revision-classic-edit.dev.js
@@ -35,10 +35,6 @@ jQuery(document).ready( function($) {
+ ' '
+ rvyObjEdit[rvyObjEdit.currentStatus + 'CompletedLinkCaption'] + ''
-
- + ' '
- + rvyObjEdit[rvyObjEdit.currentStatus + 'CompletedEditLinkCaption'] + ''
-
+ ''
+ '
'
@@ -97,7 +93,6 @@ jQuery(document).ready( function($) {
$('#post-status-display').html(rvyObjEdit[rvyObjEdit.currentStatus + 'StatusCaption']);
$('a.revision-preview').attr('href', rvyObjEdit[rvyObjEdit.currentStatus + 'CompletedURL']).show();
- $('a.revision-edit').attr('href', rvyObjEdit[rvyObjEdit.currentStatus + 'CompletedEditURL']).show();
}
var revisionaryCreateError = function (data, txtStatus) {
diff --git a/admin/rvy_revision-classic-edit.js b/admin/rvy_revision-classic-edit.js
index 362a1cda..bd5efce3 100644
--- a/admin/rvy_revision-classic-edit.js
+++ b/admin/rvy_revision-classic-edit.js
@@ -8,8 +8,6 @@ if(rvyObjEdit[rvyObjEdit.currentStatus+'ActionCaption']){$(refSelector).after('<
+rvyObjEdit[rvyObjEdit.currentStatus+'CompletedCaption']+' '
+' '
+rvyObjEdit[rvyObjEdit.currentStatus+'CompletedLinkCaption']+''
-+' '
-+rvyObjEdit[rvyObjEdit.currentStatus+'CompletedEditLinkCaption']+''
+''
+'
');}
$('.edit-post-post-schedule__toggle').after('');if(rvyObjEdit[rvyObjEdit.currentStatus+'DeletionURL']){$('a.submitdelete').attr('href',rvyObjEdit[rvyObjEdit.currentStatus+'DeletionURL']);}
@@ -17,6 +15,6 @@ $('#publish').hide();$('#save-post').val(rvyObjEdit.updateCaption);if(rvyObjEdit
var RvyUIInterval=setInterval(RvySubmissionUI,100);$(document).on('click','a.save-timestamp, a.cancel-timestamp',function(){wp.autosave.server.triggerSave();});function RvyGetRandomInt(max){return Math.floor(Math.random()*max);}
$(document).on('click','div.postbox-container',function(){$('a.revision-approve').attr('disabled','disabled');});$(document).on('click','a.revision-approve',function(){if($('a.revision-approve').attr('disabled')){return;}
$('a.revision-approve').attr('disabled','disabled');if(wp.autosave.server.postChanged()){wp.autosave.server.triggerSave();var approvalDelay=250;}else{var approvalDelay=1;}
-if(!rvyObjEdit[rvyObjEdit.currentStatus+'ActionURL']){var revisionaryCreateDone=function(){$('a.revision-approve').hide();$('.revision-created-wrapper, .revision-created').show();rvyObjEdit.currentStatus='pending';$('#post-status-display').html(rvyObjEdit[rvyObjEdit.currentStatus+'StatusCaption']);$('a.revision-preview').attr('href',rvyObjEdit[rvyObjEdit.currentStatus+'CompletedURL']).show();$('a.revision-edit').attr('href',rvyObjEdit[rvyObjEdit.currentStatus+'CompletedEditURL']).show();}
+if(!rvyObjEdit[rvyObjEdit.currentStatus+'ActionURL']){var revisionaryCreateDone=function(){$('a.revision-approve').hide();$('.revision-created-wrapper, .revision-created').show();rvyObjEdit.currentStatus='pending';$('#post-status-display').html(rvyObjEdit[rvyObjEdit.currentStatus+'StatusCaption']);$('a.revision-preview').attr('href',rvyObjEdit[rvyObjEdit.currentStatus+'CompletedURL']).show();}
var revisionaryCreateError=function(data,txtStatus){$('div.rvy-creation-ui').html(rvyObjEdit[rvyObjEdit.currentStatus+'ErrorCaption']);}
var tmoSubmit=setInterval(function(){if(!wp.autosave.server.postChanged()){var data={'rvy_ajax_field':rvyObjEdit[rvyObjEdit.currentStatus+'AjaxField'],'rvy_ajax_value':rvyObjEdit.postID,'nc':RvyGetRandomInt(99999999)};$.ajax({url:rvyObjEdit.ajaxurl,data:data,dataType:"html",success:revisionaryCreateDone,error:revisionaryCreateError});clearInterval(tmoSubmit);}},approvalDelay);}else{var tmoApproval=setInterval(function(){if(!wp.autosave.server.postChanged()){window.location=rvyObjEdit[rvyObjEdit.currentStatus+'ActionURL'];clearInterval(tmoApproval);}},approvalDelay);return false;}});$(document).on('click','#post-body-content *, #content_ifr *, #wp-content-editor-container *, #tinymce *, #submitpost, span.revision-created',function(){$('.revision-created-wrapper, .revision-created').hide();$('a.revision-approve').html(rvyObjEdit[rvyObjEdit.currentStatus+'ActionCaption']).show().removeAttr('disabled');});});
\ No newline at end of file
From 246cf8c441eb903c3304e860a1fc30af1d81102e Mon Sep 17 00:00:00 2001
From: Kevin Behrens <43488774+agapetry@users.noreply.github.com>
Date: Thu, 17 Mar 2022 16:11:18 -0400
Subject: [PATCH 02/11] New revisions created with "Auto-submit" option have
wrong date
Fixes #655
---
revision-creation_rvy.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/revision-creation_rvy.php b/revision-creation_rvy.php
index ffd92537..e54a3f76 100644
--- a/revision-creation_rvy.php
+++ b/revision-creation_rvy.php
@@ -171,7 +171,11 @@ private function insert_revision($data, $base_post_id, $revision_status, $args =
return new \WP_Error(__( 'Could not insert revision into the database', 'revisionary'));
}
- $wpdb->update($wpdb->posts, ['comment_count' => $base_post_id], ['ID' => $revision_id]);
+ $update_data = ('pending-revision' == $data['post_mime_type']) //
+ ? ['comment_count' => $base_post_id, 'post_modified_gmt' => $data['post_modified_gmt'], 'post_modified' => $data['post_modified']]
+ : ['comment_count' => $base_post_id];
+
+ $wpdb->update($wpdb->posts, $update_data, ['ID' => $revision_id]);
// Use the newly generated $post_ID.
$where = array( 'ID' => $revision_id );
From b6f3bb40d0e1e4c7fcb7727bd513953e410902e6 Mon Sep 17 00:00:00 2001
From: Kevin Behrens <43488774+agapetry@users.noreply.github.com>
Date: Thu, 17 Mar 2022 16:14:53 -0400
Subject: [PATCH 03/11] Scheduled revisions not included in dashboard
Publishing Soon list
Fixes #657
---
admin/admin-dashboard_rvy.php | 7 +++++++
admin/admin_rvy.php | 3 +++
revisionary_main.php | 5 +++--
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/admin/admin-dashboard_rvy.php b/admin/admin-dashboard_rvy.php
index e39e7d26..055bac6d 100644
--- a/admin/admin-dashboard_rvy.php
+++ b/admin/admin-dashboard_rvy.php
@@ -1,5 +1,8 @@
posts.post_type = 'post'", "$wpdb->posts.post_type IN ('$post_types_csv')", $clauses['where'] );
+ $clauses['where'] = str_replace( "$wpdb->posts.post_status = 'future'", "($wpdb->posts.post_status = 'future' OR ($wpdb->posts.post_status = 'pending' AND $wpdb->posts.post_mime_type = 'future-revision'))", $clauses['where'] );
+
+ $revisionary->is_revisions_query = false;
+
remove_filter('posts_clauses_request', [&$this, 'fltDashboardQueryClauses']);
return $clauses;
}
diff --git a/admin/admin_rvy.php b/admin/admin_rvy.php
index a76ce4cd..cd3bec92 100644
--- a/admin/admin_rvy.php
+++ b/admin/admin_rvy.php
@@ -211,6 +211,9 @@ function limitRevisionEditorUI() {
function flt_dashboard_recent_posts_query_args($query_args) {
if ('future' == $query_args['post_status']) {
+ global $revisionary;
+ $revisionary->is_revisions_query = true;
+
require_once(dirname(__FILE__).'/admin-dashboard_rvy.php');
$rvy_dash = new RevisionaryDashboard();
$query_args = $rvy_dash->recentPostsQueryArgs($query_args);
diff --git a/revisionary_main.php b/revisionary_main.php
index 5bb36c8f..391e7aaf 100644
--- a/revisionary_main.php
+++ b/revisionary_main.php
@@ -16,6 +16,7 @@ class Revisionary
var $rest = ''; // object ref - Revisionary_REST
var $internal_meta_update = false;
var $skip_filtering = false;
+ var $is_revisions_query = false;
var $config_loaded = false; // configuration related to post types and statuses must be loaded late on the init action
var $enabled_post_types = []; // enabled_post_types property is set (keyed by post type slug) late on the init action.
@@ -235,7 +236,7 @@ function configurationLateInit() {
}
public function fltPostsClauses($clauses, $_wp_query, $args = []) {
- global $wpdb;
+ global $wpdb, $revisionary;
$defaults = [
'is_revisions_query' => false,
@@ -247,7 +248,7 @@ public function fltPostsClauses($clauses, $_wp_query, $args = []) {
$$var = $args[$var];
}
- if ($is_revisions_query || !empty($_wp_query->is_revisions_query) || !empty($_wp_query->query['is_revisions_query']) || $_wp_query->is_preview) {
+ if ($is_revisions_query || !empty($_wp_query->is_revisions_query) || !empty($_wp_query->query['is_revisions_query']) || (!empty($revisionary) && !empty($revisionary->is_revisions_query)) || $_wp_query->is_preview) {
return $clauses;
}
From 4835d17c41861011bdb45053190dc51a98b6457d Mon Sep 17 00:00:00 2001
From: Kevin Behrens <43488774+agapetry@users.noreply.github.com>
Date: Thu, 17 Mar 2022 16:17:54 -0400
Subject: [PATCH 04/11] Pro: Divi - Classic Editor setting did not trigger
correct Revisions UI
Fixes #659
---
utils.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/utils.php b/utils.php
index 73c1b663..5b8f8113 100644
--- a/utils.php
+++ b/utils.php
@@ -97,6 +97,11 @@ public static function isBlockEditorActive() {
remove_filter('use_block_editor_for_post_type', '_disable_block_editor_for_navigation_post_type', 10, 2);
}
+ // Divi: Classic Editor option
+ if (function_exists('et_get_option') && ( 'on' == et_get_option( 'et_enable_classic_editor', 'off' ))) {
+ return false;
+ }
+
// phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.NoNonceVerification
$conditions[] = (self::isWp5() || $pluginsState['gutenberg'])
&& ! $pluginsState['classic-editor']
From 2b4ee0cf3959fe5b4836014675ffd4c791bb54c2 Mon Sep 17 00:00:00 2001
From: Kevin Behrens <43488774+agapetry@users.noreply.github.com>
Date: Thu, 17 Mar 2022 16:19:58 -0400
Subject: [PATCH 05/11] Pro: Divi - Revision preview bar not visible on front
end
Fixes #661
---
front_rvy.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/front_rvy.php b/front_rvy.php
index c3d2f87e..d0e27301 100644
--- a/front_rvy.php
+++ b/front_rvy.php
@@ -428,7 +428,11 @@ function rvyPreviewJS() {
rvyAdminBarMenuZindex = barZ;
}
} else {
+ if (!empty($_REQUEST['et_fb']) && !defined('PP_REVISIONS_DIVI_NO_ADMIN_BAR') && function_exists('et_divi_replace_parent_stylesheet') && (!defined('ET_BUILDER_PRODUCT_VERSION') || version_compare(ET_BUILDER_PRODUCT_VERSION, '4.14.8', '<='))) {
+ var rvyAdminBarHeight = '32px';
+ } else {
var rvyAdminBarHeight = 0;
+ }
}
$('div.rvy_view_revision').css('position', 'fixed').css('top', '32px');
From ebaa578ee40644fd42f929d2bb0e268819b499ea Mon Sep 17 00:00:00 2001
From: Kevin Behrens <43488774+agapetry@users.noreply.github.com>
Date: Thu, 17 Mar 2022 16:23:23 -0400
Subject: [PATCH 06/11] PHP warning on revision approval
---
functions.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/functions.php b/functions.php
index 7f36a296..1a0b160d 100644
--- a/functions.php
+++ b/functions.php
@@ -136,12 +136,12 @@ function revisionary_copy_postmeta($from_post, $to_post_id, $args = []) {
$meta_keys = array_diff( $source_meta_keys, $meta_excludelist );
}
- $target_meta_keys = \get_post_custom_keys( $to_post_id );
+ $target_meta_keys = (array) \get_post_custom_keys( $to_post_id );
$meta_keys = apply_filters('revisionary_create_revision_meta_keys', $meta_keys);
foreach ( $meta_keys as $meta_key ) {
- if ($empty_target_only) {
+ if ($empty_target_only && !empty($target_meta_keys) && is_array($target_meta_keys)) {
if (in_array($meta_key, $target_meta_keys)) {
continue;
}
From 222b9b9805d78752e7d0f3561ff6d1746f6e16da Mon Sep 17 00:00:00 2001
From: Kevin Behrens <43488774+agapetry@users.noreply.github.com>
Date: Thu, 17 Mar 2022 16:24:02 -0400
Subject: [PATCH 07/11] Support filtering of update_post_date setting
---
admin/revision-action_rvy.php | 12 ++++++------
rvy_init.php | 4 ++++
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/admin/revision-action_rvy.php b/admin/revision-action_rvy.php
index 0198f9d5..d1fbf1e6 100644
--- a/admin/revision-action_rvy.php
+++ b/admin/revision-action_rvy.php
@@ -586,8 +586,8 @@ function rvy_apply_revision( $revision_id, $actual_revision_status = '' ) {
);
if (
- (in_array($revision->post_mime_type, ['pending-revision', 'draft-revision']) && !rvy_get_option('pending_revision_update_post_date'))
- || (('future-revision' == $revision->post_mime_type) && !rvy_get_option('scheduled_revision_update_post_date'))
+ (in_array($revision->post_mime_type, ['pending-revision', 'draft-revision']) && !rvy_filter_option('pending_revision_update_post_date', ['revision_id' => $revision_id, 'post_id' => $published->ID]))
+ || (('future-revision' == $revision->post_mime_type) && !rvy_filter_option('scheduled_revision_update_post_date', ['revision_id' => $revision_id, 'post_id' => $published->ID]))
) {
// @todo: how was post_date_gmt of published post previously set to zero?
if (('0000-00-00 00:00:00' == $published->post_date_gmt) && ('0000-00-00 00:00:00' != $published->post_date)) {
@@ -660,8 +660,8 @@ function rvy_apply_revision( $revision_id, $actual_revision_status = '' ) {
}
if (
- (in_array($revision->post_mime_type, ['draft-revision', 'pending-revision']) && rvy_get_option('pending_revision_update_modified_date'))
- || (('future-revision' == $revision->post_mime_type) && rvy_get_option('scheduled_revision_update_modified_date'))
+ (in_array($revision->post_mime_type, ['draft-revision', 'pending-revision']) && rvy_filter_option('pending_revision_update_modified_date', ['revision_id' => $revision_id, 'post_id' => $published->ID]))
+ || (('future-revision' == $revision->post_mime_type) && rvy_filter_option('scheduled_revision_update_modified_date', ['revision_id' => $revision_id, 'post_id' => $published->ID]))
) {
$post_modified = current_time('mysql');
$post_modified_gmt = current_time('mysql', 1);
@@ -674,8 +674,8 @@ function rvy_apply_revision( $revision_id, $actual_revision_status = '' ) {
$update_fields['post_modified_gmt'] = $post_modified_gmt;
if (
- (in_array($revision->post_mime_type, ['draft-revision', 'pending-revision']) && rvy_get_option('pending_revision_update_post_date'))
- || (('future-revision' == $revision->post_mime_type) && rvy_get_option('scheduled_revision_update_post_date'))
+ (in_array($revision->post_mime_type, ['draft-revision', 'pending-revision']) && rvy_filter_option('pending_revision_update_post_date', ['revision_id' => $revision_id, 'post_id' => $published->ID]))
+ || (('future-revision' == $revision->post_mime_type) && rvy_filter_option('scheduled_revision_update_post_date', ['revision_id' => $revision_id, 'post_id' => $published->ID]))
) {
$update_fields['post_date'] = $post_modified;
$update_fields['post_date_gmt'] = $post_modified_gmt;
diff --git a/rvy_init.php b/rvy_init.php
index 661867ce..c09cc400 100644
--- a/rvy_init.php
+++ b/rvy_init.php
@@ -897,6 +897,10 @@ function rvy_retrieve_options( $sitewide = false ) {
}
}
+function rvy_filter_option($option_basename, $args) {
+ return apply_filters("pp_revisions_option_{$option_basename}", rvy_get_option($option_basename), $args);
+}
+
function rvy_get_option($option_basename, $sitewide = -1, $get_default = false) {
if (('async_scheduled_publish' == $option_basename) && function_exists('relevanssi_query')) {
return false;
From 55082bb4497a78e8dd2f75a686b4f9428b138ba3 Mon Sep 17 00:00:00 2001
From: Kevin Behrens <43488774+agapetry@users.noreply.github.com>
Date: Thu, 17 Mar 2022 16:24:23 -0400
Subject: [PATCH 08/11] Classic Editor element selection fix
---
admin/rvy_revision-classic-edit.dev.js | 4 ++++
admin/rvy_revision-classic-edit.js | 1 +
2 files changed, 5 insertions(+)
diff --git a/admin/rvy_revision-classic-edit.dev.js b/admin/rvy_revision-classic-edit.dev.js
index e5c40917..b97d3b9a 100644
--- a/admin/rvy_revision-classic-edit.dev.js
+++ b/admin/rvy_revision-classic-edit.dev.js
@@ -13,6 +13,10 @@ jQuery(document).ready( function($) {
var refSelector = 'div.misc-pub-section-last';
}
+ if (!$(refSelector).length) {
+ var refSelector = 'div.misc-pub-curtime';
+ }
+
if (rvyObjEdit.ajaxurl && !$('div.rvy-creation-ui').length && $(refSelector).length) {
$('#post-status-display').html(rvyObjEdit[rvyObjEdit.currentStatus + 'StatusCaption']);
diff --git a/admin/rvy_revision-classic-edit.js b/admin/rvy_revision-classic-edit.js
index bd5efce3..ec7237db 100644
--- a/admin/rvy_revision-classic-edit.js
+++ b/admin/rvy_revision-classic-edit.js
@@ -1,4 +1,5 @@
jQuery(document).ready(function($){var RvySubmissionUI=function(){var refSelector='#rvy_compare_button';if(!$(refSelector).length){var refSelector='div.misc-pub-section-last';}
+if(!$(refSelector).length){var refSelector='div.misc-pub-curtime';}
if(rvyObjEdit.ajaxurl&&!$('div.rvy-creation-ui').length&&$(refSelector).length){$('#post-status-display').html(rvyObjEdit[rvyObjEdit.currentStatus+'StatusCaption']);if(rvyObjEdit[rvyObjEdit.currentStatus+'ActionURL']){var url=rvyObjEdit[rvyObjEdit.currentStatus+'ActionURL'];}else{var url='javascript:void(0)';}
if(rvyObjEdit[rvyObjEdit.currentStatus+'ActionCaption']){$(refSelector).after('