PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.7
YayMail – WooCommerce Email Customizer v4.4.7
4.4.7 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 All 58 releases
yaymail / yaymail.php

yaymail.php in YayMail – WooCommerce Email Customizer 4.4.7, at yaymail.php

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