From 7b09b8e47b2d7e96532051d448f2fc9023dd9ee4 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Wed, 12 Nov 2008 19:31:39 +0000 Subject: [PATCH] Visibility section for the Publish Module for Pages git-svn-id: https://develop.svn.wordpress.org/trunk@9641 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit-form-advanced.php | 2 +- wp-admin/edit-page-form.php | 63 +++++++++++-- wp-admin/js/page.js | 157 +++++++++++++++++++++++--------- wp-includes/script-loader.php | 14 ++- 4 files changed, 177 insertions(+), 59 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index bc902c5c95..064b30aa20 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -165,7 +165,7 @@ if ( !empty( $post->post_password ) ) { $visibility_trans = __('Private'); } elseif ( is_sticky( $post->ID ) ) { $visibility = 'public'; - $visibility_trans = __('Public, sticky'); + $visibility_trans = __('Public, Sticky'); $sticky = 'sticky'; } else { $visibility = 'public'; diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index 728e603165..b48d446bdb 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -85,8 +85,8 @@ function page_submit_meta_box($post) {
-post_status && 'private' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> - +post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> +post_status ) { ?>style="display:none" type="submit" name="save" id="save-post" value="" tabindex="4" class="button button-highlighted" /> post_status && $can_publish ) { ?> @@ -106,8 +106,10 @@ function page_submit_meta_box($post) { post_status ) { - case 'publish': case 'private': + _e('Privately Published'); + break; + case 'publish': _e('Published'); break; case 'future': @@ -123,13 +125,15 @@ switch ( $post->post_status ) { ?> post_status || 'private' == $post->post_status || $can_publish ) { ?> - +post_status ) { ?>style="display:none;" class="edit-post-status hide-if-no-js" tabindex='4'>
+ + + + />
+ />
+
+ />
+ +

+ + +

+
+ + +
+ ID ) { if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date $stamp = __('Scheduled for: %1$s'); - } else if ( 'publish' == $post->post_status ) { // already published + } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published $stamp = __('Published on: %1$s'); } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified $stamp = __('Publish immediately'); @@ -188,17 +227,21 @@ if ( ( 'edit' == $action ) && current_user_can('delete_page', $post->ID) ) { ?>
post_status, array('publish', 'future') ) || 0 == $post->ID ) { ?> +if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?> post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> + + + +
@@ -224,7 +267,7 @@ function page_password_meta_box($post){

-

+

diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js index 368555400b..6af8a4d74b 100644 --- a/wp-admin/js/page.js +++ b/wp-admin/js/page.js @@ -12,6 +12,116 @@ jQuery(document).ready( function($) { var stamp = $('#timestamp').html(); + var visibility = $('#post-visibility-display').html(); + + function updateVisibility() { + if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { + $('#sticky').attr('checked', false); + $('#sticky-span').hide(); + } else { + $('#sticky-span').show(); + } + if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) { + $('#password-span').hide(); + } else { + $('#password-span').show(); + } + } + + function updateText() { + var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val()); + var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val()); + var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val()); + if ( attemptedDate > currentDate ) { + var publishOn = postL10n.publishOnFuture; + $('#publish').val( postL10n.schedule ); + } else if ( $('#original_post_status').val() != 'publish' ) { + var publishOn = postL10n.publishOn; + $('#publish').val( postL10n.publish ); + } else { + var publishOn = postL10n.publishOnPast; + $('#publish').val( postL10n.update ); + } + if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack + $('#timestamp').html(stamp); + } else { + $('#timestamp').html( + publishOn + ' ' + + $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + + $('#jj').val() + ', ' + + $('#aa').val() + ' @ ' + + $('#hh').val() + ':' + + $('#mn').val() + ' ' + ); + } + + if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) { + $('#publish').val( postL10n.update ); + if ( $('#post_status option[value=publish]').length == 0 ) { + $('#post_status').append(''); + } + $('#post_status option[value=publish]').html( postL10n.privatelyPublished ); + $('#post_status option[value=publish]').attr('selected', true); + $('.edit-post-status').hide(); + } else { + if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { + if ( $('#post_status option[value=publish]').length != 0 ) { + $('#post_status option[value=publish]').remove(); + $('#post_status').val($('#hidden_post_status').val()); + } + } else { + $('#post_status option[value=publish]').html( postL10n.published ); + } + $('.edit-post-status').show(); + } + $('#post-status-display').html($('#post_status :selected').text()); + if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) { + $('#save-post').hide(); + } else { + $('#save-post').show(); + if ( $('#post_status :selected').val() == 'pending' ) { + $('#save-post').show().val( postL10n.savePending ); + } else { + $('#save-post').show().val( postL10n.saveDraft ); + } + } + } + + $('.edit-visibility').click(function () { + if ($('#post-visibility-select').is(":hidden")) { + updateVisibility(); + $('#post-visibility-select').slideDown("normal"); + $('.edit-visibility').hide(); + } + return false; + }); + + $('.cancel-post-visibility').click(function () { + $('#post-visibility-select').slideUp("normal"); + $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); + $('#post_password').val($('#hidden_post_password').val()); + $('#post-visibility-display').html(visibility); + $('.edit-visibility').show(); + updateText(); + return false; + }); + + $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels + $('#post-visibility-select').slideUp("normal"); + $('.edit-visibility').show(); + updateText(); + + $('#post-visibility-display').html( + postL10n[$('#post-visibility-select input:radio:checked').val()] + ); + + return false; + }); + + $('#post-visibility-select input:radio').change(function() { + updateVisibility(); + }); + $('.edit-timestamp').click(function () { if ($('#timestampdiv').is(":hidden")) { $('#timestampdiv').slideDown("normal"); @@ -28,45 +138,16 @@ jQuery(document).ready( function($) { $('#aa').val($('#hidden_aa').val()); $('#hh').val($('#hidden_hh').val()); $('#mn').val($('#hidden_mn').val()); - $('#timestamp').html(stamp); $('.edit-timestamp').show(); - var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val() ); - var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() ); - if ( attemptedDate > currentDate ) { - $('#publish').val( postL10n.schedule ); - } else if ( $('#original_post_status').val() != 'publish' ) { - $('#publish').val( postL10n.publish ); - } else { - $('#publish').val( postL10n.update ); - } - + updateText(); return false; }); $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels $('#timestampdiv').slideUp("normal"); $('.edit-timestamp').show(); - var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val() ); - var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() ); - if ( attemptedDate > currentDate ) { - var publishOn = postL10n.publishOnFuture; - $('#publish').val( postL10n.schedule ); - } else if ( $('#original_post_status').val() != 'publish' ) { - var publishOn = postL10n.publishOn; - $('#publish').val( postL10n.publish ); - } else { - var publishOn = postL10n.publishOnPast; - $('#publish').val( postL10n.update ); - } - $('#timestamp').html( - publishOn + ' ' + - $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + - $('#jj').val() + ', ' + - $('#aa').val() + ' @ ' + - $('#hh').val() + ':' + - $('#mn').val() + ' ' - ); + updateText(); return false; }); @@ -82,27 +163,17 @@ jQuery(document).ready( function($) { $('.save-post-status').click(function() { $('#post-status-select').slideUp("normal"); - $('#post-status-display').html($('#post_status :selected').text()); $('.edit-post-status').show(); - if ( $('#post_status :selected').val() == 'pending' ) { - $('#save-post').val( postL10n.savePending ); - } else { - $('#save-post').val( postL10n.saveDraft ); - } + updateText(); return false; }); $('.cancel-post-status').click(function() { $('#post-status-select').slideUp("normal"); $('#post_status').val($('#hidden_post_status').val()); - $('#post-status-display').html($('#post_status :selected').text()); $('.edit-post-status').show(); - if ( $('#post_status :selected').val() == 'pending' ) { - $('#save-post').val( postL10n.savePending ); - } else { - $('#save-post').val( postL10n.saveDraft ); - } + updateText(); return false; }); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index ab0c5d0ac8..b312408de8 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -194,13 +194,12 @@ function wp_default_scripts( &$scripts ) { 'saveDraft' => __('Save Draft'), 'private' => __('Private'), 'public' => __('Public'), - 'publicSticky' => __('Public, sticky'), - 'password' => __('Password protected'), + 'publicSticky' => __('Public, Sticky'), + 'password' => __('Password Protected'), 'privatelyPublished' => __('Privately Published'), 'published' => __('Published') - ) ); - $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081107' ); + $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081112' ); $scripts->localize( 'page', 'postL10n', array( 'cancel' => __('Cancel'), 'edit' => __('Edit'), @@ -213,7 +212,12 @@ function wp_default_scripts( &$scripts ) { 'schedule' => __('Schedule'), 'update' => __('Update Page'), 'savePending' => __('Save as Pending'), - 'saveDraft' => __('Save Draft') + 'saveDraft' => __('Save Draft'), + 'private' => __('Private'), + 'public' => __('Public'), + 'password' => __('Password Protected'), + 'privatelyPublished' => __('Privately Published'), + 'published' => __('Published') ) ); $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080925' ); $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081103' );