Skip to content

Commit

Permalink
Patterns: Fix core 'Featured' pattern category registration (#40650)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Apr 27, 2022
1 parent 82e9d59 commit 2e829fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/compat/wordpress-5.9/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ function _load_remote_featured_patterns() {
return;
}

if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( 'featured' ) ) {
register_block_pattern_category( 'featured', array( 'label' => __( 'Featured', 'gutenberg' ) ) );
}
$request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
$request['category'] = 26; // This is the `Featured` category id from pattern directory.
$response = rest_do_request( $request );
Expand Down
8 changes: 7 additions & 1 deletion lib/compat/wordpress-6.0/block-patterns-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
* Register Gutenberg bundled patterns.
*/
function gutenberg_register_gutenberg_patterns() {
$pattern_category_registry = WP_Block_Pattern_Categories_Registry::get_instance();

// Register categories used for block patterns.
if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( 'query' ) ) {
if ( ! $pattern_category_registry->is_registered( 'query' ) ) {
register_block_pattern_category( 'query', array( 'label' => __( 'Query', 'gutenberg' ) ) );
}

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

$patterns = array(
'query-standard-posts' => array(
'title' => _x( 'Standard', 'Block pattern title', 'gutenberg' ),
Expand Down

0 comments on commit 2e829fa

Please sign in to comment.