acf_prepare_block()ACF 5.8.0

Prepares a block for use in render_callback by merging in all settings and attributes.

Хуков нет.

Возвращает

Массив.

Использование

acf_prepare_block( $block );
$block(массив) (обязательный)
The block props.

Список изменений

С версии 5.8.0 Введена.

Код acf_prepare_block() ACF 6.0.4

function acf_prepare_block( $block ) {

	// Bail early if no name.
	if ( ! isset( $block['name'] ) ) {
		return false;
	}

	// Get block type and return false if doesn't exist.
	$block_type = acf_get_block_type( $block['name'] );
	if ( ! $block_type ) {
		return false;
	}

	// Generate default attributes.
	$attributes = array();
	foreach ( acf_get_block_type_default_attributes( $block_type ) as $k => $v ) {
		$attributes[ $k ] = $v['default'];
	}

	// Merge together arrays in order of least to most specific.
	$block = array_merge( $block_type, $attributes, $block );

	// Add backward compatibility attributes.
	$block = acf_add_back_compat_attributes( $block );

	// Return block.
	return $block;
}