Automattic\WooCommerce\Internal\Admin\EmailPreview

EmailPreviewRestController::validate_email_typeprivateWC 1.0

Validate the email type.

Method of the class: EmailPreviewRestController{}

No Hooks.

Returns

true|false|WP_Error. True if the email type is valid, otherwise a WP_Error object.

Usage

// private - for code of main (parent) class only
$result = $this->validate_email_type( $email_type );
$email_type(string) (required)
The email type to validate.

EmailPreviewRestController::validate_email_type() code WC 10.8.1

private function validate_email_type( string $email_type ) {
	try {
		$this->email_preview->set_email_type( $email_type );
	} catch ( \InvalidArgumentException $e ) {
		return new WP_Error(
			'woocommerce_rest_invalid_email_type',
			__( 'Invalid email type.', 'woocommerce' ),
			array( 'status' => 400 ),
		);
	}
	return true;
}