Skip to content

Commit

Permalink
Add key to the $post_states array when appending a postr state.
Browse files Browse the repository at this point in the history
Also do not add post state for deleted posts.
  • Loading branch information
azaozz committed May 6, 2019
1 parent 898e3ce commit 960b63e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion classic-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,10 @@ public static function add_edit_links( $actions, $post ) {
* Show the editor that will be used in a "post state" in the Posts list table.
*/
public static function add_post_state( $post_states, $post ) {
if ( get_post_status( $post ) === 'trash' ) {
return $post_states;
}

$editors = self::get_enabled_editors_for_post( $post );

if ( ! $editors['classic_editor'] && ! $editors['block_editor'] ) {
Expand All @@ -895,7 +899,9 @@ public static function add_post_state( $post_states, $post ) {
$state = $is_classic ? _x( 'Classic Editor', 'Editor Name', 'classic-editor' ) : _x( 'Block Editor', 'Editor Name', 'classic-editor' );
}

(array) $post_states[] = $state;
// Fix PHP 7+ warnings if another plugin returns unexpected type.
$post_states = (array) $post_states;
$post_states['classic-editor-plugin'] = $state;

return $post_states;
}
Expand Down

0 comments on commit 960b63e

Please sign in to comment.