PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.4
YayMail – WooCommerce Email Customizer v4.4.4
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 3.4.2 3.4.3 All 55 releases
yaymail / yaymail.php
yaymail.php
195 lines 6.3 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.4
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 * Tested up to: 7.1
14 * Requires PHP: 5.4
15 * WC requires at least: 3.0.0
16 * WC tested up to: 11.0.1
17 * Domain Path: /i18n/languages/
18 *
19 * @package YayMail
20 */
21
22 namespace YayMail;
23
24 defined( 'ABSPATH' ) || exit;
25
26 if ( ! defined( 'YAYMAIL_PREFIX' ) ) {
27 define( 'YAYMAIL_PREFIX', 'yaymail' );
28 }
29
30 if ( ! defined( 'YAYMAIL_DEBUG' ) ) {
31 define( 'YAYMAIL_DEBUG', false );
32 }
33
34 if ( ! defined( 'YAYMAIL_VERSION' ) ) {
35 define( 'YAYMAIL_VERSION', '4.4.4' );
36 }
37
38 if ( ! defined( 'YAYMAIL_PLUGIN_URL' ) ) {
39 define( 'YAYMAIL_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
40 }
41
42 if ( ! defined( 'YAYMAIL_PLUGIN_PATH' ) ) {
43 define( 'YAYMAIL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
44 }
45
46 if ( ! defined( 'YAYMAIL_PLUGIN_BASENAME' ) ) {
47 define( 'YAYMAIL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
48 }
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
99 spl_autoload_register(
100 function ( $class ) {
101 $prefix = 'YayMail\\';
102
103 if ( strpos( $class, $prefix ) !== 0 ) {
104 return;
105 }
106
107 $relative = substr( $class, strlen( $prefix ) );
108 $relative_path = str_replace( '\\', '/', $relative ) . '.php';
109
110 $core_file = YAYMAIL_PLUGIN_PATH . 'src/' . $relative_path;
111
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 = 'email-builder-pro/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
129 );
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
141 if ( ! function_exists( 'install_yaymail_admin_notice' ) ) {
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 }
154 }
155
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' );
167
168 \YayMail\Initialize::get_instance();
169 }//end if
170 }
171 }//end if
172
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 );
177
178 // Set compatible for addon
179 $plugins = get_plugins();
180 foreach ( array_keys( $plugins ) as $key ) {
181 $is_yaymail_addon = strpos( $key, 'yaymail-addon' ) !== false || strpos( $key, 'email-customizer' ) !== false;
182 if ( $is_yaymail_addon ) {
183 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $key, true );
184 }
185 }
186 }
187 }
188 }
189
190 if ( ! wp_installing() ) {
191 add_action( 'plugins_loaded', 'YayMail\\init' );
192 }
193
194 register_activation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'activate' ] );
195 register_deactivation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'deactivate' ] );