[wp-trac] [WordPress Trac] #54113: Override core/gallery block

WordPress Trac noreply at wordpress.org
Sun Sep 12 17:34:20 UTC 2021


#54113: Override core/gallery block
--------------------------------------+-----------------------------
 Reporter:  lohic                     |      Owner:  (none)
     Type:  defect (bug)              |     Status:  new
 Priority:  normal                    |  Milestone:  Awaiting Review
Component:  General                   |    Version:  5.8.1
 Severity:  normal                    |   Keywords:
  Focuses:  administration, template  |
--------------------------------------+-----------------------------
 Hello,

 I did override the core block for the gallery using in my
 ''functions.php'' file :

 {{{#!php
 <?php
 function my_register_gallery() {
         unregister_block_type('core/gallery');
         register_block_type( 'core/gallery', array(
                 'render_callback' => 'my_gallery_render',
         ) );
 }
 add_action( 'init', 'my_register_gallery', 10 , 1  );
 }}}

 It was perfectly working, but since a few days (I did the last update of
 wordpress 5.8.1), and maybe a little bit before, but I am not totally
 sure, I have an issue :

 If I use the ''unregister_block_type'' function I cannot override it with
 ''register_block_type'' and the block disappear in the editor. And a
 strange thing occurs, I have this message on the former existing gallery
 blocks :

 {{{
 Your site doesn’t include support for the THRON block. You can try
 installing the block, convert it to a Custom HTML block, or remove it
 entirely.
 }}}

 If I don't use ''unregister_block_type('core/gallery');'' before, I have
 this message :

 {{{
 Notice: WP_Block_Type_Registry::register was called incorrectly. Block
 type "core/gallery" is already registered. Please see Debugging in
 WordPress for more information. (This message was added in version 5.0.0.)
 in /Users/the_user/wordpress_folder/wp-includes/functions.php on line 5663
 }}}

 All of that was working before with no alert.
 I tried with all my plugins deactivated, and with removing all my
 function.php files actions.

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


More information about the wp-trac mailing list