Automattic\WooCommerce\Internal\EmailEditor

BlockEmailRenderer::get_email_post_by_wc_email │ private │ WC 1.0

Get the email post for a given WC_Email.

Only published posts are used for rendering: unpublished states (auto-draft, draft, trash) are editing scratchpads or removed content and must not affect outgoing emails.

Method of the class: BlockEmailRenderer{}

No Hooks.

Returns

\WP_Post|null.

Usage

// private - for code of main (parent) class only
$result = $this->get_email_post_by_wc_email( $email ): ?\WP_Post;
$email(WC_Email) (required)
WooCommerce email.

BlockEmailRenderer::get_email_post_by_wc_email() code WC 11.1.2

private function get_email_post_by_wc_email( \WC_Email $email ): ?\WP_Post {
	$email_post = $this->template_manager->get_email_post( $email->id );

	if ( $email_post && 'publish' !== $email_post->post_status ) {
		return null;
	}

	return $email_post;
}