Automattic\WooCommerce\Internal\Admin\BlockTemplateRegistry

BlockTemplatesController::register_templates()publicWC 1.0

Register templates in the blocks endpoint.

Метод класса: BlockTemplatesController{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->register_templates();

Код BlockTemplatesController::register_templates() WC 8.1.1

public function register_templates() {
    $templates = $this->block_template_registry->get_all_registered();

    foreach ( $templates as $template ) {
        add_filter( 'pre_get_block_templates', function( $query_result, $query, $template_type ) use( $template ) {
            if ( ! isset( $query['area'] ) || $query['area'] !== $template->get_area() ) {
                return $query_result;
            }

            $wp_block_template = $this->template_transformer->transform( $template );
            $query_result[]    = $wp_block_template;
    
            return $query_result;
        }, 10, 3 );
    }
}