More work on Publish postbox. Post status tweaks, post date tweaks.

git-svn-id: http://svn.automattic.com/wordpress/trunk@9402 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2008-10-29 19:22:56 +00:00
parent f600722c5a
commit 3a0dc54a26
5 changed files with 74 additions and 13 deletions

View File

@ -95,6 +95,8 @@ if ( 0 != $post->ID ) {
$stamp = __('Published on:<br />%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');
} else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
$stamp = __('Schedule for:<br />%1$s');
} else { // draft, 1 or more saves, date specified
$stamp = __('Publish on:<br />%1$s');
}
@ -106,7 +108,8 @@ if ( 0 != $post->ID ) {
?>
<?php if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
<div class="misc-pub-section curtime">
<span id="timestamp"><?php printf($stamp, $date); ?></span>
<span id="timestamp">
<?php printf($stamp, $date); ?></span>
&nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
<div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
</div>
@ -132,16 +135,14 @@ switch ( $post->post_status ) {
}
?>
</span></b>
<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { ?>
<?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>
<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; ?>" />
<br />
<select name='post_status' id='post_status' tabindex='4'>
<?php
// only show the publish menu item if they are allowed to publish posts or they are allowed to edit this post (accounts for 'edit_published_posts' capability)
if ( $can_publish OR ( $post->post_status == 'publish' AND current_user_can('edit_post', $post->ID) ) ) : ?>
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 ( 'future' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
@ -150,7 +151,7 @@ if ( $can_publish OR ( $post->post_status == 'publish' AND current_user_can('edi
<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
</select>
<br />
<a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
<a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
</div>
@ -171,8 +172,10 @@ if ( $can_publish OR ( $post->post_status == 'publish' AND current_user_can('edi
<div id="minor-publishing-actions">
<?php if ( 'publish' != $post->post_status && 'private' != $post->post_status ) { ?>
<?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 } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
<input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Pending') ); ?>" tabindex="4" class="button button-highlighted" />
<?php } ?>
<?php if ( 'publish' == $post->post_status ) { ?>
@ -197,7 +200,11 @@ if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?>
<?php
if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post->ID ) { ?>
<?php if ( current_user_can('publish_posts') ) : ?>
<input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
<?php if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
<input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Schedule') ?>" />
<?php else : ?>
<input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
<?php endif; ?>
<?php else : ?>
<input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
<?php endif; ?>

View File

@ -2236,6 +2236,12 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
$mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
$ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
$cur_jj = gmdate( 'd', $time_adj );
$cur_mm = gmdate( 'm', $time_adj );
$cur_aa = gmdate( 'Y', $time_adj );
$cur_hh = gmdate( 'H', $time_adj );
$cur_mn = gmdate( 'i', $time_adj );
$month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
for ( $i = 1; $i < 13; $i = $i +1 ) {
$month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
@ -2254,8 +2260,11 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
if ( $multi ) return;
echo "\n\n";
foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit )
foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
$cur_timeunit = 'cur_' . $timeunit;
echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
}
?>
<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />

View File

@ -175,13 +175,36 @@ jQuery(document).ready( function($) {
$('#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 );
}
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 + '<br />' +
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
$('#jj').val() + ', ' +
$('#aa').val() + ' @ ' +
@ -216,7 +239,11 @@ jQuery(document).ready( 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 );
}
return false;
});
@ -225,6 +252,11 @@ jQuery(document).ready( function($) {
$('#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 );
}
return false;
});

View File

@ -210,12 +210,17 @@ table#availablethemes td.bottom {
#misc-publishing-actions {
float: left;
border-right: 1px solid #ddd;
min-height: 70px;
}
#side-sortables #misc-publishing-actions {
max-width: 170px;
}
#side-sortable #minor-publishing-actions {
max-width: 108px;
}
.misc-pub-section {
padding: 6px;
border-bottom: 1px solid #ddd;
@ -226,7 +231,7 @@ table#availablethemes td.bottom {
}
#minor-publishing-actions {
padding: 6px 6px 0 0;
padding: 4px 4px 4px 0;
float: right;
text-align: right;
}

View File

@ -183,8 +183,16 @@ function wp_default_scripts( &$scripts ) {
'separate' => __('Separate tags with commas'),
'cancel' => __('Cancel'),
'edit' => __('Edit'),
'publishOn' => __('Publish on:'),
'publishOnFuture' => __('Schedule for:'),
'publishOnPast' => __('Published on:'),
'showcomm' => __('Show more comments'),
'endcomm' => __('No more comments found.')
'endcomm' => __('No more comments found.'),
'publish' => __('Publish'),
'schedule' => __('Schedule'),
'update' => __('Update Post'),
'savePending' => __('Save Pending'),
'saveDraft' => __('Save Draft')
) );
$scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'postbox', 'settings-box'), '20080925' );
$scripts->localize( 'page', 'postL10n', array(
@ -308,7 +316,7 @@ function wp_default_styles( &$styles ) {
$rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'press-this-ie' );
$styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081029' );
$styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081029b' );
$styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' );
$styles->add( 'ie', '/wp-admin/css/ie.css' );