WC_Email::get_option_or_transient()privateWC 1.0

Get an option or transient for email preview.

Method of the class: WC_Email{}

Hooks from the method

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->get_option_or_transient( $key, $empty_value );
$key(string) (required)
Option key.
$empty_value(mixed)
Value to use when option is empty.
Default: null

WC_Email::get_option_or_transient() code WC 9.7.1

private function get_option_or_transient( string $key, $empty_value = null ) {
	$option = $this->get_option( $key, $empty_value );

	/**
	 * This filter is documented in templates/emails/email-styles.php
	 *
	 * @since 9.6.0
	 * @param bool $is_email_preview Whether the email is being previewed.
	 */
	$is_email_preview = apply_filters( 'woocommerce_is_email_preview', false );
	if ( $is_email_preview ) {
		$email_id  = $this->id;
		$transient = get_transient( "woocommerce_{$email_id}_{$key}" );
		if ( false !== $transient ) {
			$option = $transient ? $transient : $empty_value;
		}
	}

	return $option;
}