* Añadir Bloques de Gutenberg para crear Perfiles de Usuarios.
* https://trincherawp.com/curso/advanced-custom-fields/bloques-de-gutenberg/.
* 1. Registrar el bloque..
* 2. Crear el grupo de campos..
* 3. Mostrar el contenido del Bloque..
.
Código
/**
* Añadir Bloques de Gutenberg para crear Perfiles de Usuarios.
* Por vamez
* https://trincherawp.com/curso/advanced-custom-fields/bloques-de-gutenberg/
* 1. Registrar el bloque.
* 2. Crear el grupo de campos.
* 3. Mostrar el contenido del Bloque.
*/
/**
* Registrar el bloque.
*/
add_action('acf/init', 'my_acf_init');
function my_acf_init() {
// check function exists
if( function_exists('acf_register_block') ) {
// register a ponente block
acf_register_block(array(
'name' => 'ponente',
'title' => __('Ponente'),
'description' => __('A custom ponente block.'),
'render_callback' => 'my_acf_block_render_callback',
'category' => 'formatting',
'icon' => 'admin-comments',
'keywords' => array( 'ponente', 'quote' ),
));
}
}
/**
* Mostrar el contenido del Bloque.
*/
function my_acf_block_render_callback( $block ) {
// convert name ("acf/ponente") into path friendly slug ("ponente")
$slug = str_replace('acf/', '', $block['name']);
// include a template part from within the "template-parts/block" folder
if( file_exists( get_theme_file_path("/template-parts/block/content-{$slug}.php") ) ) {
include( get_theme_file_path("/template-parts/block/content-{$slug}.php") );
}
}