+
+
+
+
', '');?>
+
+
+
post_status);
- if (empty($actions['view'])) {
-
- }
-
if (!empty($status_obj->public) || !empty($status_obj->private) || rvy_get_option('pending_revision_unpublished')) {
- if (rvy_get_option('pending_revisions') && current_user_can('copy_post', $post->ID) && rvy_post_revision_supported($post)) {
+ if (rvy_get_option('pending_revisions') && current_user_can('copy_post', $post->ID) && rvy_post_revision_supported($post, ['context' => 'admin_posts'])) {
+ $referer_arg = '&referer=' . esc_url_raw($_SERVER['REQUEST_URI']);
+
$redirect_arg = ( ! empty($_REQUEST['rvy_redirect']) ) ? "&rvy_redirect=" . esc_url_raw($_REQUEST['rvy_redirect']) : '';
- $url = rvy_admin_url("admin.php?page=rvy-revisions&post={$post->ID}&action=revise$redirect_arg");
+ $url = rvy_admin_url("admin.php?page=rvy-revisions&post={$post->ID}&action=revise{$referer_arg}$redirect_arg");
$caption = (isset($actions['edit']) || !rvy_get_option('caption_copy_as_edit')) ? pp_revisions_status_label('draft-revision', 'submit') : esc_html__('Edit');
-
$caption = str_replace(' ', ' ', $caption);
$actions['create_revision'] = "
" . $caption . '';
diff --git a/admin/revisions.php b/admin/revisions.php
index a48d9a9..86cad98 100644
--- a/admin/revisions.php
+++ b/admin/revisions.php
@@ -47,7 +47,23 @@
if ( empty($revision_id) && ! $left && ! $right ) {
echo( '
' );
- esc_html_e( 'No revision specified.', 'revisionary');
+
+ if (!empty($_REQUEST['action']) && ('revise' == $_REQUEST['action'])) {
+ // Fallback error message, in case redirect is missed
+ if (!empty($_REQUEST['post'])) {
+ $post_id = intval($_REQUEST['post']);
+ $arr = rvy_post_revision_blocked($post_id);
+ }
+
+ if (!empty($arr) && is_array($arr) && !empty($arr['description'])) {
+ echo $arr['description'];
+ } else {
+ esc_html_e( 'Revision of this post is not allowed.', 'revisionary');
+ }
+ } else {
+ esc_html_e( 'No revision specified.', 'revisionary');
+ }
+
echo( '
' );
return;
}
diff --git a/rvy_init-functions.php b/rvy_init-functions.php
index 36608a9..2d8c468 100644
--- a/rvy_init-functions.php
+++ b/rvy_init-functions.php
@@ -718,18 +718,48 @@ function revisionary_refresh_postmeta($post_id, $args = []) {
}
}
-function rvy_post_revision_supported($post) {
+function rvy_post_revision_supported($post, $args = []) {
+ if ($post) {
+ if (rvy_post_revision_blocked($post, $args)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+function rvy_post_revision_blocked($post, $args = []) {
+ static $unfiltered_html;
+
+ if (!isset($unfiltered_html)) {
+ $unfiltered_html = current_user_can('unfiltered_html');
+ }
+
$post_id = (is_scalar($post)) ? $post : $post->ID;
- if ($post_id) {
- if (1 === intval(rvy_get_option('revision_limit_per_post'))) {
- if (rvy_get_post_meta($post_id, '_rvy_has_revisions')) {
- return false;
- }
+ if (1 === intval(rvy_get_option('revision_limit_per_post'))) {
+ if (rvy_get_post_meta($post_id, '_rvy_has_revisions')) {
+ return [
+ 'code' => 'blocked_revision_limit',
+ 'description' => __('The post already has a revision in process.', 'revisionary')
+ ];
}
}
- return true;
+ if (!$unfiltered_html && (empty($args['context']) || ('admin_posts' != $args['context']))) {
+ if (is_scalar($post)) {
+ $post = get_post($post);
+ }
+
+ if (!empty($post) && is_object($post) && !empty($post->post_content && (wp_filter_post_kses($post->post_content) != $post->post_content))) {
+ return [
+ 'code' => 'blocked_unfiltered',
+ 'description' => __('The unfiltered_html capability is required to create a revision of this post.', 'revisionary')
+ ];
+ }
+ }
+
+ return false;
}
if (!empty($_REQUEST['rvy_flush_flags'])) {