¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.
editor_blocks
The editor_blocks
hook allows plugins to register custom blocks for the block editor.
Each block is defined with its file path, title, and category to enable dynamic loading into the editor.
$pluginBlocks = DynamicHooks::executeHook('editor_blocks', true);
if (!empty($pluginBlocks)) {
foreach ($pluginBlocks as $pluginName => $blocks) {
if (!is_array($blocks)) {
error_log("Invalid blocks returned by plugin: $pluginName");
continue;
}
if (is_array($blocks)) {
foreach ($blocks as $block) {
if (!isset($block['file'], $block['title'], $block['category'])) {
error_log("Invalid block structure in plugin: $pluginName");
}
if (isset($block['file'], $block['title'], $block['category'])) {
$categories[$block['category']][] = [
'file' => $block['file'],
'title' => $block['title']
];
}
}
}
}
}
This hook processes blocks registered by plugins and categorizes them dynamically for the editor.
DynamicHooks::addHook('editor_blocks', function () {
return [
'your_plugin' => [
[
'file' => 'plugins/your_plugin/frontend/blocks/faq_question_block.php',
'title' => 'Your Plugin Question Block',
'category' => 'custom_'
],
[
'file' => 'plugins/your_plugin/frontend/blocks/faq_list_block.php',
'title' => 'Your Plugin List Block',
'category' => 'custom_'
]
]
];
}, 'your_plugin');
file
, title
, and category
properties.