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

Filters the array of queried block templates array after they've been fetched.

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

add_filter( 'get_block_templates', 'wp_kama_get_block_templates_filter', 10, 3 );

/**
 * Function for `get_block_templates` filter-hook.
 * 
 * @param WP_Block_Template[] $query_result  Array of found block templates.
 * @param array               $query         Arguments to retrieve templates. All arguments are optional.
 * @param string              $template_type wp_template or wp_template_part.
 *
 * @return WP_Block_Template[]
 */
function wp_kama_get_block_templates_filter( $query_result, $query, $template_type ){

	// filter...
	return $query_result;
}
$query_result(WP_Block_Template[])
Array of found block templates.
$query(массив)

Arguments to retrieve templates. All arguments are optional.

  • slug__in(string[])
    List of slugs to include.

  • wp_id(int)
    Post ID of customized template.

  • area(строка)
    A 'wp_template_part_area' taxonomy value to filter by (for 'wp_template_part' template type only).

  • post_type(строка)
    Post type to get the templates for.
$template_type(строка)
wp_template or wp_template_part.

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

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

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

get_block_templates()
get_block_templates
wp-includes/block-template-utils.php 1043
return apply_filters( 'get_block_templates', $query_result, $query, $template_type );

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

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