Make WordPress Core

Ticket #12706: 12706.5.patch

File 12706.5.patch, 5.1 KB (added by Mosterd3d, 9 years ago)

Fix showing "register_post_status" in save post widget. Now upper left button get updated to the selected state.

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

     
    3737
    3838<div id="minor-publishing-actions">
    3939<div id="save-action">
    40 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
    41 <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" />
     40        <?php
     41        $btnHideArray = array("publish","future","private");
     42
     43        if ( !in_array( $post->post_status, $btnHideArray ) )
     44        {
     45                $phrase = 'Save '.ucfirst($post->post_status);
     46                echo '<input type="submit" name="save" id="save-post" value="'. __($phrase) .'" class="button" />';
     47        }
     48        ?>
    4249<span class="spinner"></span>
    43 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
    44 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" class="button" />
    45 <span class="spinner"></span>
    46 <?php } ?>
    4750</div>
    4851<?php if ( is_post_type_viewable( $post_type_object ) ) : ?>
    4952<div id="preview-action">
     
    7780<div class="misc-pub-section misc-pub-post-status"><label for="post_status"><?php _e('Status:') ?></label>
    7881<span id="post-status-display">
    7982<?php
    80 switch ( $post->post_status ) {
    81         case 'private':
    82                 _e('Privately Published');
    83                 break;
    84         case 'publish':
    85                 _e('Published');
    86                 break;
    87         case 'future':
    88                 _e('Scheduled');
    89                 break;
    90         case 'pending':
    91                 _e('Pending Review');
    92                 break;
    93         case 'draft':
    94         case 'auto-draft':
    95                 _e('Draft');
    96                 break;
    97 }
     83
     84        global $wp_post_statuses, $allowed_post_status;
     85
     86        foreach($wp_post_statuses as $key => $wp_post_status){
     87                if($key == $post->post_status && $wp_post_status->show_in_admin_status_list){
     88                        $allowed_post_status = true;
     89                        echo __($wp_post_status->label);
     90                }
     91                elseif($key == $post->post_status){
     92                        $allowed_post_status = false;
     93                        echo __($wp_post_status->label);
     94                }
     95        }
    9896?>
    9997</span>
    100 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
     98<?php if ( $allowed_post_status && ('publish' == $post->post_status || 'private' == $post->post_status || $can_publish )) { ?>
    10199<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a>
    102100
    103101<div id="post-status-select" class="hide-if-js">
    104102<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); ?>" />
    105103<select name='post_status' id='post_status'>
    106 <?php if ( 'publish' == $post->post_status ) : ?>
    107 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
    108 <?php elseif ( 'private' == $post->post_status ) : ?>
    109 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
    110 <?php elseif ( 'future' == $post->post_status ) : ?>
    111 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
    112 <?php endif; ?>
    113 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
    114 <?php if ( 'auto-draft' == $post->post_status ) : ?>
    115 <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option>
    116 <?php else : ?>
    117 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
    118 <?php endif; ?>
     104<?php
     105        $ppf = array('publish','private','future');
     106        $ad = array('auto-draft','draft');
     107        $adSet = false;
     108
     109        foreach($wp_post_statuses as $key => $wp_post_status){
     110                $show = false;
     111                if($wp_post_status->show_in_admin_status_list){
     112                        if(in_array($key, $ppf)){
     113                                // Show just one of those
     114                                if($post->post_status == $key){
     115                                        $show = true;
     116                                }
     117                        } elseif($key == 'trash'){
     118                                // Don't show
     119                                $show = false;
     120                        } else{
     121                                $show = true;
     122                        }
     123
     124                        if($show){
     125                                echo "<option ".selected( $post->post_status, $key, false )."  value='".$key."'>". __($wp_post_status->label) ."</option>";
     126                        }
     127                }
     128        }
     129?>
    119130</select>
    120131 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
    121132 <a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel"><?php _e('Cancel'); ?></a>
  • src/wp-admin/js/post.js

     
    602602                                if ( $('option:selected', postStatus).val() == 'pending' ) {
    603603                                        $('#save-post').show().val( postL10n.savePending );
    604604                                } else {
    605                                         $('#save-post').show().val( postL10n.saveDraft );
     605                                        var phrase = 'Save '+$('option:selected', postStatus).val();
     606                                        $('#save-post').show().val(phrase);
    606607                                }
    607608                        }
    608609                        return true;