Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer

Content_Renderer::render_without_css_inline │ public │ WC 10.7.0

Render the content and collect CSS styles without inlining them.

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

Возвращает

array{html: string, styles: string}. Rendered HTML and collected CSS.

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

$Content_Renderer = new Content_Renderer();
$Content_Renderer->render_without_css_inline( $post, $template ): array;
$post(WP_Post) (обязательный)
Post object.
$template(WP_Block_Template) (обязательный)
Block template.

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

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

Код Content_Renderer::render_without_css_inline() WC 11.2.2

public function render_without_css_inline( WP_Post $post, WP_Block_Template $template ): array {
	if ( null === $this->rendering_context ) {
		$this->rendering_context = $this->create_rendering_context( null, $post, $template );
	}

	$this->set_template_globals( $post, $template );
	$this->initialize();
	try {
		/**
		 * Fires when rendering an email's content is about to start.
		 *
		 * @since 2.9.2
		 */
		do_action( 'woocommerce_email_editor_render_start' );
		$rendered_html = get_the_block_template_html();
	} finally {
		$this->reset();
		/**
		 * Fires when rendering an email's content has finished, whether it succeeded or threw.
		 *
		 * Counterpart of woocommerce_email_editor_render_start, for integrations that change global state
		 * for the render, such as hooked filters, and have to put it back afterwards. The renderer has
		 * already been reset when it fires, so a callback must not throw and must not expect render state.
		 *
		 * @since 2.18.0
		 */
		do_action( 'woocommerce_email_editor_render_end' );
	}

	return array(
		'html'   => $rendered_html,
		'styles' => $this->collect_styles( $post, $template ),
	);
}