| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
use YayMail\Page\Source\CustomPostType; |
| 8 |
|
| 9 |
$template = $args['email']->id; |
| 10 |
$custom_shortcode = new YayMail\MailBuilder\Shortcodes( $template ); |
| 11 |
|
| 12 |
if ( CustomPostType::postIDByTemplate( $template ) ) { |
| 13 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 14 |
$html = get_post_meta( $postID, '_yaymail_html', true ); |
| 15 |
} else { |
| 16 |
$html = ''; |
| 17 |
} |
| 18 |
if ( isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) && isset( $args['order'] ) && $args['order']->get_id() ) { |
| 19 |
$custom_shortcode->setOrderId( $args['order']->get_id(), $args['sent_to_admin'] ); |
| 20 |
if ( isset( $args['sent_to_admin'] ) ) { |
| 21 |
$custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'] ); |
| 22 |
} else { |
| 23 |
$custom_shortcode->shortCodesOrderDefined(); |
| 24 |
} |
| 25 |
$html = do_shortcode( $html ); |
| 26 |
} elseif ( isset( $args['email'] ) && isset( $args['email']->id ) ) { |
| 27 |
if ( 'customer_new_account' === $args['email']->id || 'customer_new_account_activation' === $args['email']->id || 'customer_reset_password' === $args['email']->id ) { |
| 28 |
$custom_shortcode->setOrderId( 0, $args['sent_to_admin'] ); |
| 29 |
$custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args ); |
| 30 |
$html = do_shortcode( $html ); |
| 31 |
} |
| 32 |
if ( 'cancelled_subscription' === $args['email']->id || 'expired_subscription' === $args['email']->id || 'suspended_subscription' === $args['email']->id ) { |
| 33 |
$custom_shortcode->setOrderId( $args['subscription']->data['parent_id'], $args['sent_to_admin'] ); |
| 34 |
$custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args ); |
| 35 |
$html = do_shortcode( $html ); |
| 36 |
} |
| 37 |
if ( 'ywsbs_subscription_admin_mail' === $args['email']->id || 'ywsbs_customer_subscription_cancelled' === $args['email']->id || 'ywsbs_customer_subscription_suspended' === $args['email']->id || 'ywsbs_customer_subscription_expired' === $args['email']->id || 'ywsbs_customer_subscription_before_expired' === $args['email']->id || 'ywsbs_customer_subscription_paused' === $args['email']->id || 'ywsbs_customer_subscription_resumed' === $args['email']->id || 'ywsbs_customer_subscription_request_payment' === $args['email']->id || 'ywsbs_customer_subscription_renew_reminder' === $args['email']->id || 'ywsbs_customer_subscription_payment_done' === $args['email']->id || 'ywsbs_customer_subscription_payment_failed' === $args['email']->id ) { |
| 38 |
$custom_shortcode->setOrderId( $args['subscription']->order->id, $args['sent_to_admin'] ); |
| 39 |
$custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args ); |
| 40 |
$html = do_shortcode( $html ); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
// Replace shortcode cannot do_shortcode |
| 45 |
$reg = '/\[yaymail.*?\]/m'; |
| 46 |
$html = preg_replace( $reg, '', $html ); |
| 47 |
|
| 48 |
echo html_entity_decode( $html, ENT_QUOTES, 'UTF-8' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 49 |
|