[wp-trac] [WordPress Trac] #53589: Twenty Twenty One: Translation file loaded twice

WordPress Trac noreply at wordpress.org
Wed Dec 29 21:43:26 UTC 2021


#53589: Twenty Twenty One: Translation file loaded twice
---------------------------+------------------------------
 Reporter:  Chouby         |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Bundled Theme  |     Version:  5.6
 Severity:  normal         |  Resolution:
 Keywords:  needs-testing  |     Focuses:  performance
---------------------------+------------------------------

Comment (by zodiac1978):

 I can confirm that the line 20 in `/inc/block-patterns.php` is triggering
 the first loading of the translation file:

 {{{#!php
 <?php
 require get_template_directory() . '/inc/block-patterns.php';
 }}}

 But fixing only this line wouldn't be enough. There are many more
 occurrences of translation function calls in this file. The problem is,
 that the file is executed immediately on loading. The similar file `/inc
 /block-styles` is using an action to execute the code:

 {{{#!php
 <?php
 add_action( 'init', 'twenty_twenty_one_register_block_styles' );
 }}}

 According to this comment
 (https://developer.wordpress.org/reference/functions/register_block_pattern/#comment-4675)
 and to the docs (https://developer.wordpress.org/block-editor/reference-
 guides/block-api/block-patterns/#register_block_pattern) this should also
 happen on the `init` hook.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53589#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list