Skip to content

Commit

Permalink
Merge pull request #1134 from publishpress/release-3.5.5
Browse files Browse the repository at this point in the history
Release 3.5.5
  • Loading branch information
agapetry authored Dec 12, 2023
2 parents 06837eb + 4f12cd3 commit 031935e
Show file tree
Hide file tree
Showing 21 changed files with 2,207 additions and 2,253 deletions.
11 changes: 4 additions & 7 deletions admin/RevisionEditSubmitMetabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public static function post_submit_meta_box($post, $args = [])
<?php
}


/*
* Classic Editor Post Submit Metabox: Post Save Button HTML
*/
Expand Down Expand Up @@ -108,7 +107,7 @@ public static function post_preview_button($post, $args)
?>
<?php
if (rvy_get_option('revision_preview_links') || current_user_can('administrator') || is_super_admin()) {
$preview_link = rvy_preview_url($post);
$preview_link = esc_url(get_permalink($post->ID));

$type_obj = get_post_type_object($post->post_type);

Expand All @@ -120,17 +119,15 @@ public static function post_preview_button($post, $args)

if ($type_obj && empty($type_obj->public)) {
return;
} elseif ($can_publish) {
$preview_button = esc_html__('Preview', 'revisionary');
$preview_title = esc_html__('View / moderate saved revision', 'revisionary');
} else {
$preview_button = esc_html__('Preview', 'revisionary');
$preview_title = esc_html__('View saved revision', 'revisionary');
$preview_title = esc_html__('Preview revision in progress', 'revisionary');
}
?>
<a class="preview button" href="<?php echo esc_url($preview_link); ?>" target="_blank" id="revision-preview"
<a class="preview button" href="<?php echo esc_url($preview_link); ?>" target="_blank" id="post-preview"
tabindex="4" title="<?php echo esc_attr($preview_title);?>"><?php echo esc_html($preview_button); ?></a>

<input type="hidden" name="wp-preview" id="wp-preview" value="">
<?php
}
}
Expand Down
7 changes: 2 additions & 5 deletions admin/class-list-table-archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ private function heading_spacing( $count ) {
}

protected function get_bulk_actions() {
$actions = [];

if (rvy_get_option('revision_archive_deletion')) {
$actions = [];
$actions['delete'] = esc_html__( 'Delete Revision', 'revisionary' );
}

Expand All @@ -389,10 +390,6 @@ protected function get_bulk_actions() {

// override default nonce field
protected function display_tablenav( $which ) {
if (!rvy_get_option('revision_archive_deletion')) {
return;
}

if ( 'top' === $which ) {
wp_nonce_field( 'bulk-revision-archive' );
}
Expand Down
48 changes: 44 additions & 4 deletions admin/post-edit_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function __construct() {
add_filter('presspermit_preview_post_title', [$this, 'fltPreviewTitle']);

add_action('post_submitbox_misc_actions', [$this, 'act_post_submit_revisions_links'], 5);
add_action('post_submitbox_misc_actions', [$this, 'actPostSubmitboxActions'], 20);

add_filter('user_has_cap', [$this, 'fltAllowBrowseRevisionsLink'], 50, 3);

Expand Down Expand Up @@ -103,20 +104,59 @@ public function fltPreviewLabel($preview_caption) {
public function fltPreviewTitle($preview_title) {
global $post;

$type_obj = get_post_type_object($post->post_type);
if (!empty($post) && !empty($post->ID) && rvy_in_revision_workflow($post->ID)) {
$type_obj = get_post_type_object($post->post_type);

if ($type_obj && empty($type_obj->public)) {
return $preview_title;
if ($type_obj && !empty($type_obj->public)) {
$preview_title = esc_html__('View revision in progress', 'revisionary');
}
}

return $preview_title;
}

function actPostSubmitboxActions($post) {
?>

<div id="preview-action" style="float: right; padding: 5px 10px 10px 5px">
<?php self::revision_preview_button($post); ?>
</div>

<?php
}

public static function revision_preview_button($post)
{
if (empty($post) || !is_object($post) || empty($post->ID)) {
return;
}

if (!rvy_in_revision_workflow($post->ID)) {
return;
}

if ($type_obj = get_post_type_object($post->post_type)) {
if (empty($type_obj->public) && empty($type_obj->publicly_queryable)) {
return;
}
}

?>
<?php
$preview_link = rvy_preview_url($post->ID);
$preview_button = esc_html__('View Saved Revision');

if (current_user_can('edit_post', rvy_post_id($post->ID))) {
$preview_title = esc_html__('View / moderate saved revision', 'revisionary');

} elseif ($type_obj && !empty($type_obj->public)) {
$preview_title = esc_html__('View saved revision', 'revisionary');
}

return $preview_title;
?>
<a class="preview button" href="<?php echo esc_url($preview_link); ?>" target="revision-preview" id="revision-preview"
tabindex="4" title="<?php echo esc_html($preview_title);?>"><?php echo esc_html($preview_button); ?></a>
<?php
}

function act_post_submit_revisions_links() {
Expand Down
2 changes: 1 addition & 1 deletion admin/post-editor-workflow-ui_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function revisionLinkParams($args = []) {
$vars['viewCaption'] = ('future-revision' == $post->post_mime_type) ? esc_html__('View / Publish', 'revisionary') : esc_html__('View / Approve', 'revisionary');
}

$vars['viewTitle'] = esc_html__('View / Approve saved revision', 'revisionary');
$vars['viewTitle'] = esc_html__('View / Moderate saved revision', 'revisionary');
} else {
$vars['viewCaption'] = version_compare($wp_version, '5.5-beta', '>=') ? esc_html__('Preview / Submit') : esc_html__('View / Submit');
$vars['viewTitle'] = esc_html__('View / Submit saved revision', 'revisionary');
Expand Down
2 changes: 2 additions & 0 deletions admin/revision-action_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ function rvy_apply_revision( $revision_id, $actual_revision_status = '' ) {
$update_fields['post_status'] = $published->post_status;
}

$update_fields = apply_filters('revisionary_apply_revision_fields', $update_fields, $revision, $published, $actual_revision_status);

if (
(in_array($revision->post_mime_type, ['draft-revision', 'pending-revision']) && rvy_filter_option('pending_revision_update_modified_date', ['revision_id' => $revision_id, 'post_id' => $published->ID]))
|| (('future-revision' == $revision->post_mime_type) && rvy_filter_option('scheduled_revision_update_modified_date', ['revision_id' => $revision_id, 'post_id' => $published->ID]))
Expand Down
3 changes: 2 additions & 1 deletion admin/revision-ui_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ function rvy_list_post_revisions( $post_id = 0, $status = '', $args = null ) {
if ( $post->ID != $revision->ID ) {
if ('inherit' == $revision->post_status) {
// @todo: need this case?
$preview_url = add_query_arg( 'preview', '1', get_post_permalink( $revision->ID ) . '&post_type=revision' );
$preview_arg = (defined('RVY_PREVIEW_ARG')) ? sanitize_key(constant('RVY_PREVIEW_ARG')) : 'rv_preview';
$preview_url = add_query_arg($preview_arg, '1', get_post_permalink( $revision->ID ) . '&post_type=revision' );
} else {
$preview_url = rvy_preview_url($revision, ['post_type' => $post->post_type]);
}
Expand Down
13 changes: 8 additions & 5 deletions admin/rvy_revision-classic-edit.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ jQuery(document).ready( function($) {
}

if (!$(refSelector).length) {
var refSelector = '#submitdiv div.misc-pub-curtime';
var refSelector = '#submitdiv div.curtime';
}

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

}

if (rvyObjEdit.ajaxurl && !$('div.rvy-creation-ui').length && $(refSelector).length) {
if (rvyObjEdit[rvyObjEdit.currentStatus + 'ActionURL']) {
var url = rvyObjEdit[rvyObjEdit.currentStatus + 'ActionURL'];
} else {
Expand Down Expand Up @@ -77,6 +79,7 @@ jQuery(document).ready( function($) {

$('a.save-timestamp').click(function() {
$('#save-post').val(rvyObjEdit.updateCaption);
$('a.revision-approve, a.rvy-direct-approve').attr('disabled', 'disabled');
});

$(document).on('click', 'a.save-timestamp, a.cancel-timestamp', function() {
Expand All @@ -93,7 +96,7 @@ jQuery(document).ready( function($) {

$(document).on('click', 'a.revision-approve', function() {
if ($('a.revision-approve').attr('disabled')) {
return;
return false;
}

$('a.revision-approve').attr('disabled', 'disabled');
Expand Down Expand Up @@ -151,7 +154,7 @@ jQuery(document).ready( function($) {

$(document).on('click', 'a.rvy-direct-approve', function() {
if ($('a.rvy-direct-approve').attr('disabled')) {
return;
return false;
}

clearInterval(RvyUIInterval);
Expand Down
13 changes: 7 additions & 6 deletions admin/rvy_revision-classic-edit.js

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

77 changes: 77 additions & 0 deletions front_rvy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ class RevisionaryFront {
function __construct() {
global $revisionary;

// This filter may be required in some configurations, but problematic in others
if (!defined('PP_REVISIONS_NO_PAGE_ON_FRONT_FILTER')) {
add_filter("option_page_on_front", [$this, 'fltOptionPageOnFront']);
}

add_action('parse_query', [$this, 'actSetQueriedObject'], 20);
add_action('parse_query', [$this, 'actFlagHomeRevision'], 20);
add_filter('body_class', [$this, 'fltBodyClass'], 20, 2);

add_filter('acf/load_value', [$this, 'fltACFLoadValue'], 10, 3);

if ( ! defined('RVY_CONTENT_ROLES') || !$revisionary->content_roles->is_direct_file_access() ) {
add_filter('posts_request', [$this, 'flt_view_revision'] );
add_action('template_redirect', [$this, 'act_template_redirect'], 5 );
Expand All @@ -27,6 +38,72 @@ function __construct() {
do_action('revisionary_front_init');
}

function fltACFLoadValue($value, $post_id, $field) {
if ((null === $value) && rvy_in_revision_workflow($post_id) && function_exists('acf_get_value')) {

if ($published_post_id = rvy_post_id($post_id)) {

if (($published_post_id != $post_id) && !rvy_in_revision_workflow($published_post_id)) {
return acf_get_value($published_post_id, $field);
}
}
}

return $value;
}

function fltOptionPageOnFront($front_page_id) {
global $post;

// extra caution and perf optimization for front end execution
if (!empty($post) && is_object($post) && rvy_in_revision_workflow($post) && ($post->comment_count == $front_page_id)) {
return $post->ID;
}

return $front_page_id;
}

function fltBodyClass($classes, $css_class) {
if ($this->isHomeRevision()) {
$classes = array_merge(['home'], $classes);
$classes = array_diff($classes, ['blog']);
}

return $classes;
}

function actSetQueriedObject(&$query) {
if ($post_id = rvy_detect_post_id()) {
if (rvy_in_revision_workflow($post_id)) {
$query->queried_object = get_post($post_id);
$query->queried_object_id = $post_id;
}
}
}

function actFlagHomeRevision(&$query) {
if ($this->isHomeRevision()) {
$query->is_home = true;
$query->is_front_page = true;
}
}

private function isHomeRevision() {
if ($post_id = rvy_detect_post_id()) {
if ($published_post_id = rvy_post_id($post_id)) {
if ($published_post_id != $post_id) {
if ( ('page' === get_option( 'show_on_front' ))
&& in_array( get_option( 'page_on_front' ), [$published_post_id, $post_id] )
) {
return true;
}
}
}
}

return false;
}

public function actRevisionPreviewRedirect() {
if (!class_exists('DS_Public_Post_Preview')) {
return;
Expand Down
Binary file modified languages/revisionary-es_ES.mo
Binary file not shown.
Loading

0 comments on commit 031935e

Please sign in to comment.