| 1 |
<?php |
| 2 |
/** |
| 3 |
* Overrides Core's wp-includes/block-patterns.php to add category descriptions for WP 6.2. |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Registers the block pattern categories. |
| 10 |
*/ |
| 11 |
function gutenberg_register_core_block_patterns_and_categories() { |
| 12 |
register_block_pattern_category( |
| 13 |
'banner', |
| 14 |
array( |
| 15 |
'label' => _x( 'Banners', 'Block pattern category', 'gutenberg' ), |
| 16 |
) |
| 17 |
); |
| 18 |
register_block_pattern_category( |
| 19 |
'buttons', |
| 20 |
array( |
| 21 |
'label' => _x( 'Buttons', 'Block pattern category', 'gutenberg' ), |
| 22 |
'description' => __( 'Patterns that contain buttons and call to actions.', 'gutenberg' ), |
| 23 |
) |
| 24 |
); |
| 25 |
register_block_pattern_category( |
| 26 |
'columns', |
| 27 |
array( |
| 28 |
'label' => _x( 'Columns', 'Block pattern category', 'gutenberg' ), |
| 29 |
'description' => __( 'Multi-column patterns with more complex layouts.', 'gutenberg' ), |
| 30 |
) |
| 31 |
); |
| 32 |
register_block_pattern_category( |
| 33 |
'footer', |
| 34 |
array( |
| 35 |
'label' => _x( 'Footers', 'Block pattern category', 'gutenberg' ), |
| 36 |
'description' => __( 'A variety of footer designs displaying information and site navigation.', 'gutenberg' ), |
| 37 |
) |
| 38 |
); |
| 39 |
register_block_pattern_category( |
| 40 |
'gallery', |
| 41 |
array( |
| 42 |
'label' => _x( 'Gallery', 'Block pattern category', 'gutenberg' ), |
| 43 |
'description' => __( 'Patterns containing mostly images or other media.', 'gutenberg' ), |
| 44 |
) |
| 45 |
); |
| 46 |
register_block_pattern_category( |
| 47 |
'header', |
| 48 |
array( |
| 49 |
'label' => _x( 'Headers', 'Block pattern category', 'gutenberg' ), |
| 50 |
'description' => __( 'A variety of header designs displaying your site title and navigation.', 'gutenberg' ), |
| 51 |
) |
| 52 |
); |
| 53 |
register_block_pattern_category( |
| 54 |
'text', |
| 55 |
array( |
| 56 |
'label' => _x( 'Text', 'Block pattern category', 'gutenberg' ), |
| 57 |
'description' => __( 'Patterns containing mostly text.', 'gutenberg' ), |
| 58 |
) |
| 59 |
); |
| 60 |
register_block_pattern_category( |
| 61 |
'query', |
| 62 |
array( |
| 63 |
'label' => _x( 'Posts', 'Block pattern category', 'gutenberg' ), |
| 64 |
'description' => __( 'Display your latest posts in lists, grids or other layouts.', 'gutenberg' ), |
| 65 |
) |
| 66 |
); |
| 67 |
register_block_pattern_category( |
| 68 |
'featured', |
| 69 |
array( |
| 70 |
'label' => _x( 'Featured', 'Block pattern category', 'gutenberg' ), |
| 71 |
'description' => __( 'A set of high quality curated patterns.', 'gutenberg' ), |
| 72 |
) |
| 73 |
); |
| 74 |
} |
| 75 |
add_action( 'init', 'gutenberg_register_core_block_patterns_and_categories' ); |
| 76 |
|
| 77 |
/** |
| 78 |
* Registers Gutenberg-bundled patterns, with a focus on headers and footers |
| 79 |
* for site editing. |
| 80 |
* |
| 81 |
* @since 6.2.0 |
| 82 |
* @access private |
| 83 |
*/ |
| 84 |
function gutenberg_register_core_block_patterns() { |
| 85 |
if ( ! get_theme_support( 'core-block-patterns' ) ) { |
| 86 |
return; |
| 87 |
} |
| 88 |
|
| 89 |
$core_block_patterns = array( |
| 90 |
'centered-footer', |
| 91 |
'centered-footer-with-social-links', |
| 92 |
'centered-header', |
| 93 |
'centered-logo-in-navigation', |
| 94 |
'footer-with-background-color-and-three-columns', |
| 95 |
'footer-with-credit-line-and-navigation', |
| 96 |
'footer-with-large-font-size', |
| 97 |
'footer-with-navigation-and-credit-line', |
| 98 |
'footer-with-search-site-title-and-credit-line', |
| 99 |
'footer-with-site-title-and-credit-line', |
| 100 |
'header-with-large-font-size', |
| 101 |
'left-aligned-footer', |
| 102 |
'right-aligned-footer', |
| 103 |
'simple-header', |
| 104 |
'simple-header-inside-image', |
| 105 |
'simple-header-with-background-color', |
| 106 |
'simple-header-with-image', |
| 107 |
'simple-header-with-tagline', |
| 108 |
'simple-header-with-tagline-2', |
| 109 |
'site-title-and-menu-button', |
| 110 |
'site-title-and-vertical-navigation', |
| 111 |
); |
| 112 |
|
| 113 |
foreach ( $core_block_patterns as $core_block_pattern ) { |
| 114 |
register_block_pattern( |
| 115 |
'core/' . $core_block_pattern, |
| 116 |
require __DIR__ . '/block-patterns/' . $core_block_pattern . '.php' |
| 117 |
); |
| 118 |
} |
| 119 |
} |
| 120 |
add_action( 'init', 'gutenberg_register_core_block_patterns' ); |
| 121 |
|