Make WordPress Core

Ticket #46397: 46397.diff

File 46397.diff, 2.2 KB (added by akerayo, 6 years ago)

The changes that applied to post_submit_meta_box() function

Line 
1Index: src/wp-admin/includes/meta-boxes.php
2===================================================================
3--- src/wp-admin/includes/meta-boxes.php
4+++ src/wp-admin/includes/meta-boxes.php
5@@ -91,6 +91,12 @@
6function post_submit_meta_box( $post, $args = array() ) {
7        <?php _e( 'Status:' ); ?> <span id="post-status-display">
8                        <?php
9 
10+                       // get only statuses that belong to this post type
11+                       $post_stati = array_filter( get_post_stati( array(), 'objects' ), function( $args ) use ( $post ) {
12+                               return ( is_string( $args->post_type ) && in_array( $args->post_type, array( 'all', $post->post_type ) ) )
13+                                       || ( is_array ( $args->post_type ) && in_array( $post->post_type, $args->post_type ) );
14+                       });
15+
16                        switch ( $post->post_status ) {
17                                case 'private':
18                                        _e( 'Privately Published' );
19@@ -108,6 +114,13 @@
20function post_submit_meta_box( $post, $args = array() ) {
21                                case 'auto-draft':
22                                        _e( 'Draft' );
23                                        break;
24+                               
25+                               // default check if in stati array
26+                               default: if ( in_array( $post->post_status, $post_stati ) ) :
27+
28+                                       // show the label
29+                                       echo $post_stati[$post->post_status]->label;
30+                                       endif; break;
31                        }
32                        ?>
33 </span>
34@@ -124,7 +137,14 @@
35function post_submit_meta_box( $post, $args = array() ) {
36 <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 ); ?>" />
37 <label for="post_status" class="screen-reader-text"><?php _e( 'Set status' ); ?></label>
38 <select name="post_status" id="post_status">
39-               <?php if ( 'publish' == $post->post_status ) : ?>
40+               <?php
41+               
42+               // loop through the stati array to show it as <select> option
43+               foreach ( $post_stati as $post_stati_key => $post_stati_args ) {
44+                       echo '<option' . selected( $post->post_status, $post_stati_key, false ) . ' value="' . $post_stati_key . '">' . $post_stati_args->label . '</option>';
45+               }
46+               
47+               if ( 'publish' == $post->post_status ) : ?>
48 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e( 'Published' ); ?></option>
49 <?php elseif ( 'private' == $post->post_status ) : ?>
50 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e( 'Privately Published' ); ?></option>