pre_get_block_file_template хук-фильтрWP 5.9.0

Filters the block template object before the theme file discovery takes place.

Return a non-null value to bypass the WordPress theme file discovery.

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

add_filter( 'pre_get_block_file_template', 'wp_kama_pre_get_block_file_template_filter', 10, 3 );

/**
 * Function for `pre_get_block_file_template` filter-hook.
 * 
 * @param WP_Block_Template|null $block_template Return block template object to short-circuit the default query, or null to allow WP to run its normal queries.
 * @param string                 $id             Template unique identifier (example: 'theme_slug//template_slug').
 * @param string                 $template_type  Template type. Either 'wp_template' or 'wp_template_part'.
 *
 * @return WP_Block_Template|null
 */
function wp_kama_pre_get_block_file_template_filter( $block_template, $id, $template_type ){

	// filter...
	return $block_template;
}
$block_template(WP_Block_Template|null)
Return block template object to short-circuit the default query, or null to allow WP to run its normal queries.
$id(строка)
Template unique identifier (example: 'theme_slug//template_slug').
$template_type(строка)
Template type. Either 'wp_template' or 'wp_template_part'.

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

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

Где вызывается хук

get_block_file_template()
pre_get_block_file_template
wp-includes/block-template-utils.php 1143
$block_template = apply_filters( 'pre_get_block_file_template', null, $id, $template_type );

Где используется хук в WordPress

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