Skip to content

Commit

Permalink
adds function/filter to add custom block category — WDS Blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jomurgel committed Sep 21, 2018
1 parent a725934 commit 849d2d0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,28 @@ function enqueue_block_editor_assets() {
// Recursively load all PHP files within the /src/ directory.
require_once plugin_dir_path( __DIR__ ) . 'vendor/autoload/autoload.php';
\AaronHolbrook\Autoload\autoload( plugin_dir_path( __DIR__ ) . 'src' );

/**
* Adds custom category for use in block
*
* @url https://wordpress.org/gutenberg/handbook/extensibility/extending-blocks/#managing-block-categories
*
* @param [array] $categories block categories.
* @param [string] $post post type.
* @return void updated array of $categories.
*/
function add_block_categories( $categories, $post ) {

// Otherwise update list of categories.
return array_merge(
$categories,
array(
array(
'slug' => 'wds-blocks',
'title' => __( 'WDS Blocks', 'wds-blocks' ),
),
)
);
}
add_filter( 'block_categories', __NAMESPACE__ . '\\add_block_categories', 10, 2 );

0 comments on commit 849d2d0

Please sign in to comment.