PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | src/Initialize.php +45 -12 4.4.1 → 4.4.5 View file →
@@ -1,10 +1,9 @@
1 1 <?php
2 2 namespace YayMail;
3 3
4 -use YayMail\Elements\ElementsLoader;
4 +use YayMail\Utils\Helpers;
5 5 use YayMail\Emails\EmailsLoader;
6 -use YayMail\Engine\ActDeact;
7 6 use YayMail\Engine\Backend\SettingsPage;
8 7 use YayMail\Engine\RestAPI;
9 8 use YayMail\Integrations\IntegrationsLoader;
10 9 use YayMail\PostTypes\TemplatePostType;
@@ -13,8 +12,10 @@
13 12 use YayMail\TemplatePatterns\PatternsLoader;
14 13 use YayMail\TemplatePatterns\SectionTemplatesLoader;
15 14 use YayMail\PreviewEmail\PreviewEmailsLoader;
16 15 use YayMail\Notices\NoticeMain;
16 +use YayMail\SocialIcons\SocialIconEndpoint;
17 +use YayMail\TemplateLibrary\LibraryTemplateSchema;
17 18 use YayMail\TemplateLibrary\TemplateLibraryLoader;
18 19 /**
19 20 * YayMail Plugin Initializer
20 21 *
@@ -27,8 +28,13 @@
27 28 /**
28 29 * The Constructor that load the engine classes
29 30 */
30 31 protected function __construct() {
32 + // Procedural helpers (yaymail_version(), yaymail_is_wc_installed(), ...) are used by
33 + // every hook callback below, so load them here rather than inside init_core(), whose
34 + // hook is filterable and may run after init_modules().
35 + require_once Helpers::get_plugin_path() . 'src/Functions.php';
36 +
31 37 I18n::get_instance();
32 38
33 39 /**
34 40 * Handle init core
@@ -47,9 +53,8 @@
47 53 add_action( 'init', [ $this, 'init_modules' ] );
48 54 }
49 55
50 56 public function init_core() {
51 - require_once YAYMAIL_PLUGIN_PATH . 'src/Functions.php';
52 57 do_action( 'yaymail_init_start' );
53 58
54 59 /**
55 60 * Core Integrations
@@ -56,9 +61,8 @@
56 61 */
57 62 IntegrationsLoader::get_instance();
58 63
59 64 EmailsLoader::get_instance();
60 - ElementsLoader::get_instance();
61 65 ShortcodesLoader::get_instance();
62 66 }
63 67
64 68 public function init_modules() {
@@ -75,10 +79,8 @@
75 79 update_option( 'yaymail_version_backup', $version_current );
76 80 }
77 81 }
78 82
79 - ActDeact::get_instance();
80 -
81 83 if ( yaymail_is_wc_installed() ) {
82 84 WooHandler::get_instance();
83 85 }
84 86
@@ -88,20 +90,24 @@
88 90
89 91 PreviewEmailsLoader::get_instance();
90 92
91 93 /**
92 - * Supported templates
93 - */
94 - SupportedPlugins::get_instance();
95 -
96 - /**
97 94 * Core core filters
98 95 */
99 96
100 97 SectionTemplatesLoader::get_instance();
101 98 PatternsLoader::get_instance();
102 - TemplateLibraryLoader::get_instance();
103 99
100 + // Template Library only ships WooCommerce order-email designs (Completed,
101 + // RefundedOrder, NewOrder, ...). Skip its directory scan/class instantiation
102 + // (41 files, ~23k lines) and the per-request "SHOW TABLES" check when
103 + // WooCommerce isn't active -- it noticeably slows down every admin page load
104 + // on WP-only (yaymagic-email-builder) sites for a feature they can't use.
105 + if ( yaymail_is_wc_installed() ) {
106 + TemplateLibraryLoader::get_instance();
107 + LibraryTemplateSchema::maybe_create_table();
108 + }
109 +
104 110 /**
105 111 * Initialize rest api
106 112 */
107 113 RestAPI::get_instance();
@@ -118,7 +124,34 @@
118 124 * Notices
119 125 */
120 126 NoticeMain::get_instance();
121 127
128 + /**
129 + * Social icon dynamic tint endpoint
130 + */
131 + SocialIconEndpoint::get_instance();
132 +
122 133 do_action( 'yaymail_loaded' );
134 + }
135 +
136 + public function current_yaymail_version() {
137 + $version = 'yaymail/yaymail.php';
138 + if ( ! function_exists( 'is_plugin_active' ) ) {
139 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
140 + }
141 +
142 + $yaymail_files = [
143 + 'yaymail/yaymail.php',
144 + 'yaymail-pro/yaymail.php',
145 + 'email-customizer-for-woocommerce/yaymail.php',
146 + ];
147 +
148 + foreach ( $yaymail_files as $file ) {
149 + if ( is_plugin_active( $file ) || is_plugin_active_for_network( $file ) ) {
150 + $version = $file;
151 + break;
152 + }
153 + }
154 +
155 + return $version;
123 156 }
124 157 }