acf_render_block_callback()
The render callback for all ACF blocks.
Хуков нет.
Возвращает
Строку. The block HTML.
Использование
acf_render_block_callback( $attributes, $content, $wp_block );
- $attributes(массив) (обязательный)
- The block attributes.
- $content(строка)
- The block content.
По умолчанию:'' - $wp_block(WP_Block)
- The block instance (since WP 5.5).
По умолчанию:null
Список изменений
| С версии 5.9.2 | Введена. |
Код acf_render_block_callback() acf render block callback ACF 6.4.2
function acf_render_block_callback( $attributes, $content = '', $wp_block = null ) {
$is_preview = false;
$post_id = get_the_ID();
// Set preview flag to true when rendering for the block editor.
if ( is_admin() && acf_is_block_editor() ) {
$is_preview = true;
}
// If ACF's block save method hasn't been called yet, try to initialize a default block.
if ( empty( $attributes['name'] ) && ! empty( $wp_block->name ) ) {
$attributes['name'] = $wp_block->name;
}
// Return rendered block HTML.
return acf_rendered_block( $attributes, $content, $is_preview, $post_id, $wp_block );
}