WC_Email::get_option_or_transient
Get an option or transient for email preview.
Method of the class: WC_Email{}
Hooks from the method
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $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() WC Email::get option or transient code WC 10.8.1
protected 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 ) {
$plugin_id = $this->plugin_id;
$email_id = $this->id;
$transient = get_transient( "{$plugin_id}{$email_id}_{$key}" );
if ( false !== $transient ) {
$option = $transient ? $transient : $empty_value;
}
}
return $option;
}