Description
The add_block() function enables the ability to register blocks programmatically. Needs to run during the genesis_custom_blocks_add_blocks action hook.
To avoid conflicts with other plugins , the add_block() function is namespaced. In order to use it, you must include the namespace with use.
use function Genesis\CustomBlocks\add_block;
add_block( $block_name, $block_config );
Parameters
$block_name(string)$block_config(array)- title
- icon
- category
- excluded
- keywords
- fields
Usage
use function Genesis\CustomBlocks\add_block;
// One long array with lots defined.
add_block(
'one-fish',
array(
'title' => 'One Fish',
'category' => 'common',
'icon' => 'waves',
'excluded' => array( 'page' ),
'keywords' => array( 'sad', 'glad', 'bad' ),
'fields' => array(
'thin' => array(
'label' => 'Thin',
'control' => 'toggle',
'width' => '25',
'default' => true,
),
'fat' => array(
'label' => 'Fat',
'control' => 'toggle',
'width' => '25',
'default' => false,
),
'hat' => array(
'label' => 'Hat',
'control' => 'select',
'width' => '50',
'options' => array(
array(
'label' => 'Yellow',
'value' => 'yellow',
),
array(
'label' => 'Red',
'value' => 'red',
),
array(
'label' => 'Blue',
'value' => 'blue',
),
),
),
),
)
);
