Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer

Content_Renderer::create_rendering_contextpublicWC 1.0

Create a rendering context from filtered email context.

Method of the class: Content_Renderer{}

Returns

Rendering_Context.

Usage

$Content_Renderer = new Content_Renderer();
$Content_Renderer->create_rendering_context( ?string $language, ?WP_Post $post, ?WP_Block_Template $template ): Rendering_Context;
?string $language
.
Default: null
?WP_Post $post
.
Default: null
?WP_Block_Template $template
.
Default: null

Content_Renderer::create_rendering_context() code WC 11.0.0

public function create_rendering_context( ?string $language = null, ?WP_Post $post = null, ?WP_Block_Template $template = null ): Rendering_Context {
	/**
	 * Filter the email-specific context data passed to block renderers.
	 *
	 * This allows email sending systems to provide context data such as user ID,
	 * email address, order information, etc., that can be used by blocks during rendering.
	 *
	 * Blocks that need cart product information can derive it from the user_id or recipient_email
	 * using CartCheckoutUtils::get_cart_product_ids_for_user().
	 *
	 * @since 1.9.0
	 *
	 * @param array $email_context {
	 *     Email-specific context data.
	 *
	 *     @type int    $user_id         The ID of the user receiving the email.
	 *     @type string $recipient_email The recipient's email address.
	 *     @type int    $order_id        The order ID (for order-related emails).
	 *     @type string $email_type      The type of email being rendered.
	 *     @type bool   $is_rtl          Optional. Whether this email render should use RTL direction.
	 * }
	 * @param WP_Post|null           $post     Email post being rendered.
	 * @param WP_Block_Template|null $template Block template being rendered.
	 */
	$email_context = apply_filters( 'woocommerce_email_editor_rendering_email_context', array(), $post, $template );
	if ( ! is_array( $email_context ) ) {
		$email_context = array();
	}

	return new Rendering_Context( $this->theme_controller->get_theme(), $email_context, $language );
}