mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-12 13:44:21 +01:00
Visibility section for the Publish Module for Pages
git-svn-id: http://svn.automattic.com/wordpress/trunk@9641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
16ccb3f181
commit
41b43c1d03
@ -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';
|
||||
|
@ -85,8 +85,8 @@ function page_submit_meta_box($post) {
|
||||
</div>
|
||||
|
||||
<div id="save-action">
|
||||
<?php if ( 'publish' != $post->post_status && 'private' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
|
||||
<input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Draft') ); ?>" tabindex="4" class="button button-highlighted" />
|
||||
<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
|
||||
<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Draft') ); ?>" tabindex="4" class="button button-highlighted" />
|
||||
<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
|
||||
<input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save as Pending') ); ?>" tabindex="4" class="button button-highlighted" />
|
||||
<?php } ?>
|
||||
@ -106,8 +106,10 @@ function page_submit_meta_box($post) {
|
||||
<b><span id="post-status-display">
|
||||
<?php
|
||||
switch ( $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 ) {
|
||||
?>
|
||||
</span></b>
|
||||
<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
|
||||
<a href="#post_status" class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
|
||||
<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
|
||||
|
||||
<div id="post-status-select" class="hide-if-js">
|
||||
<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo $post->post_status; ?>" />
|
||||
<select name='post_status' id='post_status' tabindex='4'>
|
||||
<?php if ( $post->post_status == 'publish' ) : ?>
|
||||
<option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
|
||||
<?php if ( 'publish' == $post->post_status ) : ?>
|
||||
<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
|
||||
<?php elseif ( 'private' == $post->post_status ) : ?>
|
||||
<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
|
||||
<?php elseif ( 'future' == $post->post_status ) : ?>
|
||||
<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
|
||||
<?php endif; ?>
|
||||
@ -144,12 +148,47 @@ switch ( $post->post_status ) {
|
||||
<?php } ?>
|
||||
</div><?php // /misc-pub-section ?>
|
||||
|
||||
<div class="misc-pub-section " id="visibility">
|
||||
<?php _e('Visibility:'); ?> <b><span id="post-visibility-display"><?php
|
||||
|
||||
if ( !empty( $post->post_password ) ) {
|
||||
$visibility = 'password';
|
||||
$visibility_trans = __('Password protected');
|
||||
} elseif ( 'private' == $post->post_status ) {
|
||||
$visibility = 'private';
|
||||
$visibility_trans = __('Private');
|
||||
} else {
|
||||
$visibility = 'public';
|
||||
$visibility_trans = __('Public');
|
||||
}
|
||||
|
||||
?><?php echo wp_specialchars( $visibility_trans ); ?></span></b> <?php if ( $can_publish ) { ?> <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
|
||||
|
||||
<div id="post-visibility-select" class="hide-if-js">
|
||||
<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo attribute_escape($post->post_password); ?>" />
|
||||
<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo attribute_escape( $visibility ); ?>" />
|
||||
|
||||
|
||||
<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
|
||||
<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
|
||||
<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo attribute_escape($post->post_password); ?>" /><br /></span>
|
||||
<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
|
||||
|
||||
<p>
|
||||
<a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
|
||||
<a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div><?php // /misc-pub-section ?>
|
||||
|
||||
<?php
|
||||
$datef = _c( 'M j, Y @ G:i|Publish box date format');
|
||||
if ( 0 != $post->ID ) {
|
||||
if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
|
||||
$stamp = __('Scheduled for: <b>%1$s</b>');
|
||||
} else if ( 'publish' == $post->post_status ) { // already published
|
||||
} else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
|
||||
$stamp = __('Published on: <b>%1$s</b>');
|
||||
} else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
|
||||
$stamp = __('Publish <b>immediately</b>');
|
||||
@ -188,17 +227,21 @@ if ( ( 'edit' == $action ) && current_user_can('delete_page', $post->ID) ) { ?>
|
||||
|
||||
<div id="publishing-action">
|
||||
<?php
|
||||
if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post->ID ) { ?>
|
||||
if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?>
|
||||
<?php if ( current_user_can('publish_posts') ) : ?>
|
||||
<?php if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Schedule') ?>" />
|
||||
<input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Schedule') ?>" />
|
||||
<?php else : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Publish') ?>" />
|
||||
<input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Submit for Review') ?>" />
|
||||
<input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
|
||||
<?php endif; ?>
|
||||
<?php } else { ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Update Page') ?>" />
|
||||
<input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Update Page') ?>" />
|
||||
<?php } ?>
|
||||
</div>
|
||||
@ -224,7 +267,7 @@ function page_password_meta_box($post){
|
||||
<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this page and its comments.'); ?></p>
|
||||
<?php
|
||||
}
|
||||
add_meta_box('pagepassworddiv', __('Privacy Options'), 'page_password_meta_box', 'page', 'side', 'core');
|
||||
// add_meta_box('pagepassworddiv', __('Privacy Options'), 'page_password_meta_box', 'page', 'side', 'core');
|
||||
|
||||
/**
|
||||
* Display page parent form fields.
|
||||
@ -378,7 +421,7 @@ require_once('admin-header.php');
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php echo wp_specialchars( $title ); ?></h2>
|
||||
<h2><?php echo wp_specialchars( $title ); ?></h2>
|
||||
|
||||
<form name="post" action="page.php" method="post" id="post">
|
||||
<?php if ( $notice ) : ?>
|
||||
|
@ -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 + ' <b>' +
|
||||
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
|
||||
$('#jj').val() + ', ' +
|
||||
$('#aa').val() + ' @ ' +
|
||||
$('#hh').val() + ':' +
|
||||
$('#mn').val() + '</b> '
|
||||
);
|
||||
}
|
||||
|
||||
if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
|
||||
$('#publish').val( postL10n.update );
|
||||
if ( $('#post_status option[value=publish]').length == 0 ) {
|
||||
$('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
|
||||
}
|
||||
$('#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 + ' <b>' +
|
||||
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
|
||||
$('#jj').val() + ', ' +
|
||||
$('#aa').val() + ' @ ' +
|
||||
$('#hh').val() + ':' +
|
||||
$('#mn').val() + '</b> '
|
||||
);
|
||||
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;
|
||||
});
|
||||
|
||||
|
@ -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' );
|
||||
|
Loading…
Reference in New Issue
Block a user