Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bundled patterns compat directory #45620

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions lib/compat/wordpress-6.1/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,59 +175,3 @@ function gutenberg_register_theme_block_patterns() {
}
remove_action( 'init', '_register_theme_block_patterns' );
add_action( 'init', 'gutenberg_register_theme_block_patterns' );

/**
* Registers Gutenberg-bundled patterns, with a focus on headers and footers
* for site editing.
*
* @since 6.1.0
* @access private
*/
function gutenberg_register_core_block_patterns() {
$should_register_core_patterns = get_theme_support( 'core-block-patterns' );

// Register categories used for block patterns.
$pattern_category_registry = WP_Block_Pattern_Categories_Registry::get_instance();

if ( ! $pattern_category_registry->is_registered( 'footer' ) ) {
register_block_pattern_category( 'footer', array( 'label' => __( 'Footers', 'gutenberg' ) ) );
}

if ( ! $pattern_category_registry->is_registered( 'banner' ) ) {
register_block_pattern_category( 'banner', array( 'label' => __( 'Banners', 'gutenberg' ) ) );
}

if ( $should_register_core_patterns ) {
$core_block_patterns = array(
'centered-footer',
'centered-footer-with-social-links',
'centered-header',
'centered-logo-in-navigation',
'footer-with-background-color-and-three-columns',
'footer-with-credit-line-and-navigation',
'footer-with-large-font-size',
'footer-with-navigation-and-credit-line',
'footer-with-search-site-title-and-credit-line',
'footer-with-site-title-and-credit-line',
'header-with-large-font-size',
'left-aligned-footer',
'right-aligned-footer',
'simple-header',
'simple-header-inside-image',
'simple-header-with-background-color',
'simple-header-with-image',
'simple-header-with-tagline',
'simple-header-with-tagline-2',
'site-title-and-menu-button',
'site-title-and-vertical-navigation',
);

foreach ( $core_block_patterns as $core_block_pattern ) {
register_block_pattern(
'core/' . $core_block_pattern,
require __DIR__ . '/block-patterns/' . $core_block_pattern . '.php'
);
}
}
}
add_action( 'init', 'gutenberg_register_core_block_patterns' );
51 changes: 51 additions & 0 deletions lib/compat/wordpress-6.2/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
* Registers the block pattern categories REST API routes.
*/
function gutenberg_register_core_block_patterns_and_categories() {
register_block_pattern_category(
'banner',
array(
'label' => _x( 'Banners', 'Block pattern category', 'gutenberg' ),
)
);
register_block_pattern_category(
'buttons',
array(
Expand Down Expand Up @@ -60,3 +66,48 @@ function gutenberg_register_core_block_patterns_and_categories() {
);
}
add_action( 'init', 'gutenberg_register_core_block_patterns_and_categories' );

/**
* Registers Gutenberg-bundled patterns, with a focus on headers and footers
* for site editing.
*
* @since 6.2.0
* @access private
*/
function gutenberg_register_core_block_patterns() {
if ( ! get_theme_support( 'core-block-patterns' ) ) {
return;
}

$core_block_patterns = array(
'centered-footer',
'centered-footer-with-social-links',
'centered-header',
'centered-logo-in-navigation',
'footer-with-background-color-and-three-columns',
'footer-with-credit-line-and-navigation',
'footer-with-large-font-size',
'footer-with-navigation-and-credit-line',
'footer-with-search-site-title-and-credit-line',
'footer-with-site-title-and-credit-line',
'header-with-large-font-size',
'left-aligned-footer',
'right-aligned-footer',
'simple-header',
'simple-header-inside-image',
'simple-header-with-background-color',
'simple-header-with-image',
'simple-header-with-tagline',
'simple-header-with-tagline-2',
'site-title-and-menu-button',
'site-title-and-vertical-navigation',
);

foreach ( $core_block_patterns as $core_block_pattern ) {
register_block_pattern(
'core/' . $core_block_pattern,
require __DIR__ . '/block-patterns/' . $core_block_pattern . '.php'
);
}
}
add_action( 'init', 'gutenberg_register_core_block_patterns' );