-
Notifications
You must be signed in to change notification settings - Fork 1
Custom Block Pattern
Loïc Antignac edited this page Sep 5, 2022
·
1 revision
Once the the plugin is created, the declaration(s) can be added:
<?php
/**
* Plugin Name: Example Custom Block Pattern
* Author: My Name
* Text Domain: wax-custom-content
* Domain Path: /languages
*/
defined( 'ABSPATH' ) || exit;
// If you already have an autoload (for example if you are on Bedrock) you can remove these 3 lines, otherwise leave them.
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
require __DIR__ . '/vendor/autoload.php';
}
use Webaxones\Core\Entities\Entities;
Webaxones\Core\Library::init( 'webaxones-content' );
/**
* Add custom block pattern: MyPatterns
*/
$declarations[] = [
'entity' => 'Webaxones\Core\Editor\Categories\BlockCategory',
'labels' => [
'title' => _x( 'Custom category', 'Custom block category name', 'webaxones-content' ),
],
'settings' => [
'slug' => 'webaxones_custom_category',
],
];
Entities::process( $declarations );
As for all entities, settings
starts with the slug
key which identifies the entity and must be unique.