[wp-trac] [WordPress Trac] #50151: use_block_editor_for_post_type filter always returns page or post as post_type

WordPress Trac noreply at wordpress.org
Tue May 12 16:19:22 UTC 2020


#50151: use_block_editor_for_post_type filter always returns page or post as
post_type
--------------------------+-----------------------------
 Reporter:  dingo_d       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:  2nd-opinion
  Focuses:                |
--------------------------+-----------------------------
 I'm trying to enable the core editor only for one post type on a client
 project (want to transition to blocks piece by piece). So I've added the
 `use_block_editor_for_post_type` filter, and set:

 {{{#!php
 <?PHP
   /**
    * Register hooks
    */
   public function register() : void {
     add_filter( 'use_block_editor_for_post_type', [ $this,
 'disable_gutenberg' ], 10, 2 );
   }

   public function disable_gutenberg( bool $use_block_editor, string
 $post_type ) {
     if ( in_array( $post_type, [ 'post', 'page' ], true ) ) {
       return false;
     }

     return $use_block_editor;
   }
 }}}

 And I check posts, and pages, they don't have GB (which is what I want).
 But my custom post types, which have editor enabled, also show classic
 editor.

 So I added an error_log in the filter and all the `$post_type` variable
 value when I'm at the new page of the CPT is `page` (except when I'm on a
 post, then it's `post`).

 Is this a bug or?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50151>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list