I would like to create a block for Gutenberg. I currently have a default configuration:
function my_block_category($categories, $post)
{
return array_merge(
$categories,
array(
array(
'slug' => 'my-block',
'title' => __('BLOCK', 'my-block'),
),
)
);
}
add_filter('block_categories', 'my_block_category', 10, 2);
function gutenberg_boilerplate_block()
{
wp_register_script(
'myblock',
plugins_url('js/gutenberg' . DIRECTORY_SEPARATOR . 'block.js'),
array('wp-blocks', 'wp-element')
);
register_block_type('myblock/shortcodes', array(
'editor_script' => 'myblock',
));
}
add_action('init', 'gutenberg_boilerplate_block');
It works. I get my category. The goal is that I get a Dropdown Select in my category, which is filled from a JSON file.
{
"text": {
"text": "Home",
"value": "[home]",
"content": "0"
},
....
}
However, I currently have no idea how I can implement that? The shortcodes that are output are evaluated by the plugin.
Can you tell me how this can be done?