Skip to content

Commit

Permalink
Merge pull request #229 from publishpress/release/2.4.2
Browse files Browse the repository at this point in the history
Release/2.4.2
  • Loading branch information
agapetry authored Oct 26, 2020
2 parents 517d2df + ecc996e commit 766094d
Show file tree
Hide file tree
Showing 15 changed files with 391 additions and 284 deletions.
2 changes: 1 addition & 1 deletion admin/admin-init_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function rvy_load_textdomain() {
if ( defined('RVY_TEXTDOMAIN_LOADED') )
return;

load_plugin_textdomain('revisionary', false, RVY_FOLDER . '/languages');
load_plugin_textdomain('revisionary', false, dirname(plugin_basename(REVISIONARY_FILE)) . '/languages');

define('RVY_TEXTDOMAIN_LOADED', true);
}
Expand Down
47 changes: 32 additions & 15 deletions admin/admin_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
if( basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME']) )
die();

$wp_content = ( is_ssl() || ( is_admin() && defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ) ) ? str_replace( 'http:', 'https:', WP_CONTENT_URL ) : WP_CONTENT_URL;
define ('RVY_URLPATH', $wp_content . '/plugins/' . RVY_FOLDER);
define ('RVY_URLPATH', plugins_url('', REVISIONARY_FILE));

class RevisionaryAdmin
{
Expand Down Expand Up @@ -155,9 +154,23 @@ function __construct() {

add_filter('presspermit_disable_exception_ui', [$this, 'fltDisableExceptionUI'], 10, 4);

add_filter('presspermit_status_control_scripts', [$this, 'fltDisableStatusControlScripts']);

add_action('admin_menu', [$this, 'actSettingsPageMaybeRedirect'], 999);
}

public function fltDisableStatusControlScripts($enable_scripts) {
if ($post_id = rvy_detect_post_id()) {
if ($post = get_post($post_id)) {
if (!empty($post) && rvy_is_revision_status($post->post_status)) {
$enable_scripts = false;
}
}
}

return $enable_scripts;
}

public function fltDisableExceptionUI($disable, $src_name, $post_id, $post_type = '') {
if (!$post_id) {
// Permissions version < 3.1.4 always passes zero value $post_id
Expand Down Expand Up @@ -397,7 +410,9 @@ function handle_submission_redirect() {
$revisionary->do_notifications( $status, $status, (array) $revised_post, $args );
}

rvy_halt( $revisionary->get_revision_msg( $revision, array( 'post_arr' => (array) $revision, 'post_id' => $revised_post->ID ) ) );
if (apply_filters('revisionary_do_submission_redirect', true)) {
rvy_halt( $revisionary->get_revision_msg( $revision, array( 'post_arr' => (array) $revision, 'post_id' => $revised_post->ID ) ) );
}
}
}
}
Expand Down Expand Up @@ -515,7 +530,7 @@ function flt_detect_revision_save( $post_status ) {

// adds an Options link next to Deactivate, Edit in Plugins listing
function flt_plugin_action_links($links, $file) {
if ( $file == RVY_BASENAME ) {
if ($file == plugin_basename(REVISIONARY_FILE)) {
$page = ( RVY_NETWORK ) ? 'rvy-net_options' : 'revisionary-settings';
$links[] = "<a href='admin.php?page=$page'>" . __awp('Settings') . "</a>";
}
Expand Down Expand Up @@ -568,17 +583,19 @@ function admin_scripts() {

function admin_print_scripts() {
if (class_exists('DS_Public_Post_Preview')) {
?>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready( function($) {
setInterval(function() {
$("div.edit-post-post-status label:not(:contains('<?php _e('Enable public preview');?>')):not('[for=public-post-preview-url]')"). closest('div').hide();
}, 100);
});
/* ]]> */
</script>
<?php
$post_id = rvy_detect_post_id();

if ($post_id && rvy_is_revision_status(get_post_field('post_status', $post_id))):?>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready( function($) {
setInterval(function() {
$("div.edit-post-post-status label:not(:contains('<?php _e('Enable public preview');?>')):not('[for=public-post-preview-url]')").closest('div').closest('div.components-panel__row').hide();
}, 100);
});
/* ]]> */
</script>
<?php endif;
}
}

Expand Down
6 changes: 4 additions & 2 deletions admin/class-list-table_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($args = []) {
remove_action('the_post', [$multiple_authors_addon, 'fix_post'], 10);
}

if (!empty($_REQUEST['published_post']) && !get_post_meta($post_id, '_rvy_has_revisions', true)) {
if (!empty($_REQUEST['published_post']) && !get_post_meta($_REQUEST['published_post'], '_rvy_has_revisions', true)) {
revisionary_refresh_postmeta($_REQUEST['published_post']);
}
}
Expand Down Expand Up @@ -62,7 +62,9 @@ function do_query( $q = false ) {
$qp['posts_per_page'] = -1;
$qp['fields'] = 'ids';

$qp['meta_key'] = '_rvy_has_revisions';
if (!rvy_get_option('queue_query_all_posts')) { // support defeat of performance enhancement in case _has_revisions flag is not being stored reliably due to plugin integration issues
$qp['meta_key'] = '_rvy_has_revisions';
}

if (!empty($q['post_author'])) {
do_action('revisionary_queue_pre_query');
Expand Down
4 changes: 3 additions & 1 deletion admin/history_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function actAjaxRevisionDiffs() {
return;
}

if ( ! current_user_can( 'edit_post', $post->ID ) ) {
if ( ! current_user_can( 'read_post', $post->ID ) ) {
return;
}

Expand Down Expand Up @@ -1096,6 +1096,8 @@ function actRevisionDiffScripts() {
}

function actPastRevisionDiffScripts() {
global $revisionary;

if (did_action('rvy_compare_revisions')) {
return;
}
Expand Down
62 changes: 44 additions & 18 deletions admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,21 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
'role_definition' => __('Role Definition', 'revisionary'),
'scheduled_revisions' => __('Scheduled Revisions', 'revisionary'),
'pending_revisions' => __('Pending Revisions', 'revisionary'),
'revision_queue' => __('Revision Queue', 'revisionary'),
'preview' => __('Preview / Approval', 'revisionary'),
'revisions' => __('Revision Options', 'revisionary'),
'notification' => __('Email Notification', 'revisionary')
)
);

// TODO: replace individual _e calls with these (and section, tab captions)
$this->option_captions = apply_filters('revisionary_option_captions', array(
$this->option_captions = apply_filters('revisionary_option_captions',
[
'pending_revisions' => __('Enable Pending Revisions', 'revisionary'),
'scheduled_revisions' => __('Enable Scheduled Revisions', 'revisionary'),
'revisor_lock_others_revisions' => __("Prevent Revisors from editing others&apos; revisions", 'revisionary'),
'revisor_hide_others_revisions' => __("Prevent Revisors from viewing others&apos; revisions", 'revisionary'),
'queue_query_all_posts' => __('Compatibility Mode', 'revisionary'),
'trigger_post_update_actions' => __('Revision publication triggers API actions to mimic post update', 'revisionary'),
'diff_display_strip_tags' => __('Strip html tags out of difference display', 'revisionary'),
'async_scheduled_publish' => __('Asynchronous Publishing', 'revisionary'),
Expand All @@ -128,7 +131,8 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
'preview_link_type' => __('Preview Link Type', 'revisionary'),
'compare_revisions_direct_approval' => __('Approve Button on Compare Revisions screen', 'revisionary'),
'copy_revision_comments_to_post' => __('Copy revision comments to published post', 'revisionary'),
));
]
);


if ( defined('RVY_CONTENT_ROLES') ) {
Expand All @@ -144,13 +148,14 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {

$this->form_options = apply_filters('revisionary_option_sections', [
'features' => [
'license' => array( 'edd_key' ),
'role_definition' => array( 'revisor_role_add_custom_rolecaps', 'require_edit_others_drafts' ),
'scheduled_revisions' => array( 'scheduled_revisions', 'async_scheduled_publish', 'scheduled_revision_update_post_date', ),
'pending_revisions' => array( 'pending_revisions', 'pending_revision_update_post_date', ),
'preview' => array( 'revision_preview_links', 'preview_link_type', 'compare_revisions_direct_approval'),
'revisions' => array( 'revisor_lock_others_revisions', 'revisor_hide_others_revisions', 'trigger_post_update_actions', 'copy_revision_comments_to_post', 'diff_display_strip_tags', 'display_hints' ),
'notification' => array( 'pending_rev_notify_admin', 'pending_rev_notify_author', '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' )
'license' => ['edd_key'],
'role_definition' => ['revisor_role_add_custom_rolecaps', 'require_edit_others_drafts'],
'scheduled_revisions' => ['scheduled_revisions', 'async_scheduled_publish', 'scheduled_revision_update_post_date'],
'pending_revisions' => ['pending_revisions', 'pending_revision_update_post_date'],
'revision_queue' => ['revisor_lock_others_revisions', 'revisor_hide_others_revisions', 'queue_query_all_posts'],
'preview' => ['revision_preview_links', 'preview_link_type', 'compare_revisions_direct_approval'],
'revisions' => ['trigger_post_update_actions', 'copy_revision_comments_to_post', 'diff_display_strip_tags', 'display_hints'],
'notification' => ['pending_rev_notify_admin', 'pending_rev_notify_author', '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 @@ -374,6 +379,36 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
endif;


if ( // To avoid confusion, don't display any revision settings if pending revisions / scheduled revisions are unavailable
$pending_revisions_available || $scheduled_revisions_available ) :

$section = 'revision_queue'; // --- REVISION QUEUE SECTION ---

if ( ! empty( $this->form_options[$tab][$section] ) ) :?>
<tr valign="top"><th scope="row">
<?php echo $this->section_captions[$tab][$section]; ?>
</th><td>

<?php
$hint = __('This restriction applies to users who are not full editors for the post type. To enable a role, give it the edit_others_revisions capability.', 'revisionary');
$this->option_checkbox( 'revisor_lock_others_revisions', $tab, $section, $hint, '' );

$hint = __('This restriction applies to users who are not full editors for the post type. To enable a role, give it the list_others_revisions capability.', 'revisionary');
$this->option_checkbox( 'revisor_hide_others_revisions', $tab, $section, $hint, '' );

$hint = __('If some revisions are missing from the queue, disable a performance enhancement for better compatibility with themes and plugins.', 'revisionary');
$this->option_checkbox( 'queue_query_all_posts', $tab, $section, $hint, '' );
?>

<p style="padding-left:22px">
<a href="<?php echo add_query_arg('rvy_flush_flags', 1, esc_url($_SERVER['REQUEST_URI']))?>"><?php _e('Regenerate "post has revision" flags', 'revisionary');?></a>
</p>

</td></tr>
<?php endif; // any options accessable in this section
endif;


$section = 'preview'; // --- PREVIEW SECTION ---

if ( ! empty( $this->form_options[$tab][$section] ) ) :?>
Expand Down Expand Up @@ -444,12 +479,6 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
<?php endif;?>

<?php
$hint = __('This restriction applies to users who are not full editors for the post type. To enable a role, give it the edit_others_revisions capability.', 'revisionary');
$this->option_checkbox( 'revisor_lock_others_revisions', $tab, $section, $hint, '' );

$hint = __('This restriction applies to users who are not full editors for the post type. To enable a role, give it the list_others_revisions capability.', 'revisionary');
$this->option_checkbox( 'revisor_hide_others_revisions', $tab, $section, $hint, '' );

$hint = __('This may improve compatibility with some plugins.', 'revisionary');
$this->option_checkbox( 'trigger_post_update_actions', $tab, $section, $hint, '' );

Expand All @@ -463,9 +492,6 @@ function options_ui( $sitewide = false, $customize_defaults = false ) {
$this->option_checkbox( 'display_hints', $tab, $section, $hint, '' );
?>

<p style="padding-left:22px">
<a href="<?php echo add_query_arg('rvy_flush_flags', 1, esc_url($_SERVER['REQUEST_URI']))?>"><?php _e('Regenerate revision storage flags (for Revision Queue listing)', 'revisionary');?></a>
</p>
</td></tr>
<?php endif; // any options accessable in this section

Expand Down
12 changes: 12 additions & 0 deletions admin/post-edit-block-ui_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ public static function act_object_guten_scripts() {
'previewURL' => $preview_url,
);

if (defined('REVISIONARY_DISABLE_SUBMISSION_REDIRECT') || !apply_filters('revisionary_do_submission_redirect', true)) {
unset($args['redirectURLpending']);
}

if (defined('REVISIONARY_DISABLE_SCHEDULE_REDIRECT') || !apply_filters('revisionary_do_schedule_redirect', true)) {
unset($args['redirectURLscheduled']);
}

if ($do_pending_revisions && $_revisions = rvy_get_post_revisions($post_id, 'pending-revision', ['orderby' => 'ID', 'order' => 'ASC'])) {
$status_obj = get_post_status_object('pending-revision');
$args['pendingRevisionsCaption'] = sprintf(_n('<span class="dashicons dashicons-edit"></span>&nbsp;%s Pending Revision', '<span class="dashicons dashicons-edit"></span>&nbsp;%s Pending Revisions', count($_revisions), 'revisionary'), count($_revisions));
Expand Down Expand Up @@ -165,6 +173,10 @@ public static function act_object_guten_scripts() {
'redirectURL' => admin_url("edit.php?post_type={$post_type}&revision_submitted={$status}&post_id={$post_id}"),
'revisableStatuses' => rvy_filtered_statuses('names'),
);

if (defined('REVISIONARY_DISABLE_SUBMISSION_REDIRECT') || !apply_filters('revisionary_do_submission_redirect', true)) {
unset($args['redirectURL']);
}
}

wp_localize_script( 'rvy_object_edit', 'rvyObjEdit', $args );
Expand Down
2 changes: 2 additions & 0 deletions defaults_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function rvy_default_options_sitewide() {
'revisor_role_add_custom_rolecaps' => true,
'revisor_lock_others_revisions' => true,
'revisor_hide_others_revisions' => true,
'queue_query_all_posts' => true,
'require_edit_others_drafts' => true,
'diff_display_strip_tags' => false,
'scheduled_revision_update_post_date' => true,
Expand Down Expand Up @@ -68,6 +69,7 @@ function rvy_default_options() {
'revisor_role_add_custom_rolecaps' => 1,
'revisor_lock_others_revisions' => 1,
'revisor_hide_others_revisions' => 1,
'queue_query_all_posts' => 0,
'require_edit_others_drafts' => 1,
'diff_display_strip_tags' => 0,
'scheduled_revision_update_post_date' => 1,
Expand Down
25 changes: 20 additions & 5 deletions front_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ function __construct() {
if (defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION')) {
add_filter('the_author', [$this, 'fltAuthor'], 20);
}

if (!empty($_REQUEST['_ppp'])) {
add_action('template_redirect', [$this, 'actRevisionPreviewRedirect'], 1);
}
}

public function actRevisionPreviewRedirect() {
if (!class_exists('DS_Public_Post_Preview')) {
return;
}

if ($_post = get_post(rvy_detect_post_id())) {
if (('revision' == $_post->post_type) && ('inherit' == $_post->post_status)) {
if ($url = get_permalink(rvy_post_id($_post->ID))) {
wp_redirect($url);
}
}
}
}

public function fltAuthor($display_name) {
Expand Down Expand Up @@ -163,7 +181,7 @@ function act_template_redirect() {

$redirect_arg = ( ! empty($_REQUEST['rvy_redirect']) ) ? "&rvy_redirect=" . esc_url($_REQUEST['rvy_redirect']) : '';

load_plugin_textdomain('revisionary', false, RVY_FOLDER . '/languages');
load_plugin_textdomain('revisionary', false, dirname(plugin_basename(REVISIONARY_FILE)) . '/languages');

$published_url = ($published_post_id) ? get_permalink($published_post_id) : '';
$diff_url = admin_url("revision.php?revision=$revision_id");
Expand Down Expand Up @@ -309,10 +327,7 @@ function act_template_redirect() {
}

function rvyFrontCSS() {
$wp_content = ( is_ssl() || ( is_admin() && defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ) ) ? str_replace( 'http:', 'https:', WP_CONTENT_URL ) : WP_CONTENT_URL;
$path = $wp_content . '/plugins/' . RVY_FOLDER;

echo '<link rel="stylesheet" href="' . $path . '/revisionary-front.css" type="text/css" />'."\n";
echo '<link rel="stylesheet" href="' . plugins_url('', REVISIONARY_FILE) . '/revisionary-front.css" type="text/css" />'."\n";
}

function rvyEnqueuePreviewJS() {
Expand Down
Binary file modified languages/revisionary.mo
Binary file not shown.
Loading

0 comments on commit 766094d

Please sign in to comment.