From c6e5e1f05281d36d375b31d288a48971f00f8387 Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:13:09 -0500 Subject: [PATCH 01/10] Gutenberg plugin: generic error screen when submitting revision in 3.0 Fixes #508 --- admin/post-editor-workflow-ui_rvy.php | 2 ++ admin/rvy_revision-block-edit.dev.js | 4 ++++ admin/rvy_revision-block-edit.js | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/admin/post-editor-workflow-ui_rvy.php b/admin/post-editor-workflow-ui_rvy.php index 9ae704b1..f1d638e9 100644 --- a/admin/post-editor-workflow-ui_rvy.php +++ b/admin/post-editor-workflow-ui_rvy.php @@ -28,6 +28,8 @@ public static function revisionLinkParams($args = []) { 'onApprovalCaption' => __('(on approval)', 'revisionary'), ]; + $vars['disableRecaption'] = is_plugin_active('gutenberg/gutenberg.php'); + if (rvy_get_option('revision_preview_links') || current_user_can('administrator') || is_super_admin()) { $vars['viewURL'] = rvy_preview_url($post); $can_publish = current_user_can('edit_post', rvy_post_id($post->ID)); diff --git a/admin/rvy_revision-block-edit.dev.js b/admin/rvy_revision-block-edit.dev.js index 47e444b6..f8a94b3b 100644 --- a/admin/rvy_revision-block-edit.dev.js +++ b/admin/rvy_revision-block-edit.dev.js @@ -7,6 +7,10 @@ */ jQuery(document).ready( function($) { function RvyRecaptionElement(btnSelector, btnCaption, btnIcon = '') { + if (rvyObjEdit.disableRecaption) { + return; + } + let node = document.querySelector(btnSelector); if (node) { diff --git a/admin/rvy_revision-block-edit.js b/admin/rvy_revision-block-edit.js index f3f888e1..9cd7db8a 100644 --- a/admin/rvy_revision-block-edit.js +++ b/admin/rvy_revision-block-edit.js @@ -1,4 +1,5 @@ -jQuery(document).ready(function($){function RvyRecaptionElement(btnSelector,btnCaption,btnIcon=''){let node=document.querySelector(btnSelector);if(node){document.querySelector(btnSelector).innerText=`${btnCaption}`;if(btnIcon){document.querySelector(btnSelector).innerHTML=`${btnCaption}`;}}} +jQuery(document).ready(function($){function RvyRecaptionElement(btnSelector,btnCaption,btnIcon=''){if(rvyObjEdit.disableRecaption){return;} +let node=document.querySelector(btnSelector);if(node){document.querySelector(btnSelector).innerText=`${btnCaption}`;if(btnIcon){document.querySelector(btnSelector).innerHTML=`${btnCaption}`;}}} function RvySetPublishButtonCaption(caption,waitForSaveDraftButton,forceRegen,timeout){if(caption==''&&(typeof rvyObjEdit['publishCaptionCurrent']!='undefined')){caption=rvyObjEdit.publishCaptionCurrent;}else{rvyObjEdit.publishCaptionCurrent=caption;} if(typeof waitForSaveDraftButton=='undefined'){waitForSaveDraftButton=false;} if((!waitForSaveDraftButton||$('button.editor-post-switch-to-draft').filter(':visible').length||$('button.editor-post-save-draft').filter(':visible').length)&&$('button.editor-post-publish-button').length){RvyRecaptionElement('button.editor-post-publish-button',caption);}} From f34584fda8ffcfebe09a49a50f3bb1270fd58c39 Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:15:40 -0500 Subject: [PATCH 02/10] Classic Editor : Schedule Revisions cannot be submitted Fixes #511 --- admin/rvy_post-classic-edit.dev.js | 2 +- admin/rvy_post-classic-edit.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/rvy_post-classic-edit.dev.js b/admin/rvy_post-classic-edit.dev.js index 4f29a6df..d981a8af 100644 --- a/admin/rvy_post-classic-edit.dev.js +++ b/admin/rvy_post-classic-edit.dev.js @@ -101,7 +101,7 @@ jQuery(document).ready( function($) { }); } - $(document).on('click', 'div.postbox-container', function() { + $(document).on('click', '#normal-sortables input, #normal-sortables select', function() { $('a.revision-create').attr('disabled', 'disabled'); $('a.revision-schedule').attr('disabled', 'disabled'); }); diff --git a/admin/rvy_post-classic-edit.js b/admin/rvy_post-classic-edit.js index 6b222f98..1f7a92df 100644 --- a/admin/rvy_post-classic-edit.js +++ b/admin/rvy_post-classic-edit.js @@ -17,7 +17,7 @@ $(document).on('click','a.revision-create',function(){if($('a.revision-create'). $('a.revision-create').attr('disabled','disabled');if(wp.autosave&&wp.autosave.server.postChanged()){var tmoRevisionSubmit=setTimeout(rvyCopyPost,5000);var intRevisionSubmit=setInterval(function(){if(!wp.autosave.server.postChanged()){clearTimeout(tmoRevisionSubmit);clearInterval(intRevisionSubmit);rvyCopyPost();}},250);wp.autosave.server.triggerSave();}else{rvyCopyPost();}});function rvyCopyPost(){var revisionaryCreateDone=function(){$('.revision-create').hide();$('.revision-created-wrapper').show();$('div.revision-created-wrapper a.revision-edit').attr('href',rvyObjEdit.completedURL);$('a.revision-create').removeAttr('disabled');} var revisionaryCreateError=function(data,txtStatus){$('div.rvy-creation-ui').html(rvyObjEdit.errorCaption);} var data={'rvy_ajax_field':'create_revision','rvy_ajax_value':rvyObjEdit.postID,'rvy_date_selection':RvyTimeSelection,'nc':RvyGetRandomInt(99999999)};$.ajax({url:rvyObjEdit.ajaxurl,data:data,dataType:"html",success:revisionaryCreateDone,error:revisionaryCreateError});} -$(document).on('click','div.postbox-container',function(){$('a.revision-create').attr('disabled','disabled');$('a.revision-schedule').attr('disabled','disabled');});$(document).on('click','a.revision-schedule',function(){if($('a.revision-schedule').attr('disabled')){return;} +$(document).on('click','#normal-sortables input, #normal-sortables select',function(){$('a.revision-create').attr('disabled','disabled');$('a.revision-schedule').attr('disabled','disabled');});$(document).on('click','a.revision-schedule',function(){if($('a.revision-schedule').attr('disabled')){return;} $('a.revision-schedule').attr('disabled','disabled');if(wp.autosave.server.postChanged()){wp.autosave.server.triggerSave();var approvalDelay=250;}else{var approvalDelay=1;} var revisionaryScheduleDone=function(){$('.revision-schedule').hide();$('.revision-scheduled-wrapper').show();$('div.revision-scheduled-wrapper a.revision-edit').attr('href',rvyObjEdit.scheduledURL);$('a.revision-schedule').removeAttr('disabled');} var revisionaryScheduleError=function(data,txtStatus){$('div.rvy-creation-ui').html(rvyObjEdit.errorCaption);} From d170e21beea0cb032b198e362a513d35c2199a98 Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:18:27 -0500 Subject: [PATCH 03/10] Classic Editor: Schedule button displayed incorrectly when date futuricity toggled Classic Editor: Schedule button displayed incorrectly when date is set future, then back to past Fixes #512 --- admin/post-editor-workflow-ui_rvy.php | 2 ++ admin/rvy_post-classic-edit.dev.js | 1 + admin/rvy_post-classic-edit.js | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/admin/post-editor-workflow-ui_rvy.php b/admin/post-editor-workflow-ui_rvy.php index f1d638e9..2177a0e1 100644 --- a/admin/post-editor-workflow-ui_rvy.php +++ b/admin/post-editor-workflow-ui_rvy.php @@ -167,6 +167,7 @@ public static function postLinkParams($args = []) { 'completedURL' => rvy_nc_url( add_query_arg('get_new_revision', $post->ID, get_permalink($post->ID))), 'errorCaption' => __('Error Creating Revision', 'revisionary'), 'ajaxurl' => rvy_admin_url(''), + 'update' => __('Update', 'revisionary'), 'postID' => $post->ID )); } else { @@ -184,6 +185,7 @@ public static function postLinkParams($args = []) { 'scheduledCaption' => pp_revisions_status_label('future-revision', 'submitted'), 'scheduledLinkCaption' => __('Preview', 'revisionary'), 'scheduledURL' => rvy_nc_url( add_query_arg('get_new_revision', $post->ID, get_permalink($post->ID))), + 'update' => __('Update', 'revisionary'), )); } diff --git a/admin/rvy_post-classic-edit.dev.js b/admin/rvy_post-classic-edit.dev.js index d981a8af..ad556971 100644 --- a/admin/rvy_post-classic-edit.dev.js +++ b/admin/rvy_post-classic-edit.dev.js @@ -207,6 +207,7 @@ jQuery(document).ready( function($) { } } + $('#publish').val(rvyObjEdit.update); $('#publish').show(); } } diff --git a/admin/rvy_post-classic-edit.js b/admin/rvy_post-classic-edit.js index 1f7a92df..ca4d4347 100644 --- a/admin/rvy_post-classic-edit.js +++ b/admin/rvy_post-classic-edit.js @@ -23,5 +23,5 @@ var revisionaryScheduleDone=function(){$('.revision-schedule').hide();$('.revisi var revisionaryScheduleError=function(data,txtStatus){$('div.rvy-creation-ui').html(rvyObjEdit.errorCaption);} var tmoSubmit=setInterval(function(){if(!wp.autosave.server.postChanged()){var data={'rvy_ajax_field':'create_scheduled_revision','rvy_ajax_value':rvyObjEdit.postID,'rvy_date_selection':RvyTimeSelection,'nc':RvyGetRandomInt(99999999)};$.ajax({url:rvyObjEdit.ajaxurl,data:data,dataType:"html",success:revisionaryScheduleDone,error:revisionaryScheduleError});clearInterval(tmoSubmit);}},approvalDelay);});$(document).on('click','#post-body-content *, #content_ifr *, #wp-content-editor-container *, #tinymce *, #submitpost, span.revision-created',function(){RvyRefreshScheduleButton();});var RvySelectedFutureDate=false;var RvyTimeSelection='';var RvyRefreshScheduleButton=function(){var selectedDateHTML=$('#timestamp').html();if(!/\d/.test(selectedDateHTML)||!rvyIsPublished){RvyTimeSelection='';$('.rvy-creation-ui .revision-schedule').hide();$('.rvy-creation-ui .revision-scheduled-wrapper').hide();$('.rvy-creation-ui .revision-created-wrapper').hide();$('.rvy-creation-ui .revision-create').show();return;} var dateStr=$('#mm').val()+'/'+$('#jj').val()+'/'+$('#aa').val()+' '+$('#hh').val()+':'+$('#mn').val()+':00';var selectedDate=new Date(dateStr);RvyTimeSelection=selectedDate.getTime();var tdiff=RvyTimeSelection-Date.now();RvyTimeSelection=RvyTimeSelection/1000;if((tdiff>1000)){RvySelectedFutureDate=true;$('.rvy-creation-ui .revision-create').hide();$('.rvy-creation-ui .revision-created-wrapper').hide();$('.rvy-creation-ui .revision-scheduled-wrapper').hide();$('.rvy-creation-ui .revision-schedule').show();$('#publish').hide();}else{$('.rvy-creation-ui .revision-schedule').hide();$('.rvy-creation-ui .revision-scheduled-wrapper').hide();$('.rvy-creation-ui .revision-created-wrapper').hide();$('.rvy-creation-ui .revision-create').show();if(tdiff<=0){if(RvySelectedFutureDate){RvyTimeSelection='';}} -$('#publish').show();}} +$('#publish').val(rvyObjEdit.update);$('#publish').show();}} $(document).on('click','a.save-timestamp, a.cancel-timestamp',function(){RvyRefreshScheduleButton();});}); \ No newline at end of file From 3630f8d3e03b784f5cd2dcd1a3d704004676170a Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:21:28 -0500 Subject: [PATCH 04/10] Edit Revision: Primary styling for Update button This change was already present in the minified code (therefore for most users). --- admin/rvy_revision-block-edit.dev.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/rvy_revision-block-edit.dev.js b/admin/rvy_revision-block-edit.dev.js index f8a94b3b..5f39516f 100644 --- a/admin/rvy_revision-block-edit.dev.js +++ b/admin/rvy_revision-block-edit.dev.js @@ -317,7 +317,8 @@ jQuery(document).ready( function($) { var RvyRecaptionSaveDraft = function() { if ($('button.editor-post-save-draft:not(.rvy-recaption)').length) { RvyRecaptionElement('button.editor-post-save-draft:not(.rvy-recaption)', rvyObjEdit.saveRevision); - $('button.editor-post-save-draft:not(.rvy-recaption)').addClass('rvy-recaption').removeClass('is-tertiary').addClass('is-secondary').addClass('ppr-purple-button'); + + $('button.editor-post-save-draft:not(.rvy-recaption)').addClass('rvy-recaption').removeClass('is-tertiary').addClass('is-primary').addClass('ppr-purple-button'); } if (($('div.edit-post-header__settings a.editor-post-preview:visible').length || $('div.block-editor-post-preview__dropdown button.block-editor-post-preview__button-toggle:visible').length) && !$('a.rvy-post-preview').length) { From 8aff0c344cc7e1fb7a709175aae6e0fad4d75dcf Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:25:16 -0500 Subject: [PATCH 05/10] Version 2.x revisions were not migrated until plugin re-activation Fixes #509 --- functions.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 8f02d240..8225952e 100644 --- a/functions.php +++ b/functions.php @@ -244,7 +244,16 @@ function rvy_admin_url($partial_admin_url) { function pp_revisions_plugin_updated($current_version) { $last_ver = get_option('revisionary_last_version'); - if (version_compare($last_ver, '3.0-rc7', '<')) { + if (version_compare($last_ver, '3.0.1', '<')) { + // convert pending / scheduled revisions to v3.0 format + global $wpdb; + $revision_status_csv = rvy_revision_statuses(['return' => 'csv']); + $wpdb->query("UPDATE $wpdb->posts SET post_mime_type = post_status WHERE post_status IN ($revision_status_csv)"); + $wpdb->query("UPDATE $wpdb->posts SET post_status = 'draft' WHERE post_status IN ('draft-revision')"); + $wpdb->query("UPDATE $wpdb->posts SET post_status = 'pending' WHERE post_status IN ('pending-revision')"); + $wpdb->query("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status IN ('future-revision')"); + + } elseif (version_compare($last_ver, '3.0-rc7', '<')) { if ($role = @get_role('administrator')) { $role->add_cap('manage_unsubmitted_revisions'); } @@ -252,8 +261,8 @@ function pp_revisions_plugin_updated($current_version) { if ($role = @get_role('revisor')) { $role->add_cap('upload_files'); } - } + /* elseif (version_compare($last_ver, '2.4.3-beta4', '<')) { // Empty Queue condition was reported with Elementor, so default this setting if (defined('ELEMENTOR_VERSION') || defined('ELEMENTOR_PRO_VERSION')) { From 018dd4e67193488753c28c70bb543af8bc0d6520 Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:29:40 -0500 Subject: [PATCH 06/10] Front Page setting dropdown in Settings > Reading included revisions Fixes #510 --- revisionary_main.php | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/revisionary_main.php b/revisionary_main.php index 1442c613..92b294d1 100644 --- a/revisionary_main.php +++ b/revisionary_main.php @@ -131,9 +131,72 @@ function addFilters() { add_action('admin_bar_menu', [$this, 'adminToolbarItem'], 100); } + add_filter('wp_dropdown_pages', [$this, 'fltDropdownPages'], 10, 3); + do_action( 'rvy_init', $this ); } + // Work around unfilterable get_pages() query by replacing the wp_dropdown_pages() return array + function fltDropdownPages($output, $parsed_args, $pages) { + // ---- Begin PublishPress Modification --- + global $wpdb; + + // don't recursively execute this filter + remove_filter('wp_dropdown_pages', [$this, 'fltDropdownPages'], 10, 3); + + $parse_args['echo'] = 0; + + $revision_status_csv = rvy_revision_statuses(['return' => 'csv']); + $parsed_args['exclude'] = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_mime_type IN ($revision_status_csv)"); + // ---- End PublishPress Modification --- + + $pages = get_pages( $parsed_args ); + $output = ''; + // Back-compat with old system where both id and name were based on $name argument. + if ( empty( $parsed_args['id'] ) ) { + $parsed_args['id'] = $parsed_args['name']; + } + + if ( ! empty( $pages ) ) { + $class = ''; + if ( ! empty( $parsed_args['class'] ) ) { + $class = " class='" . esc_attr( $parsed_args['class'] ) . "'"; + } + + $output = "\n"; + } + + /** + * Filters the HTML output of a list of pages as a drop down. + * + * @since 2.1.0 + * @since 4.4.0 `$parsed_args` and `$pages` added as arguments. + * + * @param string $output HTML output for drop down list of pages. + * @param array $parsed_args The parsed arguments array. See wp_dropdown_pages() + * for information on accepted arguments. + * @param WP_Post[] $pages Array of the page objects. + */ + $html = apply_filters( 'wp_dropdown_pages', $output, $parsed_args, $pages ); + + if ( $parsed_args['echo'] ) { + echo $html; + } + + // PublishPress: restore this filter hook + add_filter('wp_dropdown_pages', [$this, 'fltDropdownPages'], 10, 3); + + return $html; + } + function adminToolbarItem($admin_bar) { global $post; From ab9351863750e1093c955080cc51d9593c699dc5 Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:34:37 -0500 Subject: [PATCH 07/10] Revision submission clears WordPress homepage setting Fixes #493 --- revisionary_main.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/revisionary_main.php b/revisionary_main.php index 92b294d1..745b2bc1 100644 --- a/revisionary_main.php +++ b/revisionary_main.php @@ -123,7 +123,10 @@ function addFilters() { add_action('post_updated', [$this, 'actUpdateRevision'], 10, 2); add_action('post_updated', [$this, 'actUpdateRevisionFixCommentCount'], 999, 2); - add_filter("option_page_on_front", [$this, 'fltOptionPageOnFront']); + // This filter may be required in some configurations, but problematic in others + if (defined('PP_REVISIONS_PAGE_ON_FRONT_FILTER')) { + add_filter("option_page_on_front", [$this, 'fltOptionPageOnFront']); + } add_filter('posts_clauses', [$this, 'fltPostsClauses'], 10, 2); From 1eaafd666abb622d6478b28a087dff45b8ef7a4b Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:36:27 -0500 Subject: [PATCH 08/10] createRevision(): support 'suppress_redirect' argument --- revision-creation_rvy.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/revision-creation_rvy.php b/revision-creation_rvy.php index 92ac6ac4..4d2b8f55 100644 --- a/revision-creation_rvy.php +++ b/revision-creation_rvy.php @@ -114,6 +114,10 @@ function createRevision($post_id, $revision_status, $args = []) { $url = apply_filters('revisionary_create_revision_redirect', rvy_admin_url("post.php?post=$revision_id&action=edit"), $revision_id); + if (!empty($args['suppress_redirect'])) { + return $url; + } + wp_redirect($url); exit; } From 802fe34849563178aecec81b1d433f84b62ed292 Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:36:52 -0500 Subject: [PATCH 09/10] Update change log --- readme.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/readme.txt b/readme.txt index 15aba17e..6d734c2b 100644 --- a/readme.txt +++ b/readme.txt @@ -104,6 +104,15 @@ Follow PublishPress on [Facebook](https://www.facebook.com/publishpress), [Twitt == Changelog == += 3.0.1 - 10 Nov 2021 = +* Fixed : Revisions created using Revisions 2.x were not listed in Revision Queue until plugin de/re-activation +* Fixed : Front Page setting was cleared at revision submission on some sites +* Fixed : Front Page setting dropdown in Settings > Reading included revisions +* Fixed : Classic Editor : Schedule Revisions could not be submitted +* Fixed : Classic Editor : Schedule button was displayed incorrectly while selecting a future date for scheduled revision +* Compat : Gutenberg plugin - Edit Revision screen crashed on update attempt +* API: Allow redirect to be disabled on revision creation + = 3.0 - 9 Nov 2021 = * Feature: New revision submission mechanism: create an unsubmitted revision first instead of editing existing post. Edit revision directly, then submit for scheduling or publication. * Change: Revisions UI in Post / Revision editor From d821ea10e9ec542bf9067494a0c4bdafa9f14c23 Mon Sep 17 00:00:00 2001 From: Kevin Behrens <43488774+agapetry@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:37:30 -0500 Subject: [PATCH 10/10] Release 3.0.1 --- readme.txt | 2 +- revisionary.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index 6d734c2b..75f71540 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Tags: revision, submit changes, workflow, collaboration, permissions, moderate, Requires at least: 4.9.7 Requires PHP: 5.6.20 Tested up to: 5.8 -Stable tag: 3.0 +Stable tag: 3.0.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/revisionary.php b/revisionary.php index 78a6bb80..a5d532b6 100644 --- a/revisionary.php +++ b/revisionary.php @@ -5,7 +5,7 @@ * Description: Maintain published content with teamwork and precision using the Revisions model to submit, approve and schedule changes. * Author: PublishPress * Author URI: https://publishpress.com - * Version: 3.0 + * Version: 3.0.1 * Text Domain: revisionary * Domain Path: /languages/ * Min WP Version: 4.9.7 @@ -36,7 +36,7 @@ // Temporary usage within this module only; avoids multiple instances of version string global $pp_revisions_version; -$pp_revisions_version = '3.0'; +$pp_revisions_version = '3.0.1'; if( basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME']) ) die( 'This page cannot be called directly.' );