Disable "Visibility" placeholder for now. Propagate new Publish box formatting and functionality to Edit Page form.

git-svn-id: http://svn.automattic.com/wordpress/trunk@9429 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2008-10-31 05:38:31 +00:00
parent 1cb2fe068c
commit 8be1ba6191
5 changed files with 153 additions and 93 deletions

View File

@ -82,12 +82,12 @@ function post_submit_meta_box($post) {
<?php if ( $can_publish && current_user_can( 'edit_others_posts' ) ) { ?> <?php if ( $can_publish && current_user_can( 'edit_others_posts' ) ) { ?>
<div class="misc-pub-section" id="sticky-checkbox"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID), true); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick to front page') ?></label></div> <div class="misc-pub-section" id="sticky-checkbox"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID), true); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick to front page') ?></label></div>
<?php } ?> <?php } ?>
<!--
<div class="misc-pub-section misc-pub-section-1-last" id="visibility"> <div class="misc-pub-section misc-pub-section-1-last" id="visibility">
<?php _e('Visibility:'); ?> <b><?php _e('Public'); // TODO: dropdown ?></b> <?php _e('Visibility:'); ?> <b><?php _e('Public'); // TODO: dropdown ?></b>
</div> </div>
-->
</div> </div>
<div id="misc-pub-block-2"> <div id="misc-pub-block-2">
<?php <?php
$datef = _c( 'M j, Y \a\t G:i|Publish box date format'); $datef = _c( 'M j, Y \a\t G:i|Publish box date format');
@ -144,13 +144,11 @@ switch ( $post->post_status ) {
<div id="post-status-select" class="hide-if-js"> <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; ?>" /> <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'> <select name='post_status' id='post_status' tabindex='4'>
<?php <?php if ( $post->post_status == 'publish' ) : ?>
if ( $post->post_status == 'publish' ) : ?>
<option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option> <option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
<?php if ( 'future' == $post->post_status ) : ?> <?php elseif ( 'future' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
<?php endif; ?> <?php endif; ?>
<?php endif; ?>
<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> <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> <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
</select> </select>

View File

@ -63,10 +63,53 @@ function page_submit_meta_box($post) {
?> ?>
<div class="submitbox" id="submitpage"> <div class="submitbox" id="submitpage">
<div class="inside-submitbox"> <div id="minor-publishing">
<div id="misc-publishing-actions">
<div class="insidebox"><label for='post_status'><?php _e('This page is') ?></label> <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
<strong><span id="post-status-display"> <div style="display:none;">
<input type="submit" name="save" value="<?php echo attribute_escape( __('Save') ); ?>" />
</div>
<div id="misc-pub-block-1">
<!--
<div class="misc-pub-section misc-pub-section-1-last" id="visibility">
<?php _e('Visibility:'); ?> <b><?php _e('Public'); // TODO: dropdown ?></b>
</div>
-->
</div>
<div id="misc-pub-block-2">
<?php
$datef = _c( 'M j, Y \a\t 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:<br />%1$s');
} else if ( 'publish' == $post->post_status ) { // already published
$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');
}
$date = date_i18n( $datef, strtotime( $post->post_date ) );
} else { // draft (no saves, and thus no date specified)
$stamp = __('Publish immediately');
$date = date_i18n( $datef, strtotime( current_time('mysql') ) );
}
?>
<?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>
&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>
<?php endif; ?>
<div class="misc-pub-section misc-pub-section-2-last"><label for="post_status"><?php _e('Status:') ?></label>
<b><span id="post-status-display">
<?php <?php
switch ( $post->post_status ) { switch ( $post->post_status ) {
case 'publish': case 'publish':
@ -80,103 +123,80 @@ switch ( $post->post_status ) {
_e('Pending Review'); _e('Pending Review');
break; break;
case 'draft': case 'draft':
_e('Unpublished'); _e('Draft');
break; break;
} }
?> ?>
</span></strong> </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="#edit_post_status" class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> <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"> <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; ?>" /> <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo $post->post_status; ?>" />
<?php _e('Change page status'); ?><br />
<select name='post_status' id='post_status' tabindex='4'> <select name='post_status' id='post_status' tabindex='4'>
<?php <?php if ( $post->post_status == 'publish' ) : ?>
// 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_page', $post->ID) ) ) : ?>
<option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option> <option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
<?php if ( 'future' == $post->post_status ) : ?> <?php elseif ( 'future' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
<?php endif; ?> <?php endif; ?>
<?php endif; ?>
<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> <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('Unpublished') ?></option> <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
</select> </select>
<br />
<a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> <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> <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
</div> </div>
</div>
<?php } else { ?>
</div>
<?php if ( $can_publish && 'pending' != $post->post_status ) { ?>
<div class="insidebox"><input name="pending" type="submit" class="button" id="pending" tabindex="6" accesskey="r" value="<?php _e('Submit for Review') ?>" /></div>
<?php } ?>
<?php } ?> <?php } ?>
</div>
<?php if ( ('edit' == $action) && current_user_can('delete_page', $post->ID) ) { ?> </div>
<div class="insidebox" id="deletebutton"><a class="submitdelete" href="<?php echo wp_nonce_url("page.php?action=delete&amp;post=$post->ID", 'delete-page_' . $post->ID); ?>" onclick="if ( confirm('<?php echo js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete&nbsp;page'); ?></a></div>
<?php } ?>
<?php
if ( 0 != $post->ID ) {
if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
$stamp = __('Scheduled for: %1$s at %2$s');
} else if ( 'publish' == $post->post_status ) { // already published
$stamp = __('Published on: %1$s at %2$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 { // draft, 1 or more saves, date specified
$stamp = __('Publish on: %1$s at %2$s');
}
$date = mysql2date(get_option('date_format'), $post->post_date);
$time = mysql2date(get_option('time_format'), $post->post_date);
} else { // draft (no saves, and thus no date specified)
$stamp = __('Publish immediately');
$date = mysql2date(get_option('date_format'), current_time('mysql'));
$time = mysql2date(get_option('time_format'), current_time('mysql'));
}
?>
<?php if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
<div class="insidebox curtime"><span id="timestamp"><?php printf($stamp, $date, $time); ?></span>
&nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a></p>
<div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div></div>
<?php endif; ?>
</div> </div>
<p class="submit"> <div id="minor-publishing-actions">
<?php do_action('page_submitbox_start'); ?>
<?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 ) { ?>
$savebtn = attribute_escape( __('Save') ); <input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Draft') ); ?>" tabindex="4" class="button button-highlighted" />
else <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
$savebtn = attribute_escape( __('Save Draft') ); <input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Pending') ); ?>" tabindex="4" class="button button-highlighted" />
?> <?php } ?>
<input type="submit" name="save" id="save-post" value="<?php echo $savebtn; ?>" tabindex="4" class="button button-highlighted" />
<?php if ( 'publish' == $post->post_status ) { ?> <?php if ( 'publish' == $post->post_status ) { ?>
<a class="preview button" href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank" tabindex="4"><?php _e('View this Page'); ?></a> <a class="preview button" href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank" tabindex="4"><?php _e('View Post'); ?></a>
<?php } else { ?> <?php } else { ?>
<a class="preview button" href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" target="_blank" tabindex="4"><?php _e('Preview'); ?></a> <a class="preview button" href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" target="_blank" tabindex="4"><?php _e('Preview'); ?></a>
<?php } ?> <?php } ?>
</div>
<?php
if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post->ID ) { ?>
<?php if ( current_user_can('publish_pages') ) : ?>
<input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
<?php else : ?>
<input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
<?php endif; ?>
<?php } ?>
</p>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<div id="major-publishing-actions">
<?php do_action('post_submitbox_start'); ?>
<div id="delete-action">
<?php
if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?>
<a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID); ?>" onclick="if ( confirm('<?php echo js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
<?php } ?>
</div>
<div id="publishing-action">
<?php
if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post->ID ) { ?>
<?php if ( current_user_can('publish_posts') ) : ?>
<?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; ?>
<?php } else { ?>
<input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Update Page') ?>" />
<?php } ?>
</div>
<div class="clear"></div>
</div>
</div>
<?php <?php
} }
add_meta_box('pagesubmitdiv', __('Publish'), 'page_submit_meta_box', 'page', 'side', 'core'); add_meta_box('pagesubmitdiv', __('Publish'), 'page_submit_meta_box', 'page', 'side', 'core');

View File

@ -31,13 +31,36 @@ jQuery(document).ready( function($) {
$('#timestamp').html(stamp); $('#timestamp').html(stamp);
$('.edit-timestamp').show(); $('.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; return false;
}); });
$('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
$('#timestampdiv').slideUp("normal"); $('#timestampdiv').slideUp("normal");
$('.edit-timestamp').show(); $('.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( $('#timestamp').html(
publishOn + '<br />' +
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
$('#jj').val() + ', ' + $('#jj').val() + ', ' +
$('#aa').val() + ' @ ' + $('#aa').val() + ' @ ' +
@ -61,7 +84,11 @@ jQuery(document).ready( function($) {
$('#post-status-select').slideUp("normal"); $('#post-status-select').slideUp("normal");
$('#post-status-display').html($('#post_status :selected').text()); $('#post-status-display').html($('#post_status :selected').text());
$('.edit-post-status').show(); $('.edit-post-status').show();
if ( $('#post_status :selected').val() == 'pending' ) {
$('#save-post').val( postL10n.savePending );
} else {
$('#save-post').val( postL10n.saveDraft );
}
return false; return false;
}); });
@ -70,6 +97,11 @@ jQuery(document).ready( function($) {
$('#post_status').val($('#hidden_post_status').val()); $('#post_status').val($('#hidden_post_status').val());
$('#post-status-display').html($('#post_status :selected').text()); $('#post-status-display').html($('#post_status :selected').text());
$('.edit-post-status').show(); $('.edit-post-status').show();
if ( $('#post_status :selected').val() == 'pending' ) {
$('#save-post').val( postL10n.savePending );
} else {
$('#save-post').val( postL10n.saveDraft );
}
return false; return false;
}); });

View File

@ -215,17 +215,6 @@ jQuery(document).ready( function($) {
return false; return false;
}); });
// Custom Fields
jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
if ( jQuery.isFunction( autosave_update_post_ID ) ) {
autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
}
}, addBefore: function( s ) {
s.data += '&post_id=' + jQuery('#post_ID').val();
return s;
}
});
$('.edit-post-status').click(function() { $('.edit-post-status').click(function() {
if ($('#post-status-select').is(":hidden")) { if ($('#post-status-select').is(":hidden")) {
$('#post-status-select').slideDown("normal"); $('#post-status-select').slideDown("normal");
@ -260,6 +249,17 @@ jQuery(document).ready( function($) {
return false; return false;
}); });
// Custom Fields
jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
if ( jQuery.isFunction( autosave_update_post_ID ) ) {
autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
}
}, addBefore: function( s ) {
s.data += '&post_id=' + jQuery('#post_ID').val();
return s;
}
});
}); });
(function($){ (function($){

View File

@ -199,6 +199,16 @@ function wp_default_scripts( &$scripts ) {
$scripts->localize( 'page', 'postL10n', array( $scripts->localize( 'page', 'postL10n', array(
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
'edit' => __('Edit'), 'edit' => __('Edit'),
'publishOn' => __('Publish on:'),
'publishOnFuture' => __('Schedule for:'),
'publishOnPast' => __('Published on:'),
'showcomm' => __('Show more comments'),
'endcomm' => __('No more comments found.'),
'publish' => __('Publish'),
'schedule' => __('Schedule'),
'update' => __('Update Page'),
'savePending' => __('Save Pending'),
'saveDraft' => __('Save Draft')
) ); ) );
$scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox', 'settings-box'), '20080925' ); $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox', 'settings-box'), '20080925' );
$scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20080219' ); $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20080219' );