Skip to content

Commit

Permalink
Merge pull request #519 from publishpress/release-3.0.1
Browse files Browse the repository at this point in the history
Release 3.0.1
  • Loading branch information
agapetry authored Nov 10, 2021
2 parents e7f761e + d821ea1 commit b98f1d0
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 11 deletions.
4 changes: 4 additions & 0 deletions admin/post-editor-workflow-ui_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -165,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 {
Expand All @@ -182,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'),
));
}

Expand Down
3 changes: 2 additions & 1 deletion admin/rvy_post-classic-edit.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down Expand Up @@ -207,6 +207,7 @@ jQuery(document).ready( function($) {
}
}

$('#publish').val(rvyObjEdit.update);
$('#publish').show();
}
}
Expand Down
4 changes: 2 additions & 2 deletions admin/rvy_post-classic-edit.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion admin/rvy_revision-block-edit.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
*/
jQuery(document).ready( function($) {
function RvyRecaptionElement(btnSelector, btnCaption, btnIcon = '') {
if (rvyObjEdit.disableRecaption) {
return;
}

let node = document.querySelector(btnSelector);

if (node) {
Expand Down Expand Up @@ -313,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) {
Expand Down
3 changes: 2 additions & 1 deletion admin/rvy_revision-block-edit.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,25 @@ 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');
}

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')) {
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Tags: revision, submit changes, workflow, collaboration, schedule revisions
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

Expand Down Expand Up @@ -118,6 +118,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
Expand Down
4 changes: 4 additions & 0 deletions revision-creation_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions revisionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.' );
Expand Down
68 changes: 67 additions & 1 deletion revisionary_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,83 @@ 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);

if (!is_admin()) {
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 = "<select name='" . esc_attr( $parsed_args['name'] ) . "'" . $class . " id='" . esc_attr( $parsed_args['id'] ) . "'>\n";
if ( $parsed_args['show_option_no_change'] ) {
$output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n";
}
if ( $parsed_args['show_option_none'] ) {
$output .= "\t<option value=\"" . esc_attr( $parsed_args['option_none_value'] ) . '">' . $parsed_args['show_option_none'] . "</option>\n";
}
$output .= walk_page_dropdown_tree( $pages, $parsed_args['depth'], $parsed_args );
$output .= "</select>\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;

Expand Down

0 comments on commit b98f1d0

Please sign in to comment.