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 | yaymail.php +149 -87 3.3 → 4.4.5 View file →
@@ -2,137 +2,199 @@
2 2 /**
3 3 * Plugin Name: YayMail - WooCommerce Email Customizer
4 4 * Plugin URI: https://yaycommerce.com/yaymail-woocommerce-email-customizer/
5 5 * Description: Create awesome transactional emails with a drag and drop email builder
6 - * Version: 3.3
6 + * Version: 4.4.5
7 7 * Author: YayCommerce
8 8 * Author URI: https://yaycommerce.com
9 + * License: GPLv2 or later
10 + * License URI: https://www.gnu.org/licenses/gpl-2.0.html
9 11 * Text Domain: yaymail
12 + * Requires at least: 4.7
13 + * Tested up to: 7.1
14 + * Requires PHP: 5.4
10 15 * WC requires at least: 3.0.0
11 - * WC tested up to: 7.9.0
16 + * WC tested up to: 11.1.2
12 17 * Domain Path: /i18n/languages/
18 + *
19 + * @package YayMail
13 20 */
14 21
15 22 namespace YayMail;
16 23
17 -use YayMail\License\LicenseHandler;
18 -
19 24 defined( 'ABSPATH' ) || exit;
20 25
21 -if ( function_exists( 'YayMail\\init' ) ) {
22 - require_once plugin_dir_path( __FILE__ ) . 'includes/Fallback.php';
23 - add_action(
24 - 'admin_init',
25 - function() {
26 - deactivate_plugins( plugin_basename( __FILE__ ) );
27 - }
28 - );
29 - return;
30 -}
31 -
32 26 if ( ! defined( 'YAYMAIL_PREFIX' ) ) {
33 - define( 'YAYMAIL_PREFIX', 'yaymail' );
27 + define( 'YAYMAIL_PREFIX', 'yaymail' );
34 28 }
35 29
36 30 if ( ! defined( 'YAYMAIL_DEBUG' ) ) {
37 - define( 'YAYMAIL_DEBUG', false );
31 + define( 'YAYMAIL_DEBUG', false );
38 32 }
39 33
40 34 if ( ! defined( 'YAYMAIL_VERSION' ) ) {
41 - define( 'YAYMAIL_VERSION', '3.3' );
35 + define( 'YAYMAIL_VERSION', '4.4.5' );
42 36 }
43 37
44 38 if ( ! defined( 'YAYMAIL_PLUGIN_URL' ) ) {
45 - define( 'YAYMAIL_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
39 + define( 'YAYMAIL_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
46 40 }
47 41
48 42 if ( ! defined( 'YAYMAIL_PLUGIN_PATH' ) ) {
49 - define( 'YAYMAIL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
43 + define( 'YAYMAIL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
50 44 }
51 45
52 46 if ( ! defined( 'YAYMAIL_PLUGIN_BASENAME' ) ) {
53 - define( 'YAYMAIL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
47 + define( 'YAYMAIL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
54 48 }
55 49
50 +if ( ! defined( 'YAYMAIL_IS_DEVELOPMENT' ) ) {
51 + define( 'YAYMAIL_IS_DEVELOPMENT', false );
52 +}
53 +
54 +if ( ! defined( 'YAYMAIL_REST_NAMESPACE' ) ) {
55 + define( 'YAYMAIL_REST_NAMESPACE', 'yaymail/v1' );
56 +}
57 +
58 +if ( ! defined( 'YAYMAIL_MENU_PRIORITY' ) ) {
59 + define( 'YAYMAIL_MENU_PRIORITY', 100 );
60 +}
61 +
62 +// Lite customizer JS expects a single { global_header_elements, global_footer_elements }
63 +// object, not the multi-language array used by pro. SettingsPage gates on this flag.
64 +if ( ! defined( 'YAYMAIL_LITE_LEGACY_GHF_SHAPE' ) ) {
65 + define( 'YAYMAIL_LITE_LEGACY_GHF_SHAPE', true );
66 +}
67 +
68 +$yaymail_has_required_deps = true;
69 +if ( function_exists( 'YayMail\\init' ) ) {
70 + require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-exists.php';
71 + $yaymail_has_required_deps = false;
72 +}
73 +
74 +if ( version_compare( PHP_VERSION, '7.2', '<' ) ) {
75 + require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-minimum-php.php';
76 + $yaymail_has_required_deps = false;
77 +}
78 +
79 +if ( version_compare( $GLOBALS['wp_version'], '5.2', '<' ) ) {
80 + require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-minimum-wp.php';
81 + $yaymail_has_required_deps = false;
82 +}
83 +
84 +if ( ! $yaymail_has_required_deps ) {
85 + add_action(
86 + 'admin_init',
87 + function() {
88 + deactivate_plugins( plugin_basename( __FILE__ ) );
89 + }
90 + );
91 +
92 + // Return early to prevent loading the plugin.
93 + return;
94 +}
95 +
96 +require_once __DIR__ . '/vendor/autoload.php';
97 +require_once __DIR__ . '/YaymailPluginAdapter.php';
98 +
56 99 spl_autoload_register(
57 - function ( $class ) {
58 - $prefix = __NAMESPACE__;
59 - $base_dir = __DIR__ . '/includes';
100 + function ( $class ) {
101 + $prefix = 'YayMail\\';
60 102
61 - $len = strlen( $prefix );
62 - if ( strncmp( $prefix, $class, $len ) !== 0 ) {
63 - return;
64 - }
103 + if ( strpos( $class, $prefix ) !== 0 ) {
104 + return;
105 + }
65 106
66 - $relative_class_name = substr( $class, $len );
107 + $relative = substr( $class, strlen( $prefix ) );
108 + $relative_path = str_replace( '\\', '/', $relative ) . '.php';
67 109
68 - $file = $base_dir . str_replace( '\\', '/', $relative_class_name ) . '.php';
110 + $core_file = YAYMAIL_PLUGIN_PATH . 'src/' . $relative_path;
69 111
70 - if ( file_exists( $file ) ) {
71 - require $file;
72 - }
73 - }
112 + // Check if yay-wp-pro active
113 + if ( ! function_exists( 'is_plugin_active' ) ) {
114 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
115 + }
116 + $yaymail_wp_pro_plugin_file = 'yaymagic-email-builder-pro/yaymagic-email-builder.php';
117 + $yaymail_wp_pro_active = is_plugin_active( $yaymail_wp_pro_plugin_file ) || is_plugin_active_for_network( $yaymail_wp_pro_plugin_file );
118 +
119 + if ( $yaymail_wp_pro_active && defined( 'YAYWP_PLUGIN_PATH' ) ) {
120 + $core_file = YAYWP_PLUGIN_PATH . 'src/' . $relative_path;
121 + }
122 +
123 + if ( file_exists( $core_file ) ) {
124 + require $core_file;
125 + }
126 + },
127 + true,
128 + true
74 129 );
75 130
131 +// Declare this platform so shared core reads platform-specific values from the
132 +// registry instead of detecting the platform inline. Registered after the core
133 +// autoloader above so PlatformRegistry/PlatformInterface resolve, and before Initialize.
134 +\YayMail\Platform\PlatformRegistry::register( new \YayMail\Platform\YaymailPlatform() );
135 +
136 +/**
137 + * Initialize constants
138 + */
139 +Constants\ConstantsHandler::get_instance();
140 +
76 141 if ( ! function_exists( 'install_yaymail_admin_notice' ) ) {
77 - function install_yaymail_admin_notice() {
78 - ?>
79 - <div class="error">
80 - <p>
81 - <?php
82 - // translators: %s: search WooCommerce plugin link
83 - printf( 'YayMail ' . esc_html__( 'is enabled but not effective. It requires %1$sWooCommerce%2$s in order to work.', 'yaymail' ), '<a href="' . esc_url( admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' ) ) . '">', '</a>' );
84 - ?>
85 - </p>
86 - </div>
87 - <?php
88 - }
142 + function install_yaymail_admin_notice() {
143 + ?>
144 +<div class="error">
145 + <p>
146 + <?php
147 + // translators: %s: search WooCommerce plugin link
148 + printf( 'YayMail ' . esc_html__( 'is enabled but not effective. It requires %1$sWooCommerce%2$s in order to work.', 'yaymail' ), '<a href="' . esc_url( admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' ) ) . '">', '</a>' );
149 + ?>
150 + </p>
151 +</div>
152 + <?php
153 + }
89 154 }
90 155
91 -if ( ! function_exists( 'yaymail_enable_compatible_hpos' ) ) {
92 - function yaymail_enable_compatible_hpos() {
93 - if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
94 - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
95 - $plugins = get_plugins();
156 +if ( ! function_exists( 'YayMail\\init' ) ) {
157 + function init() {
158 + \YayMailScoped\YayCommerce\AdminShell\AdminShell::boot();
159 + \YayMailScoped\YayCommerce\AdminShell\AdminShell::register_plugin(
160 + new \YaymailPluginAdapter()
161 + );
162 + if ( ! function_exists( 'WC' ) ) {
163 + add_action( 'admin_notices', 'YayMail\\install_yaymail_admin_notice' );
164 + } else {
165 + add_action( 'before_woocommerce_init', 'YayMail\\yaymail_enable_compatible_hpos' );
166 + do_action( 'yaymail_before_init' );
96 167
97 - $yaymail_addons = array_filter(
98 - $plugins,
99 - function( $key ) {
100 - return strpos( $key, 'yaymail-addon' ) !== false || strpos( $key, 'email-customizer' ) !== false || strpos( $key, 'yaymail-premium-addon' ) !== false || strpos( $key, 'yaymail-conditional-logic' ) !== false;
101 - },
102 - ARRAY_FILTER_USE_KEY
103 - );
168 + \YayMail\Initialize::get_instance();
169 + }//end if
170 + }
171 +}//end if
104 172
105 - $addon_keys = array_keys( $yaymail_addons );
173 +if ( ! function_exists( 'yaymail_enable_compatible_hpos' ) ) {
174 + function yaymail_enable_compatible_hpos() {
175 + if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
176 + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
106 177
107 - array_map(
108 - function( $key ) {
109 - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $key, true );
110 - },
111 - $addon_keys
112 - );
113 - }
114 - }
178 + // Set compatible for active addons. Read the active-plugin options instead of
179 + // scanning the plugin directory: this hook fires on every request and that scans and
180 + // parses every plugin header on disk.
181 + $active_plugins = array_merge(
182 + (array) get_option( 'active_plugins', [] ),
183 + array_keys( (array) get_site_option( 'active_sitewide_plugins', [] ) )
184 + );
185 + foreach ( $active_plugins as $key ) {
186 + $is_yaymail_addon = strpos( $key, 'yaymail-addon' ) !== false || strpos( $key, 'email-customizer' ) !== false;
187 + if ( $is_yaymail_addon ) {
188 + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $key, true );
189 + }
190 + }
191 + }
192 + }
115 193 }
116 194
117 -if ( ! function_exists( 'YayMail\\init' ) ) {
118 - function init() {
119 - \YayMail\YayCommerceMenu\RegisterMenu::get_instance();
120 - LicenseHandler::get_instance();
121 - if ( ! function_exists( 'WC' ) ) {
122 - add_action( 'admin_notices', 'YayMail\\install_yaymail_admin_notice' );
123 - } else {
124 - add_action( 'before_woocommerce_init', 'YayMail\\yaymail_enable_compatible_hpos' );
125 - }
126 -
127 - Plugin::getInstance();
128 - I18n::loadPluginTextdomain();
129 - Page\Settings::getInstance();
130 - MailBuilder\WooTemplate::getInstance();
131 - MailBuilder\YaymailElement::getInstance();
132 - }
195 +if ( ! wp_installing() ) {
196 + add_action( 'plugins_loaded', 'YayMail\\init' );
133 197 }
134 198
135 -add_action( 'plugins_loaded', 'YayMail\\init' );
136 -
137 -register_activation_hook( __FILE__, array( 'YayMail\\Plugin', 'activate' ) );
138 -register_deactivation_hook( __FILE__, array( 'YayMail\\Plugin', 'deactivate' ) );
199 +register_activation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'activate' ] );
200 +register_deactivation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'deactivate' ] );