Twenty Twenty One: Prevent loading translation file twice.

This changes wraps the registration of patterns and pattern categories in a function hooked to `init`, to avoid loading the Twenty Twenty One translation file twice.

Props zodiac1978, sabernhardt, audrasjb.
Fixes #53589.

Built from https://develop.svn.wordpress.org/trunk@53121


git-svn-id: http://core.svn.wordpress.org/trunk@52710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2022-04-10 22:29:03 +00:00
parent 439bf1296f
commit 5c07bc0b59
2 changed files with 110 additions and 93 deletions

View File

@ -10,21 +10,35 @@
* @since Twenty Twenty-One 1.0
*/
/**
* Register Block Pattern Category.
*/
if ( function_exists( 'register_block_pattern_category' ) ) {
/**
* Register Block Pattern Category.
*
* @since Twenty Twenty-One 1.0
*
* @return void
*/
function twenty_twenty_one_register_block_pattern_category() {
register_block_pattern_category(
'twentytwentyone',
array( 'label' => esc_html__( 'Twenty Twenty-One', 'twentytwentyone' ) )
);
}
add_action( 'init', 'twenty_twenty_one_register_block_pattern_category' );
}
/**
* Register Block Patterns.
*/
if ( function_exists( 'register_block_pattern' ) ) {
/**
* Register Block Pattern.
*
* @since Twenty Twenty-One 1.0
*
* @return void
*/
function twenty_twenty_one_register_block_pattern() {
// Large Text.
register_block_pattern(
@ -117,4 +131,7 @@ if ( function_exists( 'register_block_pattern' ) ) {
'content' => '<!-- wp:columns {"align":"wide"} --><div class="wp-block-columns alignwide"><!-- wp:column --><div class="wp-block-column"><!-- wp:paragraph --><p><a href="mailto:#">' . esc_html_x( 'example@example.com', 'Block pattern sample content', 'twentytwentyone' ) . '<br></a>' . esc_html_x( '123-456-7890', 'Block pattern sample content', 'twentytwentyone' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:paragraph {"align":"center"} --><p class="has-text-align-center">' . esc_html_x( '123 Main Street', 'Block pattern sample content', 'twentytwentyone' ) . '<br>' . esc_html_x( 'Cambridge, MA, 02139', 'Block pattern sample content', 'twentytwentyone' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --><!-- wp:column {"verticalAlignment":"center"} --><div class="wp-block-column is-vertically-aligned-center"><!-- wp:social-links {"align":"right","className":"is-style-twentytwentyone-social-icons-color"} --><ul class="wp-block-social-links alignright is-style-twentytwentyone-social-icons-color"><!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /--><!-- wp:social-link {"url":"https://www.facebook.com/WordPress/","service":"facebook"} /--><!-- wp:social-link {"url":"https://twitter.com/WordPress","service":"twitter"} /--><!-- wp:social-link {"url":"https://www.youtube.com/wordpress","service":"youtube"} /--></ul><!-- /wp:social-links --></div><!-- /wp:column --></div><!-- /wp:columns -->',
)
);
}
add_action( 'init', 'twenty_twenty_one_register_block_pattern' );
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-53120';
$wp_version = '6.0-alpha-53121';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.