Last active
September 22, 2023 22:28
-
-
Save jrtashjian/6a7c16ec5d9fd60ca39a546d58b626ae to your computer and use it in GitHub Desktop.
Get With Gutenberg - Creating a Block Category • https://getwithgutenberg.com/2019/04/creating-a-block-category/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add a block category for "Get With Gutenberg" if it doesn't exist already. | |
* | |
* @param array $categories Array of block categories. | |
* | |
* @return array | |
*/ | |
function gwg_block_categories( $categories ) { | |
$category_slugs = wp_list_pluck( $categories, 'slug' ); | |
return in_array( 'gwg', $category_slugs, true ) ? $categories : array_merge( | |
$categories, | |
array( | |
array( | |
'slug' => 'gwg', | |
'title' => __( 'Get With Gutenberg', 'gwg' ), | |
'icon' => null, | |
), | |
) | |
); | |
} | |
add_filter( 'block_categories', 'gwg_block_categories' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment