Skip to content

Commit

Permalink
Merge pull request #545 from publishpress/release-3.0.2
Browse files Browse the repository at this point in the history
Release 3.0.2
  • Loading branch information
agapetry authored Nov 17, 2021
2 parents eef7a7d + 83aba5f commit d359c3b
Show file tree
Hide file tree
Showing 15 changed files with 155 additions and 91 deletions.
2 changes: 1 addition & 1 deletion admin/admin-posts_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function revisions_row_action_link($actions = array()) {
}

if (!empty($status_obj->public) || !empty($status_obj->private) || rvy_get_option('pending_revision_unpublished')) {
if (current_user_can('copy_post', $post->ID)) {
if (rvy_get_option('pending_revisions') && current_user_can('copy_post', $post->ID)) {
$redirect_arg = ( ! empty($_REQUEST['rvy_redirect']) ) ? "&rvy_redirect=" . esc_url($_REQUEST['rvy_redirect']) : '';
//$url = wp_nonce_url(rvy_admin_url("admin.php?page=rvy-revisions&post={$post->ID}&action=revise$redirect_arg"), "submit-post_{$post->ID}" );
$url = rvy_admin_url("admin.php?page=rvy-revisions&post={$post->ID}&action=revise$redirect_arg");
Expand Down
16 changes: 8 additions & 8 deletions admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
'features' => array(
'role_definition' => __('Revisors', 'revisionary'),
'revision_statuses' => __('Statuses', 'revisionary'),
'working_copy' => pp_revisions_status_label('draft-revision', 'plural'),
'working_copy' => rvy_get_option('revision_statuses_noun_labels') ? pp_revisions_status_label('draft-revision', 'plural') : __('Revision Creation', 'revisionary'),
'pending_revisions' => rvy_get_option('revision_statuses_noun_labels') ? pp_revisions_status_label('pending-revision', 'plural') : __('Revision Submission', 'revisionary'),
'scheduled_revisions' => pp_revisions_status_label('future-revision', 'plural'),
'pending_revisions' => pp_revisions_status_label('pending-revision', 'plural'),
'revision_queue' => __('Queue', 'revisionary'),
'preview' => __('Preview / Approval', 'revisionary'),
'revisions' => __('Options', 'revisionary'),
Expand All @@ -109,18 +109,18 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {

// TODO: replace individual _e calls with these (and section, tab captions)
$pending_revision_singular = pp_revisions_status_label('pending-revision', 'name');
$pending_revision_plural = pp_revisions_status_label('pending-revision', 'plural');
$pending_revision_plural = rvy_get_option('revision_statuses_noun_labels') ? pp_revisions_status_label('pending-revision', 'plural') : __('Revision Submission', 'revisionary');
$pending_revision_basic = pp_revisions_status_label('pending-revision', 'basic');
$future_revision_singular = pp_revisions_status_label('future-revision', 'name');

$this->option_captions = apply_filters('revisionary_option_captions',
[
'revision_statuses_noun_labels' => __('Use alternate labeling: "Working Copy" > "Change Request" > "Scheduled Change"', 'revisionary'),
'copy_posts_capability' => sprintf(__("%s require role capability", 'revisionary'), pp_revisions_status_label('draft-revision', 'plural')),
'caption_copy_as_edit' => __("Posts / Pages admin listing: limited users get 'Edit' caption"),
'copy_posts_capability' => rvy_get_option('revision_statuses_noun_labels') ? __("Additional role capability required to create a Working Copy", 'revisionary') : __("Additional role capability required to create a new revision", 'revisionary'),
'caption_copy_as_edit' => sprintf(__('Posts / Pages list: Use "Edit" caption for %s link'), pp_revisions_status_label('draft-revision', 'submit_short')),
'pending_revisions' => sprintf(__('Enable %s', 'revisionary'), $pending_revision_plural),
'scheduled_revisions' => sprintf(__('Enable %s', 'revisionary'), pp_revisions_status_label('future-revision', 'plural')),
'revise_posts_capability' => sprintf(__("%s require role capability", 'revisionary'), $pending_revision_plural),
'revise_posts_capability' => rvy_get_option('revision_statuses_noun_labels') ? __("Additional role capability required to submit a Change Request", 'revisionary') : __("Additional role capability required to submit a revision", 'revisionary'),
'revisor_lock_others_revisions' => __("Editing others' revisions requires role capability", 'revisionary'),
'revisor_hide_others_revisions' => __("Listing others' revisions requires role capability", 'revisionary'),
'admin_revisions_to_own_posts' => __("Users can always administer revisions to their own editable posts", 'revisionary'),
Expand Down Expand Up @@ -203,7 +203,7 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
<header>
<!-- <div class='wrap'> -->
<?php
echo '<form action="" method="post">';
echo '<form action="" method="post" autocomplete="off">';
wp_nonce_field( 'rvy-update-options' );

if ( $sitewide )
Expand Down Expand Up @@ -401,7 +401,7 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
</div><br />
<?php endif;

$hint = sprintf(__('If the user does not have a regular Edit link, use the "Edit" caption for New %s operation', 'revisionary'), pp_revisions_status_label('draft-revision', 'name'));
$hint = sprintf(__('If the user does not have a regular Edit link, recaption the %s link as "Edit"', 'revisionary'), pp_revisions_status_label('draft-revision', 'submit_short'));
$this->option_checkbox( 'caption_copy_as_edit', $tab, $section, $hint, '' );

//do_action('revisionary_option_ui_working_copies', $this);
Expand Down
12 changes: 10 additions & 2 deletions admin/post-editor-workflow-ui_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ public static function revisionLinkParams($args = []) {
$vars['futureDeletionURL'] = '';
}

if (\PublishPress\Revisions\Utils::isBlockEditorActive()) {
$vars['updateCaption'] = __('Update Revision', 'revisionary');
} else {
if (!$vars['updateCaption'] = pp_revisions_status_label($post->post_mime_type, 'update')) {
$vars['updateCaption'] = pp_revisions_label('update_revision');
}
}

return $vars;
}

Expand Down Expand Up @@ -156,7 +164,7 @@ public static function postLinkParams($args = []) {
$redirect_arg = ( ! empty($_REQUEST['rvy_redirect']) ) ? "&rvy_redirect=" . esc_url($_REQUEST['rvy_redirect']) : '';
$published_post_id = rvy_post_id($post->ID);

if (current_user_can('copy_post', $post->ID)) {
if (rvy_get_option('pending_revisions') && current_user_can('copy_post', $post->ID)) {
$vars = array_merge($vars, array(
'actionCaption' => pp_revisions_status_label('draft-revision', 'submit'),
'actionTitle' => esc_attr(sprintf(__('Create a %s of this post', 'revisionary'), strtolower(pp_revisions_status_label('draft-revision', 'basic')))),
Expand All @@ -174,7 +182,7 @@ public static function postLinkParams($args = []) {
$vars['actionCaption'] = '';
}

if (current_user_can($type_obj->cap->publish_posts)) {
if (rvy_get_option('scheduled_revisions') && current_user_can($type_obj->cap->publish_posts)) {
$published_statuses = array_merge(get_post_stati(['public' => true]), get_post_stati(['private' => true]));

$vars = array_merge($vars, array(
Expand Down
7 changes: 6 additions & 1 deletion admin/revision-action_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@ function rvy_apply_revision( $revision_id, $actual_revision_status = '' ) {
$update_fields['post_date_gmt'] = $update['post_date_gmt'];
}

// Safeguard: prevent invalid hierarchy and broken Pages admin
if (!empty($update_fields['post_parent']) && ($post_id == $update_fields['post_parent'])) {
$update_fields['post_parent'] = 0;
}

$wpdb->update($wpdb->posts, $update_fields, ['ID' => $post_id]);

// also copy all stored postmeta from revision
Expand Down Expand Up @@ -938,7 +943,7 @@ function rvy_revision_bulk_delete() {

// before deleting the revision, note its status for redirect
$revision_status = $revision->post_mime_type;
wp_delete_post( $revision_id );
wp_delete_post($revision_id, true);
$delete_count++;

rvy_delete_past_revisions($revision_id);
Expand Down
4 changes: 4 additions & 0 deletions admin/rvy_post-classic-edit.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ jQuery(document).ready( function($) {
RvyRefreshScheduleButton();
});

var $timestampdiv = $('#timestampdiv');
$timestampdiv.find('.save-timestamp').on( 'click', function( event ) {
RvyRefreshScheduleButton();
});

/**
* If date is set to future, change Publish button caption to "Schedule Revision",
Expand Down
2 changes: 1 addition & 1 deletion admin/rvy_post-classic-edit.js

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

55 changes: 32 additions & 23 deletions admin/rvy_revision-block-edit.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jQuery(document).ready( function($) {

// Update main publish ("Publish" / "Submit Pending") button width and span caption
function RvySetPublishButtonCaption(caption,waitForSaveDraftButton,forceRegen,timeout) {
if ('future' == rvyObjEdit.currentStatus) {
caption = rvyObjEdit.updateCaption;
}

if ( caption == '' && ( typeof rvyObjEdit['publishCaptionCurrent'] != 'undefined' ) ) {
caption = rvyObjEdit.publishCaptionCurrent;
} else {
Expand Down Expand Up @@ -118,8 +122,13 @@ jQuery(document).ready( function($) {
$('#icl_div').closest('div.edit-post-meta-boxes-area').hide();
}

if ('future' == rvyObjEdit.currentStatus) {
$('button.editor-post-publish-button').show();

} else {
if ( $('button.editor-post-publish-button').length ) {
$('button.editor-post-publish-button').hide();
}
}
}
var RvyHideInterval = setInterval(RvyHideElements, 50);
Expand Down Expand Up @@ -287,32 +296,32 @@ jQuery(document).ready( function($) {
});

function rvySubmitCopy() {
var revisionaryCreateDone = function () {
$('.revision-approve').hide();
var revisionaryCreateDone = function () {
$('.revision-approve').hide();
$('div.revision-submitting').hide();
$('.revision-created').show();
$('.revision-created').show();

// @todo: abstract this for other workflows
rvyObjEdit.currentStatus = 'pending';
// @todo: abstract this for other workflows
rvyObjEdit.currentStatus = 'pending';

$('.rvy-current-status').html(rvyObjEdit[rvyObjEdit.currentStatus + 'StatusCaption']);
$('a.revision-edit').attr('href', rvyObjEdit[rvyObjEdit.currentStatus + 'CompletedURL']).show();
}
$('.rvy-current-status').html(rvyObjEdit[rvyObjEdit.currentStatus + 'StatusCaption']);
$('a.revision-edit').attr('href', rvyObjEdit[rvyObjEdit.currentStatus + 'CompletedURL']).show();
}

var revisionaryCreateError = function (data, txtStatus) {
$('div.rvy-creation-ui').html(rvyObjEdit[rvyObjEdit.currentStatus + 'ErrorCaption']);
}
var revisionaryCreateError = function (data, txtStatus) {
$('div.rvy-creation-ui').html(rvyObjEdit[rvyObjEdit.currentStatus + 'ErrorCaption']);
}

var data = {'rvy_ajax_field': rvyObjEdit[rvyObjEdit.currentStatus + 'AjaxField'], 'rvy_ajax_value': wp.data.select('core/editor').getCurrentPostId(), 'nc': RvyGetRandomInt(99999999)};
var data = {'rvy_ajax_field': rvyObjEdit[rvyObjEdit.currentStatus + 'AjaxField'], 'rvy_ajax_value': wp.data.select('core/editor').getCurrentPostId(), 'nc': RvyGetRandomInt(99999999)};

$.ajax({
url: rvyObjEdit.ajaxurl,
data: data,
dataType: "html",
success: revisionaryCreateDone,
error: revisionaryCreateError
});
}
$.ajax({
url: rvyObjEdit.ajaxurl,
data: data,
dataType: "html",
success: revisionaryCreateDone,
error: revisionaryCreateError
});
}

var RvyRecaptionSaveDraft = function() {
if ($('button.editor-post-save-draft:not(.rvy-recaption)').length) {
Expand All @@ -338,13 +347,13 @@ jQuery(document).ready( function($) {
if (rvyObjEdit.viewCaption) {
RvyRecaptionElement('.block-editor-post-preview__button-toggle', rvyObjEdit.viewCaption);
$('button.block-editor-post-preview__button-toggle:not(.ppr-purple-button)').removeClass('is-tertiary').addClass('is-secondary').addClass('ppr-purple-button');
}
}
}

if (rvyObjEdit.viewTitle) {
$('div.edit-post-header__settings a.rvy-post-preview').attr('title', rvyObjEdit.viewTitle);
}

} else {
if (!rvyObjEdit.multiPreviewActive) { // WP < 5.5
if (!$('a.editor-post-preview').next('a.rvy-post-preview').length) {
Expand All @@ -354,7 +363,7 @@ jQuery(document).ready( function($) {
if (rvyObjEdit.viewCaption) {
RvyRecaptionElement('div.edit-post-header__settings a.rvy-post-preview', rvyObjEdit.viewCaption);
}

if (rvyObjEdit.viewTitle) {
$('div.edit-post-header__settings a.rvy-post-preview').attr('title', rvyObjEdit.viewTitle);
}
Expand Down
13 changes: 10 additions & 3 deletions admin/rvy_revision-classic-edit.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ jQuery(document).ready( function($) {
var RvySubmissionUI = function() {
var refSelector = '#rvy_compare_button';

if (!$(refSelector).length) {
var refSelector = 'div.misc-pub-section-last';
}

if (rvyObjEdit.ajaxurl && !$('div.rvy-creation-ui').length && $(refSelector).length) {
$('#post-status-display').html(rvyObjEdit[rvyObjEdit.currentStatus + 'StatusCaption']);

Expand All @@ -35,13 +39,16 @@ jQuery(document).ready( function($) {

+ '</div> <br /><br />'
);
}

}
$('.edit-post-post-schedule__toggle').after('<button class="components-button is-tertiary post-schedule-footnote" disabled>' + rvyObjEdit.onApprovalCaption + '</button>');

if (rvyObjEdit[rvyObjEdit.currentStatus + 'DeletionURL']) {
$('a.submitdelete').attr('href', rvyObjEdit[rvyObjEdit.currentStatus + 'DeletionURL']);
}
}

$('#publish').hide();
$('#save-post').val(rvyObjEdit.updateCaption);
}
}
var RvyUIInterval = setInterval(RvySubmissionUI, 100);
Expand Down
6 changes: 4 additions & 2 deletions admin/rvy_revision-classic-edit.js

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

2 changes: 2 additions & 0 deletions front_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ function act_template_redirect() {
$class = 'draft';
$status_obj = get_post_status_object(get_post_field('post_status', rvy_post_id($revision_id)));

$approve_caption = __( 'Approve', 'revisionary' );

if (!empty($submit_url) && current_user_can("set_revision_pending-revision", $revision_id)) {
$submit_caption = __( 'Submit', 'revisionary' );
$publish_button = '<span><a href="' . $submit_url . '" class="rvy_preview_linkspan rvy-submit-revision">' . $submit_caption . '</a></span>';
Expand Down
Loading

0 comments on commit d359c3b

Please sign in to comment.