Skip to content

Commit

Permalink
Merge pull request #1174 from publishpress/release-3.5.7
Browse files Browse the repository at this point in the history
Release 3.5.7
  • Loading branch information
agapetry authored Apr 4, 2024
2 parents 72c368e + 2468a76 commit 18060a2
Show file tree
Hide file tree
Showing 24 changed files with 947 additions and 611 deletions.
13 changes: 10 additions & 3 deletions admin/admin-init_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,17 @@ function rvy_admin_init() {
exit;
}

} elseif (isset($_REQUEST['action2']) && !empty($_REQUEST['page']) && ('revisionary-q' == $_REQUEST['page']) && !empty($_REQUEST['post'])) {
} elseif (
(isset($_REQUEST['action2']) && !empty($_REQUEST['page']) && ('revisionary-q' == $_REQUEST['page']) && !empty($_REQUEST['post']))
|| (isset($_REQUEST['action']) && in_array($_REQUEST['action'], ['decline_revision']))
) {
$doaction = (!empty($_REQUEST['action']) && !is_numeric($_REQUEST['action'])) ? sanitize_key($_REQUEST['action']) : sanitize_key($_REQUEST['action2']);

check_admin_referer('bulk-revision-queue');
if (isset($_REQUEST['action']) && in_array($_REQUEST['action'], ['decline_revision'])) {
check_admin_referer('decline-revision');
} else {
check_admin_referer('bulk-revision-queue');
}

if (!$url = str_replace('#038;', '&', wp_get_referer())) {
$url = admin_url("admin.php?page=revisionary-q");
Expand All @@ -160,7 +167,7 @@ function rvy_admin_init() {
} elseif ( isset( $_REQUEST['ids'] ) ) {
$post_ids = array_map('intval', explode( ',', sanitize_text_field($_REQUEST['ids']) ));
} elseif ( !empty( $_REQUEST['post'] ) ) {
$post_ids = array_map('intval', $_REQUEST['post']);
$post_ids = array_map('intval', (array) $_REQUEST['post']);
}

if ( !isset( $post_ids ) ) {
Expand Down
7 changes: 6 additions & 1 deletion admin/admin_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @package PublishPress\Revisions\RevisionaryAdmin
* @author PublishPress <[email protected]>
* @copyright Copyright (c) 2023 PublishPress. All rights reserved.
* @copyright Copyright (c) 2024 PublishPress. All rights reserved.
* @license GPLv2 or later
* @since 1.0.0
*
Expand Down Expand Up @@ -344,6 +344,11 @@ function flt_plugin_action_links($links, $file) {

public function fltPublishPressCapsSection($section_caps) {
$section_caps['PublishPress Revisions'] = ['edit_others_drafts', 'edit_others_revisions', 'list_others_revisions', 'manage_unsubmitted_revisions'];

if (defined('PUBLISHPRESS_REVISIONS_PRO_VERSION') && rvy_get_option('revision_restore_require_cap')) {
$section_caps['PublishPress Revisions'] []= 'restore_revisions';
}

return $section_caps;
}

Expand Down
8 changes: 8 additions & 0 deletions admin/class-list-table_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,14 @@ protected function handle_row_actions( $post, $column_name, $primary ) {
);
}

if ($can_edit_post && ('pending-revision' == $post->post_mime_type)) {
$actions['decline'] = sprintf(
'<a href="%1$s" class="" target="_revision_diff">%2$s</a>',
wp_nonce_url(admin_url("post.php?post=$post->ID&action=decline_revision"), 'decline-revision'),
_x( 'Decline', 'revisions', 'revisionary' )
);
}

$actions = apply_filters('revisionary_queue_row_actions', $actions, $post);

return $this->row_actions( $actions );
Expand Down
2 changes: 1 addition & 1 deletion admin/edit-revision-classic-ui_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function hide_admin_divs() {

$object_type = (!empty($post->post_type)) ? $post->post_type : awp_post_type_from_uri();

$unrevisable_css_ids = apply_filters('rvy_hidden_meta_boxes', ['authordiv', 'visibility', 'postcustom', 'pagecustom']);
$unrevisable_css_ids = apply_filters('rvy_hidden_meta_boxes', ['authordiv', 'visibility']);

if (rvy_in_revision_workflow($post)) {
$unrevisable_css_ids = array_merge($unrevisable_css_ids, ['publish', 'slugdiv', 'edit-slug-box']);
Expand Down
29 changes: 21 additions & 8 deletions admin/edit-revision-ui_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,28 @@ function add_js() {
if (!class_exists('DS_Public_Post_Preview')) {
?>
<style>
div.edit-post-post-visibility, div.edit-post-post-status div {
display: none;
}
<?php
global $wp_version;

div.edit-post-post-status div.rvy-creation-ui,
div.edit-post-post-status div.rvy-creation-ui div
{
display: inline;
}
if (!empty($wp_version) && version_compare($wp_version, '6.5-beta', '>=')) :?>
div.edit-post-post-status div.rvy-current-status {
padding-left: 20px;
}

button.edit-post-post-visibility__toggle, div.editor-post-url__panel-dropdown, div.components-checkbox-control {
display: none;
}
<?php else:?>
div.edit-post-post-visibility, div.edit-post-post-status div {
display: none;
}

div.edit-post-post-status div.rvy-creation-ui,
div.edit-post-post-status div.rvy-creation-ui div
{
display: inline;
}
<?php endif;?>

div.edit-post-post-status div.rvy-creation-ui div.revision-created {
display: block;
Expand Down
8 changes: 5 additions & 3 deletions admin/history_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@ function actCompareRevisionsTweakUI() {
// Hide Restore button if user does not have permission
if ($_post = get_post($revision_id)) {
if (!rvy_in_revision_workflow($_post)) {
if ($parent_post = get_post($_post->post_parent)) {
if (!$revisionary->canEditPost($parent_post)) :
$parent_post = get_post($_post->post_parent);

if (($parent_post && !$revisionary->canEditPost($parent_post))
|| (rvy_get_option('revision_restore_require_cap') && !current_user_can('administrator') && !is_super_admin() && !current_user_can('restore_revisions'))
) :
?>
<style type='text/css'>
input.restore-revision {display:none !important;}
</style>
<?php

endif;
}
}
}
}
Expand Down
21 changes: 17 additions & 4 deletions admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
'revision_preview_links' => esc_html__('Show Preview Links', 'revisionary'),
'preview_link_type' => esc_html__('Preview Link Type', 'revisionary'),
'preview_link_alternate_preview_arg' => esc_html__('Modify preview link for better theme compatibility', 'revisionary'),
'home_preview_set_home_flag' => esc_html__('Theme Compat: For front page revision preview, set home flag', 'revisionary'),
'compare_revisions_direct_approval' => esc_html__('Approve Button on Compare Revisions screen', 'revisionary'),
'copy_revision_comments_to_post' => esc_html__('Copy revision comments to published post', 'revisionary'),
'past_revisions_order_by' => esc_html__('Compare Past Revisions ordering:'),
'list_unsubmitted_revisions' => sprintf(esc_html__('Include %s in My Activity, Revisions to My Posts views', 'revisionary'), pp_revisions_status_label('draft-revision', 'plural')),
'rev_publication_delete_ed_comments' => esc_html__('On Revision publication, delete Editorial Comments', 'revisionary'),
'deletion_queue' => esc_html__('Enable deletion queue', 'revisionary'),
'revision_archive_deletion' => esc_html__('Enable deletion in Revision Archive', 'revisionary'),
'revision_restore_require_cap' => esc_html__('Revision Restore: Non-Administrators need capability', 'revisionary'),
]
);

Expand All @@ -180,8 +182,8 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
'scheduled_revisions' => ['scheduled_revisions', 'scheduled_publish_cron', 'async_scheduled_publish', 'wp_cron_usage_detected', 'scheduled_revision_update_post_date', 'scheduled_revision_update_modified_date'],
'pending_revisions' => ['pending_revisions', 'revise_posts_capability', 'pending_revision_update_post_date', 'pending_revision_update_modified_date'],
'revision_queue' => ['revisor_lock_others_revisions', 'revisor_hide_others_revisions', 'admin_revisions_to_own_posts', 'list_unsubmitted_revisions'],
'preview' => ['revision_preview_links', 'preview_link_type', 'preview_link_alternate_preview_arg', 'compare_revisions_direct_approval'],
'revisions' => ['trigger_post_update_actions', 'copy_revision_comments_to_post', 'diff_display_strip_tags', 'past_revisions_order_by', 'rev_publication_delete_ed_comments', 'deletion_queue', 'revision_archive_deletion', 'display_hints'],
'preview' => ['revision_preview_links', 'preview_link_type', 'preview_link_alternate_preview_arg', 'home_preview_set_home_flag', 'compare_revisions_direct_approval'],
'revisions' => ['trigger_post_update_actions', 'copy_revision_comments_to_post', 'diff_display_strip_tags', 'past_revisions_order_by', 'rev_publication_delete_ed_comments', 'deletion_queue', 'revision_archive_deletion', 'revision_restore_require_cap', 'display_hints'],
'notification' => ['pending_rev_notify_admin', 'pending_rev_notify_author', 'revision_update_notifications', 'rev_approval_notify_admin', 'rev_approval_notify_author', 'rev_approval_notify_revisor', 'publish_scheduled_notify_admin', 'publish_scheduled_notify_author', 'publish_scheduled_notify_revisor', 'use_notification_buffer'],
]
]);
Expand Down Expand Up @@ -650,7 +652,7 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
<table class="form-table rs-form-table" id="<?php echo esc_attr("ppr-tab-$section");?>"<?php echo ($setActiveTab != $section) ? ' style="display:none;"' : '' ?>><tr><td>

<?php
$hint = esc_html__('For themes that block revision preview, hide preview links from non-Administrators', 'revisionary');
$hint = esc_html__('For themes that block revision preview, hide preview links from non-Administrators.', 'revisionary');
$this->option_checkbox( 'revision_preview_links', $tab, $section, $hint, '' );

$id = 'preview_link_type';
Expand Down Expand Up @@ -698,7 +700,13 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
<?php
}

$hint = esc_html__('If disabled, Compare screen links to Revision Preview for approval', 'revisionary');
$hint = esc_html__('Some themes may require this setting for correct revision preview display.', 'revisionary');
$this->option_checkbox( 'home_preview_set_home_flag', $tab, $section, $hint, '' );
?>
<br />

<?php
$hint = esc_html__('If disabled, Compare screen links to Revision Preview for approval.', 'revisionary');
$this->option_checkbox( 'compare_revisions_direct_approval', $tab, $section, $hint, '' );
?>
</td></tr></table>
Expand Down Expand Up @@ -771,6 +779,11 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {

$hint = '';
$this->option_checkbox( 'revision_archive_deletion', $tab, $section, $hint, '' );

if (defined('PUBLISHPRESS_REVISIONS_PRO_VERSION')) {
$hint = esc_html__('Non-Administrators cannot restore a revision without the restore_revisions capability', 'revisionary');
$this->option_checkbox( 'revision_restore_require_cap', $tab, $section, $hint, '' );
}
?>

</td></tr></table>
Expand Down
9 changes: 8 additions & 1 deletion admin/revision-action_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @package PublishPress\Revisions\RevisionaryAction
* @author PublishPress <[email protected]>
* @copyright Copyright (c) 2023 PublishPress. All rights reserved.
* @copyright Copyright (c) 2024 PublishPress. All rights reserved.
* @license GPLv2 or later
* @since 1.0.0
*/
Expand Down Expand Up @@ -100,6 +100,10 @@ function rvy_revision_submit($revision_id = 0) {
if ( empty($status_obj->public) && empty($status_obj->private) ) {
$wpdb->update($wpdb->posts, ['post_status' => 'pending', 'post_mime_type' => 'pending-revision'], ['ID' => $revision_id]);

if (defined('REVISIONARY_LIMIT_IGNORE_UNSUBMITTED')) {
rvy_update_post_meta($published_id, '_rvy_has_revisions', true);
}

clean_post_cache($revision_id);

require_once( dirname(REVISIONARY_FILE).'/revision-workflow_rvy.php' );
Expand Down Expand Up @@ -342,6 +346,7 @@ function rvy_revision_approve($revision_id = 0, $args = []) {
clean_post_cache( $revision->ID );
} else {
$_result = rvy_apply_revision($revision->ID, $revision->post_mime_type);

if (!$_result || is_wp_error($_result)) {
// Go ahead with the normal redirect because the revision may have been approved / published already.
// If revision does not exist, preview's Not Found will prevent false impression of success.
Expand Down Expand Up @@ -861,6 +866,8 @@ function rvy_apply_revision( $revision_id, $actual_revision_status = '' ) {
],
['ID' => $revision_id]
);

Revisionary::applyRevisionLimit($published);
} else {
wp_delete_post($revision_id, true);
}
Expand Down
Loading

0 comments on commit 18060a2

Please sign in to comment.