| 1 |
<?php |
| 2 |
|
| 3 |
namespace YayMail\Shortcodes; |
| 4 |
|
| 5 |
use YayMail\Shortcodes\OrderDetails\OrderDetailsShortcodes; |
| 6 |
use YayMail\Shortcodes\ShippingShortcodes; |
| 7 |
use YayMail\Shortcodes\BillingShortcodes; |
| 8 |
use YayMail\Shortcodes\PaymentsShortcodes; |
| 9 |
use YayMail\Shortcodes\NewUsersShortcodes; |
| 10 |
use YayMail\Shortcodes\ResetPasswordsShortcodes; |
| 11 |
use YayMail\Shortcodes\LegacyCustomShortcodes; |
| 12 |
use YayMail\Utils\SingletonTrait; |
| 13 |
|
| 14 |
/** |
| 15 |
* @method: static ShortcodesLoader get_instance() |
| 16 |
*/ |
| 17 |
class ShortcodesLoader { |
| 18 |
|
| 19 |
use SingletonTrait; |
| 20 |
|
| 21 |
private $shortcode_intances = []; |
| 22 |
|
| 23 |
protected function __construct() { |
| 24 |
|
| 25 |
$this->shortcode_intances = [ |
| 26 |
CommonShortcodes::get_instance(), |
| 27 |
|
| 28 |
LegacyCustomShortcodes::get_instance(), |
| 29 |
|
| 30 |
]; |
| 31 |
|
| 32 |
if ( function_exists( 'WC' ) && defined( 'YAYMAIL_VERSION' ) ) { |
| 33 |
$this->shortcode_intances = array_merge( |
| 34 |
$this->shortcode_intances, |
| 35 |
[ |
| 36 |
OrderDetailsShortcodes::get_instance(), |
| 37 |
HookShortcodes::get_instance(), |
| 38 |
ShippingShortcodes::get_instance(), |
| 39 |
BillingShortcodes::get_instance(), |
| 40 |
PaymentsShortcodes::get_instance(), |
| 41 |
NewUsersShortcodes::get_instance(), |
| 42 |
ResetPasswordsShortcodes::get_instance(), |
| 43 |
OrderMetaShortcodes::get_instance(), |
| 44 |
/** |
| 45 |
* @since 4.0.6 |
| 46 |
*/ |
| 47 |
RefundShortcodes::get_instance(), |
| 48 |
] |
| 49 |
); |
| 50 |
} |
| 51 |
|
| 52 |
do_action( 'yaymail_register_shortcodes', $this ); |
| 53 |
|
| 54 |
foreach ( yaymail_get_emails() as $email ) { |
| 55 |
|
| 56 |
do_action( 'yaymail_' . YAYMAIL_ALL_EMAILS . '_register_shortcodes', $email ); |
| 57 |
do_action( 'yaymail_' . $email->get_id() . '_register_shortcodes', $email ); |
| 58 |
|
| 59 |
if ( in_array( YAYMAIL_NON_ORDER_EMAILS, $email->email_types, true ) ) { |
| 60 |
do_action( 'yaymail_' . YAYMAIL_NON_ORDER_EMAILS . '_register_shortcodes', $email ); |
| 61 |
continue; |
| 62 |
} |
| 63 |
if ( in_array( YAYMAIL_WITH_ORDER_EMAILS, $email->email_types, true ) ) { |
| 64 |
do_action( 'yaymail_' . YAYMAIL_WITH_ORDER_EMAILS . '_register_shortcodes', $email ); |
| 65 |
continue; |
| 66 |
} |
| 67 |
|
| 68 |
if ( in_array( YAYMAIL_GLOBAL_HEADER_FOOTER_ID, $email->email_types, true ) ) { |
| 69 |
do_action( 'yaymail_' . YAYMAIL_GLOBAL_HEADER_FOOTER_ID . '_register_shortcodes', $email ); |
| 70 |
continue; |
| 71 |
} |
| 72 |
} |
| 73 |
} |
| 74 |
} |
| 75 |
|