diff --git a/src/js/_enqueues/admin/post.js b/src/js/_enqueues/admin/post.js index 445e79d8a6f05..f812b1b5e57b7 100644 --- a/src/js/_enqueues/admin/post.js +++ b/src/js/_enqueues/admin/post.js @@ -308,6 +308,7 @@ jQuery( function($) { postId = $('#post_ID').val() || 0, $submitpost = $('#submitpost'), releaseLock = true, + statusBeforePrivate = null, $postVisibilitySelect = $('#post-visibility-select'), $timestampdiv = $('#timestampdiv'), $postStatusSelect = $('#post-status-select'), @@ -757,7 +758,7 @@ jQuery( function($) { if ( ! $timestampdiv.length ) return true; - var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'), + var attemptedDate, originalDate, currentDate, publishOn, selectedPostStatus, postStatus = $('#post_status'), optPublish = $('option[value="publish"]', postStatus), aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(); @@ -823,15 +824,23 @@ jQuery( function($) { // Add "privately published" to post status when applies. if ( $postVisibilitySelect.find('input:radio:checked').val() == 'private' ) { $('#publish').val( __( 'Update' ) ); + if ( postStatus.val() !== 'publish' ) { + statusBeforePrivate = postStatus.val(); + } if ( 0 === optPublish.length ) { - postStatus.append(''); + postStatus.append(''); } else { optPublish.html( __( 'Privately Published' ) ); } $('option[value="publish"]', postStatus).prop('selected', true); $('#misc-publishing-actions .edit-post-status').hide(); } else { - if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { + if ( null !== statusBeforePrivate ) { + optPublish.html( __( 'Published' ) ); + optPublish.filter('[data-private-status-option]').remove(); + postStatus.val( statusBeforePrivate ); + statusBeforePrivate = null; + } else if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { if ( optPublish.length ) { optPublish.remove(); postStatus.val($('#hidden_post_status').val()); @@ -843,22 +852,26 @@ jQuery( function($) { $('#misc-publishing-actions .edit-post-status').show(); } + selectedPostStatus = $('option:selected', postStatus); + // Update "Status:" to currently selected status. $('#post-status-display').text( // Remove any potential tags from post status text. - wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() ) + wp.sanitize.stripTagsAndEncodeText( selectedPostStatus.text() ) ); // Show or hide the "Save Draft" button. if ( - $('option:selected', postStatus).val() == 'private' || - $('option:selected', postStatus).val() == 'publish' + selectedPostStatus.val() == 'private' || + selectedPostStatus.val() == 'publish' ) { $('#save-post').hide(); } else { $('#save-post').show(); - if ( $('option:selected', postStatus).val() == 'pending' ) { + if ( selectedPostStatus.val() == 'pending' ) { $('#save-post').show().val( __( 'Save as Pending' ) ); + } else if ( selectedPostStatus.attr( 'data-save-text' ) ) { + $('#save-post').show().val( selectedPostStatus.attr( 'data-save-text' ) ); } else { $('#save-post').show().val( __( 'Save Draft' ) ); } diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 535a00cd3fe94..1c4e8aabc0916 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -30,10 +30,11 @@ function post_submit_meta_box( $post, $args = array() ) { global $action; - $post_id = (int) $post->ID; - $post_type = $post->post_type; - $post_type_object = get_post_type_object( $post_type ); - $can_publish = current_user_can( $post_type_object->cap->publish_posts ); + $post_id = (int) $post->ID; + $post_type = $post->post_type; + $post_type_object = get_post_type_object( $post_type ); + $post_status_object = get_post_status_object( $post->post_status ); + $can_publish = current_user_can( $post_type_object->cap->publish_posts ); ?>