Skip to content

Commit

Permalink
Merge pull request #104 from publishpress/release-2-3-8
Browse files Browse the repository at this point in the history
Release 2.3.8
  • Loading branch information
agapetry authored Jul 30, 2020
2 parents ca0a1d2 + 0487012 commit ba7cd83
Show file tree
Hide file tree
Showing 75 changed files with 2,324 additions and 12,367 deletions.
42 changes: 38 additions & 4 deletions admin/admin-init_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,43 @@ function rvy_admin_init() {

break;

case 'unschedule_revision' :
$unscheduled = 0;
$is_administrator = current_user_can('administrator');

require_once( dirname(__FILE__).'/revision-action_rvy.php');

foreach ((array) $post_ids as $post_id) {
if (!$revision = get_post($post_id)) {
continue;
}

if ('future-revision' != $revision->post_status) {
continue;
}

if ( !$is_administrator
&& !agp_user_can($type_obj->cap->edit_post, rvy_post_id($revision->ID), '', ['skip_revision_allowance' => true])
) {
if (count($post_ids) == 1) {
wp_die( __('Sorry, you are not allowed to approve this revision.', 'revisionary') );
} else {
continue;
}
}

if (rvy_revision_unschedule($revision->ID)) {
$unscheduled++;
}
}

if ($unscheduled) {
$arg = 'unscheduled_count';
$sendback = add_query_arg($arg, $unscheduled, $sendback);
}

break;

case 'delete':
$deleted = 0;
foreach ( (array) $post_ids as $post_id ) {
Expand Down Expand Up @@ -167,6 +204,7 @@ function rvy_admin_init() {

if ($sendback) {
$sendback = remove_query_arg( array('action', 'action2', '_wp_http_referer', '_wpnonce', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
$sendback = str_replace('#038;', '&', $sendback); // @todo Proper decode
wp_redirect($sendback);
}

Expand All @@ -189,10 +227,6 @@ function rvy_admin_init() {
require_once( dirname(__FILE__).'/revision-action_rvy.php');
add_action( 'wp_loaded', 'rvy_revision_publish' );

} elseif ( ! empty($_GET['action']) && ('unschedule' == $_GET['action']) ) {
require_once( dirname(__FILE__).'/revision-action_rvy.php');
add_action( 'wp_loaded', 'rvy_revision_unschedule' );

} elseif ( ! empty($_POST['action']) && ('bulk-delete' == $_POST['action'] ) ) {
require_once( dirname(__FILE__).'/revision-action_rvy.php');
add_action( 'wp_loaded', 'rvy_revision_bulk_delete' );
Expand Down
37 changes: 37 additions & 0 deletions admin/admin_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function __construct() {

add_action('admin_head', array(&$this, 'admin_head'));
add_action('admin_enqueue_scripts', array(&$this, 'admin_scripts'));
add_action('admin_print_scripts', [$this, 'admin_print_scripts'], 99);

if ( ! defined('XMLRPC_REQUEST') && ! strpos($script_name, 'p-admin/async-upload.php' ) ) {
global $blog_id;
Expand Down Expand Up @@ -530,6 +531,26 @@ function admin_scripts() {
</style>
<?php
}

if (!class_exists('DS_Public_Post_Preview')) {
?>
<style>
div.edit-post-post-visibility, div.edit-post-post-status div {
display:none;
}
</style>
<?php
} else {
?>
<style>
/*
div.edit-post-post-status #inspector-checkbox-control-1 {
display:none;
}
*/
</style>
<?php
}
}

wp_enqueue_style('revisionary-admin-common', RVY_URLPATH . '/common/css/pressshack-admin.css', [], REVISIONARY_VERSION);
Expand All @@ -539,6 +560,22 @@ 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
}
}

function admin_head() {
//echo '<link rel="stylesheet" href="' . RVY_URLPATH . '/admin/revisionary.css" type="text/css" />'."\n";

Expand Down
12 changes: 8 additions & 4 deletions admin/class-list-table_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ function pre_query_where_filter($where, $args = []) {
$can_edit_others_types = [];

foreach(array_keys($revisionary->enabled_post_types) as $post_type) {
$type_obj = get_post_type_object($post_type);

if (agp_user_can($type_obj->cap->edit_others_posts, 0, '', ['skip_revision_allowance' => true])) {
$can_edit_others_types[]= $post_type;
if ($type_obj = get_post_type_object($post_type)) {
if (agp_user_can($type_obj->cap->edit_others_posts, 0, '', ['skip_revision_allowance' => true])) {
$can_edit_others_types[]= $post_type;
}
}
}

Expand Down Expand Up @@ -724,6 +724,10 @@ protected function get_bulk_actions() {
if ($approval_potential = apply_filters('revisionary_bulk_action_approval', $approval_potential)) {
$actions['approve_revision'] = __('Approve');
$actions['publish_revision'] = __('Publish');

if (revisionary()->getOption('scheduled_revisions')) {
$actions['unschedule_revision'] = __('Unschedule', 'revisionary');
}
}

$actions['delete'] = __( 'Delete Permanently' );
Expand Down
31 changes: 7 additions & 24 deletions admin/revision-action_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,9 @@ function rvy_revision_bulk_delete() {
exit;
}

function rvy_revision_unschedule() {
require_once( ABSPATH . 'wp-admin/admin.php');
$revision_id = (int) $_GET['revision'];
function rvy_revision_unschedule($revision_id) {
global $wpdb;

$redirect = '';

do {
Expand All @@ -742,34 +742,17 @@ function rvy_revision_unschedule() {
}

if ( $type_obj = get_post_type_object( $revision->post_type ) ) {
if ( ! agp_user_can( $type_obj->cap->edit_post, $published_id, '', array( 'skip_revision_allowance' => true ) ) )
if ( ! agp_user_can( $type_obj->cap->edit_post, $published_id, '', array( 'skip_revision_allowance' => true ) ) ) {
break;
}
}

check_admin_referer('unschedule-revision_' . $revision_id);

global $wpdb;
$wpdb->query(
$wpdb->prepare(
"UPDATE $wpdb->posts SET post_status = 'pending-revision' WHERE ID = %d",
$revision_id
)
);
$wpdb->update( $wpdb->posts, array( 'post_status' => 'pending-revision' ), array( 'ID' => $revision->ID ) );

rvy_update_next_publish_date();

$redirect = rvy_preview_url($revision);
} while (0);

if ( ! $redirect ) {
if ( ! empty($post) && is_object($post) && ( 'post' != $post->post_type ) ) {
$redirect = "edit.php?post_type={$post->post_type}";
} else
$redirect = 'edit.php';
}

wp_redirect( $redirect );
exit;
return true;
}

function rvy_revision_publish($revision_id = false) {
Expand Down
2 changes: 2 additions & 0 deletions admin/revision-queue_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'updated' => 0,
'locked' => 0,
'approved_count' => isset( $_REQUEST['approved_count'] ) ? absint( $_REQUEST['approved_count'] ) : 0,
'unscheduled_count' => isset( $_REQUEST['unscheduled_count'] ) ? absint( $_REQUEST['unscheduled_count'] ) : 0,
'published_count' => isset( $_REQUEST['published_count'] ) ? absint( $_REQUEST['published_count'] ) : 0,
'trashed' => 0,
'untrashed' => 0,
Expand All @@ -37,6 +38,7 @@
$bulk_messages = [];
$bulk_messages['post'] = array(
'approved_count' => sprintf(_n( '%s revision approved.', '%s revisions approved.', $bulk_counts['approved_count'], 'revisionary' ), $bulk_counts['approved_count']),
'unscheduled_count' => sprintf(_n( '%s revision unscheduled.', '%s revisions unscheduled.', $bulk_counts['unscheduled_count'], 'revisionary' ), $bulk_counts['unscheduled_count']),
'published_count' => sprintf(_n( '%s revision published.', '%s revisions published.', $bulk_counts['published_count'], 'revisionary' ), $bulk_counts['published_count']),
'deleted' => sprintf(_n( '%s revision permanently deleted.', '%s revisions permanently deleted.', $bulk_counts['deleted'] ), $bulk_counts['deleted']),
);
Expand Down
8 changes: 2 additions & 6 deletions admin/rvy-revision-edit.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
div.edit-post-post-visibility {
display:none;
}

div.edit-post-post-status div {
display:none;
div.publishpress-extended-post-privacy, div.publishpress-extended-post-status {
display: none;
}

div.edit-post-post-status div.edit-post-post-schedule, div.edit-post-post-status div.edit-post-post-schedule div {
Expand Down
Binary file added languages/revisionary-es_ES.mo
Binary file not shown.
Empty file added languages/revisionary-es_ES.po
Empty file.
Binary file modified languages/revisionary-fr_FR.mo
Binary file not shown.
Loading

0 comments on commit ba7cd83

Please sign in to comment.