Automattic\WooCommerce\Blocks

BlockTemplatesController::render_woocommerce_template_part()publicWC 1.0

Renders the core/template-part block on the server.

This is done because the core handling for template parts only supports templates from the current theme, not from a plugin.

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

Хуков нет.

Возвращает

Строку. The render.

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

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->render_woocommerce_template_part( $attributes );
$attributes(массив) (обязательный)
The block attributes.

Код BlockTemplatesController::render_woocommerce_template_part() WC 9.5.1

public function render_woocommerce_template_part( $attributes ) {
	if ( isset( $attributes['theme'] ) && 'woocommerce/woocommerce' === $attributes['theme'] ) {
		$template_part = get_block_template( $attributes['theme'] . '//' . $attributes['slug'], 'wp_template_part' );

		if ( $template_part && ! empty( $template_part->content ) ) {
			$content = do_blocks( $template_part->content );

			if ( empty( $attributes['tagName'] ) || tag_escape( $attributes['tagName'] ) !== $attributes['tagName'] ) {
				$html_tag = 'div';
			} else {
				$html_tag = esc_attr( $attributes['tagName'] );
			}
			$wrapper_attributes = get_block_wrapper_attributes();

			return "<$html_tag $wrapper_attributes>" . str_replace( ']]>', ']]&gt;', $content ) . "</$html_tag>";
		}
	}
	return function_exists( '\gutenberg_render_block_core_template_part' ) ? \gutenberg_render_block_core_template_part( $attributes ) : \render_block_core_template_part( $attributes );
}