[wp-trac] [WordPress Trac] #56284: Site Editor: Pass correct context into get_block_categories

WordPress Trac noreply at wordpress.org
Mon Jul 25 15:32:39 UTC 2022


#56284: Site Editor: Pass correct context into get_block_categories
--------------------------+-----------------------------
 Reporter:  Mamaduka      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Editor        |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Site Editor passes global `$post` as a context when setting up block
 categories. Instead, it should pass `$block_editor_context`, since global
 `$post` is `null` in this file.


 To reproduce:

 {{{#!php
 <?php
 add_filter( 'block_categories_all', function( $categories, $context ) {
         error_log( var_export( $context instanceof
 WP_Block_Editor_Context, true ) );

         return $categories;
 }, 10, 2 );
 }}}

 Expected:

 The example above should log `true` twice.

 Actual:

 Logs `true` and `false`.

 Note: The second log represents the `get_block_categories` call when
 setting up the categories. The first comes from
 `get_block_editor_settings`, where context is correctly set.

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


More information about the wp-trac mailing list