Make WordPress Core

Ticket #12567: post-submit-hooks.25279.diff

File post-submit-hooks.25279.diff, 24.9 KB (added by ragulka, 11 years ago)

Patch from duplicate ticket

  • wp-admin/includes/meta-boxes.php

    diff --git wp-admin/includes/meta-boxes.php wp-admin/includes/meta-boxes.php
    index 7f13f54..aa2daa8 100644
    function post_submit_meta_box($post, $args = array() ) { 
    1818?>
    1919<div class="submitbox" id="submitpost">
    2020
    21 <div id="minor-publishing">
     21        <div id="minor-publishing">
     22                <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
     23                <div style="display:none;">
     24                <?php submit_button( __( 'Save' ), 'button', 'save' ); ?>
     25                </div>
    2226
    23 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
    24 <div style="display:none;">
    25 <?php submit_button( __( 'Save' ), 'button', 'save' ); ?>
    26 </div>
     27                <div id="minor-publishing-actions">
     28                <?php do_action( 'post_submitbox_minor_actions', $post_type, $post_type_object, $can_publish, $args ); ?>
     29                <div class="clear"></div>
     30                </div><!-- #minor-publishing-actions -->
    2731
    28 <div id="minor-publishing-actions">
    29 <div id="save-action">
    30 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
    31 <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button" />
    32 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
    33 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" class="button" />
    34 <?php } ?>
    35 <span class="spinner"></span>
     32                <div id="misc-publishing-actions">
     33                <?php do_action( 'post_submitbox_misc_actions', $post_type, $post_type_object, $can_publish, $args ); ?>
     34                </div>
     35                <div class="clear"></div>
     36        </div>
     37
     38        <div id="major-publishing-actions">
     39                <?php do_action( 'post_submitbox_start', $post_type, $post_type_object, $can_publish, $args ); ?>
     40                <div class="clear"></div>
     41        </div>
    3642</div>
    37 <?php if ( $post_type_object->public ) : ?>
    38 <div id="preview-action">
     43
    3944<?php
    40 if ( 'publish' == $post->post_status ) {
    41         $preview_link = esc_url( get_permalink( $post->ID ) );
    42         $preview_button = __( 'Preview Changes' );
    43 } else {
    44         $preview_link = set_url_scheme( get_permalink( $post->ID ) );
    45         $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) );
    46         $preview_button = __( 'Preview' );
    4745}
    48 ?>
    49 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview"><?php echo $preview_button; ?></a>
    50 <input type="hidden" name="wp-preview" id="wp-preview" value="" />
    51 </div>
    52 <?php endif; // public post type ?>
    53 <div class="clear"></div>
    54 </div><!-- #minor-publishing-actions -->
    5546
    56 <div id="misc-publishing-actions">
     47/**
     48 * Add post save minor publishing action.
     49 *
     50 * @param string $post_type
     51 * @param object $post_type_object
     52 * @param bool $can_publish
     53 */
     54function post_submitbox_minor_save_action( $post_type, $post_type_object, $can_publish ) {
     55        global $post;
    5756
    58 <div class="misc-pub-section misc-pub-post-status"><label for="post_status"><?php _e('Status:') ?></label>
    59 <span id="post-status-display">
    60 <?php
    61 switch ( $post->post_status ) {
    62         case 'private':
    63                 _e('Privately Published');
    64                 break;
    65         case 'publish':
    66                 _e('Published');
    67                 break;
    68         case 'future':
    69                 _e('Scheduled');
    70                 break;
    71         case 'pending':
    72                 _e('Pending Review');
    73                 break;
    74         case 'draft':
    75         case 'auto-draft':
    76                 _e('Draft');
    77                 break;
     57        ?>
     58        <div id="save-action">
     59        <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
     60        <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button" />
     61        <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
     62        <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" class="button" />
     63        <?php } ?>
     64        <span class="spinner"></span>
     65        </div>
     66        <?php
    7867}
    79 ?>
    80 </span>
    81 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
    82 <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><?php _e('Edit') ?></a>
    83 
    84 <div id="post-status-select" class="hide-if-js">
    85 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" />
    86 <select name='post_status' id='post_status'>
    87 <?php if ( 'publish' == $post->post_status ) : ?>
    88 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
    89 <?php elseif ( 'private' == $post->post_status ) : ?>
    90 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
    91 <?php elseif ( 'future' == $post->post_status ) : ?>
    92 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
    93 <?php endif; ?>
    94 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
    95 <?php if ( 'auto-draft' == $post->post_status ) : ?>
    96 <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option>
    97 <?php else : ?>
    98 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
    99 <?php endif; ?>
    100 </select>
    101  <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
    102  <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
    103 </div>
     68add_action( 'post_submitbox_minor_actions', 'post_submitbox_minor_save_action', 10, 3 );
    10469
    105 <?php } ?>
    106 </div><!-- .misc-pub-section -->
    107 
    108 <div class="misc-pub-section misc-pub-visibility" id="visibility">
    109 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
    110 
    111 if ( 'private' == $post->post_status ) {
    112         $post->post_password = '';
    113         $visibility = 'private';
    114         $visibility_trans = __('Private');
    115 } elseif ( !empty( $post->post_password ) ) {
    116         $visibility = 'password';
    117         $visibility_trans = __('Password protected');
    118 } elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
    119         $visibility = 'public';
    120         $visibility_trans = __('Public, Sticky');
    121 } else {
    122         $visibility = 'public';
    123         $visibility_trans = __('Public');
     70/**
     71 * Add post preview minor publishing action.
     72 *
     73 * @param string $post_type
     74 * @param object $post_type_object
     75 * @param bool $can_publish
     76 */
     77function post_submitbox_minor_preview_action( $post_type, $post_type_object, $can_publish ) {
     78        global $post;
     79
     80        if ( $post_type_object->public ) : ?>
     81        <div id="preview-action">
     82        <?php
     83        if ( 'publish' == $post->post_status ) {
     84                $preview_link = esc_url( get_permalink( $post->ID ) );
     85                $preview_button = __( 'Preview Changes' );
     86        } else {
     87                $preview_link = set_url_scheme( get_permalink( $post->ID ) );
     88                $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) );
     89                $preview_button = __( 'Preview' );
     90        }
     91        ?>
     92        <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview"><?php echo $preview_button; ?></a>
     93        <input type="hidden" name="wp-preview" id="wp-preview" value="" />
     94        </div>
     95        <?php endif;
    12496}
     97add_action( 'post_submitbox_minor_actions', 'post_submitbox_minor_preview_action', 10, 3 );
    12598
    126 echo esc_html( $visibility_trans ); ?></span>
    127 <?php if ( $can_publish ) { ?>
    128 <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
     99/**
     100 * Add post status misc publishing action.
     101 *
     102 * @param string $post_type
     103 * @param object $post_type_object
     104 * @param bool $can_publish
     105 */
     106function post_submitbox_misc_post_status_action( $post_type, $post_type_object, $can_publish ) {
     107        global $post;
     108        ?>
     109        <div class="misc-pub-section misc-pub-post-status"><label for="post_status"><?php _e('Status:') ?></label>
     110        <span id="post-status-display">
     111        <?php
     112        switch ( $post->post_status ) {
     113                case 'private':
     114                        _e('Privately Published');
     115                        break;
     116                case 'publish':
     117                        _e('Published');
     118                        break;
     119                case 'future':
     120                        _e('Scheduled');
     121                        break;
     122                case 'pending':
     123                        _e('Pending Review');
     124                        break;
     125                case 'draft':
     126                case 'auto-draft':
     127                        _e('Draft');
     128                        break;
     129        }
     130        ?>
     131        </span>
     132        <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
     133        <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><?php _e('Edit') ?></a>
     134
     135        <div id="post-status-select" class="hide-if-js">
     136        <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" />
     137        <select name='post_status' id='post_status'>
     138        <?php if ( 'publish' == $post->post_status ) : ?>
     139        <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
     140        <?php elseif ( 'private' == $post->post_status ) : ?>
     141        <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
     142        <?php elseif ( 'future' == $post->post_status ) : ?>
     143        <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
     144        <?php endif; ?>
     145        <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
     146        <?php if ( 'auto-draft' == $post->post_status ) : ?>
     147        <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option>
     148        <?php else : ?>
     149        <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
     150        <?php endif; ?>
     151        </select>
     152         <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
     153         <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
     154        </div>
    129155
    130 <div id="post-visibility-select" class="hide-if-js">
    131 <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
    132 <?php if ($post_type == 'post'): ?>
    133 <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
    134 <?php endif; ?>
    135 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
    136 <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 />
    137 <?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?>
    138 <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span>
    139 <?php endif; ?>
    140 <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 />
    141 <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>"  maxlength="20" /><br /></span>
    142 <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 />
     156        <?php } ?>
     157        </div><!-- .misc-pub-section -->
     158        <?php
     159}
     160add_action( 'post_submitbox_misc_actions', 'post_submitbox_misc_post_status_action', 10, 3 );
    143161
    144 <p>
    145  <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
    146  <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
    147 </p>
    148 </div>
    149 <?php } ?>
     162/**
     163 * Add post visibility misc publishing action.
     164 *
     165 * @param string $post_type
     166 * @param object $post_type_object
     167 * @param bool $can_publish
     168 */
     169function post_submitbox_misc_visibility_action( $post_type, $post_type_object, $can_publish ) {
     170        global $post;
     171        ?>
     172        <div class="misc-pub-section misc-pub-visibility" id="visibility">
     173        <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
     174
     175        if ( 'private' == $post->post_status ) {
     176                $post->post_password = '';
     177                $visibility = 'private';
     178                $visibility_trans = __('Private');
     179        } elseif ( !empty( $post->post_password ) ) {
     180                $visibility = 'password';
     181                $visibility_trans = __('Password protected');
     182        } elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
     183                $visibility = 'public';
     184                $visibility_trans = __('Public, Sticky');
     185        } else {
     186                $visibility = 'public';
     187                $visibility_trans = __('Public');
     188        }
    150189
    151 </div><!-- .misc-pub-section -->
     190        echo esc_html( $visibility_trans ); ?></span>
     191        <?php if ( $can_publish ) { ?>
     192        <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
    152193
    153 <?php
    154 // translators: Publish box date format, see http://php.net/date
    155 $datef = __( 'M j, Y @ G:i' );
    156 if ( 0 != $post->ID ) {
    157         if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
    158                 $stamp = __('Scheduled for: <b>%1$s</b>');
    159         } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
    160                 $stamp = __('Published on: <b>%1$s</b>');
    161         } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
    162                 $stamp = __('Publish <b>immediately</b>');
    163         } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
    164                 $stamp = __('Schedule for: <b>%1$s</b>');
    165         } else { // draft, 1 or more saves, date specified
    166                 $stamp = __('Publish on: <b>%1$s</b>');
    167         }
    168         $date = date_i18n( $datef, strtotime( $post->post_date ) );
    169 } else { // draft (no saves, and thus no date specified)
    170         $stamp = __('Publish <b>immediately</b>');
    171         $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
     194        <div id="post-visibility-select" class="hide-if-js">
     195        <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
     196        <?php if ($post_type == 'post'): ?>
     197        <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
     198        <?php endif; ?>
     199        <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
     200        <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 />
     201        <?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?>
     202        <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span>
     203        <?php endif; ?>
     204        <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 />
     205        <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>"  maxlength="20" /><br /></span>
     206        <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 />
     207
     208        <p>
     209         <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
     210         <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
     211        </p>
     212        </div>
     213        <?php } ?>
     214
     215        </div><!-- .misc-pub-section -->       
     216        <?php
    172217}
     218add_action( 'post_submitbox_misc_actions', 'post_submitbox_misc_visibility_action', 10, 3 );
    173219
    174 if ( ! empty( $args['args']['revisions_count'] ) ) :
    175         $revisions_to_keep = wp_revisions_to_keep( $post );
    176 ?>
    177 <div class="misc-pub-section misc-pub-revisions">
    178 <?php
    179         if ( $revisions_to_keep > 0 && $revisions_to_keep <= $args['args']['revisions_count'] ) {
    180                 echo '<span title="' . esc_attr( sprintf( __( 'Your site is configured to keep only the last %s revisions.' ),
    181                         number_format_i18n( $revisions_to_keep ) ) ) . '">';
    182                 printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '+</b>' );
    183                 echo '</span>';
    184         } else {
    185                 printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' );
     220/**
     221 * Add post revisions misc publishing action.
     222 *
     223 * @param string $post_type
     224 * @param object $post_type_object
     225 * @param bool $can_publish
     226 */
     227function post_submitbox_misc_revisions_action( $post_type, $post_type_object, $can_publish, $args ) {
     228        global $post;
     229        if ( ! empty( $args['args']['revisions_count'] ) ) :
     230                $revisions_to_keep = wp_revisions_to_keep( $post );
     231                ?>
     232                <div class="misc-pub-section misc-pub-revisions">
     233                <?php
     234                        if ( $revisions_to_keep > 0 && $revisions_to_keep <= $args['args']['revisions_count'] ) {
     235                                echo '<span title="' . esc_attr( sprintf( __( 'Your site is configured to keep only the last %s revisions.' ),
     236                                        number_format_i18n( $revisions_to_keep ) ) ) . '">';
     237                                printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '+</b>' );
     238                                echo '</span>';
     239                        } else {
     240                                printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' );
     241                        }
     242                ?>
     243                        <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><?php _ex( 'Browse', 'revisions' ); ?></a>
     244                </div>
     245                <?php
     246        endif;
     247}
     248add_action( 'post_submitbox_misc_actions', 'post_submitbox_misc_revisions_action', 10, 4 );
     249
     250/**
     251 * Add post publish date misc publishing action.
     252 *
     253 * @param string $post_type
     254 * @param object $post_type_object
     255 * @param bool $can_publish
     256 */
     257function post_submitbox_misc_publish_date_action( $post_type, $post_type_object, $can_publish ) {
     258        global $post;
     259        // translators: Publish box date format, see http://php.net/date
     260        $datef = __( 'M j, Y @ G:i' );
     261        if ( 0 != $post->ID ) {
     262                if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
     263                        $stamp = __('Scheduled for: <b>%1$s</b>');
     264                } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
     265                        $stamp = __('Published on: <b>%1$s</b>');
     266                } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
     267                        $stamp = __('Publish <b>immediately</b>');
     268                } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
     269                        $stamp = __('Schedule for: <b>%1$s</b>');
     270                } else { // draft, 1 or more saves, date specified
     271                        $stamp = __('Publish on: <b>%1$s</b>');
     272                }
     273                $date = date_i18n( $datef, strtotime( $post->post_date ) );
     274        } else { // draft (no saves, and thus no date specified)
     275                $stamp = __('Publish <b>immediately</b>');
     276                $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
    186277        }
    187 ?>
    188         <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><?php _ex( 'Browse', 'revisions' ); ?></a>
    189 </div>
    190 <?php endif;
    191 
    192 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
    193 <div class="misc-pub-section curtime misc-pub-curtime">
    194         <span id="timestamp">
    195         <?php printf($stamp, $date); ?></span>
    196         <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><?php _e('Edit') ?></a>
    197         <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'), 1); ?></div>
    198 </div><?php // /misc-pub-section ?>
    199 <?php endif; ?>
    200278
    201 <?php do_action('post_submitbox_misc_actions'); ?>
    202 </div>
    203 <div class="clear"></div>
    204 </div>
     279        if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
     280        <div class="misc-pub-section curtime misc-pub-curtime">
     281                <span id="timestamp">
     282                <?php printf($stamp, $date); ?></span>
     283                <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><?php _e('Edit') ?></a>
     284                <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'), 1); ?></div>
     285        </div><?php // /misc-pub-section ?>
     286        <?php endif;   
     287}
     288add_action( 'post_submitbox_misc_actions', 'post_submitbox_misc_publish_date_action', 10, 3 );
    205289
    206 <div id="major-publishing-actions">
    207 <?php do_action('post_submitbox_start'); ?>
    208 <div id="delete-action">
    209 <?php
    210 if ( current_user_can( "delete_post", $post->ID ) ) {
    211         if ( !EMPTY_TRASH_DAYS )
    212                 $delete_text = __('Delete Permanently');
    213         else
    214                 $delete_text = __('Move to Trash');
     290/**
     291 * Add post delete button to major publishing actions.
     292 *
     293 * @param string $post_type
     294 * @param object $post_type_object
     295 * @param bool $can_publish
     296 */
     297function post_submitbox_major_delete_action() {
     298        global $post;
    215299        ?>
    216 <a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php
    217 } ?>
    218 </div>
    219 
    220 <div id="publishing-action">
    221 <span class="spinner"></span>
    222 <?php
    223 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
    224         if ( $can_publish ) :
    225                 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
    226                 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
    227                 <?php submit_button( __( 'Schedule' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
    228 <?php   else : ?>
    229                 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
    230                 <?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
    231 <?php   endif;
    232         else : ?>
    233                 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
    234                 <?php submit_button( __( 'Submit for Review' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
    235 <?php
    236         endif;
    237 } else { ?>
    238                 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
    239                 <input name="save" type="submit" class="button button-primary button-large" id="publish" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
    240 <?php
    241 } ?>
    242 </div>
    243 <div class="clear"></div>
    244 </div>
    245 </div>
     300        <div id="delete-action">
     301        <?php
     302        if ( current_user_can( "delete_post", $post->ID ) ) {
     303                if ( !EMPTY_TRASH_DAYS )
     304                        $delete_text = __('Delete Permanently');
     305                else
     306                        $delete_text = __('Move to Trash');
     307                ?>
     308        <a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php
     309        } ?>
     310        </div>
     311        <?php
     312}
     313add_action( 'post_submitbox_start', 'post_submitbox_major_delete_action' );
    246314
    247 <?php
     315function post_submitbox_major_publishing_action( $post_type, $post_type_object, $can_publish ) {
     316        global $post;
     317        ?>
     318        <div id="publishing-action">
     319        <span class="spinner"></span>
     320        <?php
     321        if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
     322                if ( $can_publish ) :
     323                        if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
     324                        <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
     325                        <?php submit_button( __( 'Schedule' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
     326        <?php   else : ?>
     327                        <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
     328                        <?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
     329        <?php   endif;
     330                else : ?>
     331                        <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
     332                        <?php submit_button( __( 'Submit for Review' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
     333        <?php
     334                endif;
     335        } else { ?>
     336                        <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
     337                        <input name="save" type="submit" class="button button-primary button-large" id="publish" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
     338        <?php
     339        } ?>
     340        </div>
     341        <?php
    248342}
     343add_action( 'post_submitbox_start', 'post_submitbox_major_publishing_action', 10, 4 );
     344
     345
    249346
    250347/**
    251348 * Display attachment submit form fields.