| 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.1 |
| 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.0 |
| 14 |
* Requires PHP: 5.4 |
| 15 |
* WC requires at least: 3.0.0 |
| 16 |
* WC tested up to: 10.7.0 |
| 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.1' ); |
| 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 |
$yaymail_has_required_deps = true; |
| 63 |
if ( function_exists( 'YayMail\\init' ) ) { |
| 64 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-exists.php'; |
| 65 |
$yaymail_has_required_deps = false; |
| 66 |
} |
| 67 |
|
| 68 |
if ( version_compare( PHP_VERSION, '7.2', '<' ) ) { |
| 69 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-minimum-php.php'; |
| 70 |
$yaymail_has_required_deps = false; |
| 71 |
} |
| 72 |
|
| 73 |
if ( version_compare( $GLOBALS['wp_version'], '5.2', '<' ) ) { |
| 74 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-minimum-wp.php'; |
| 75 |
$yaymail_has_required_deps = false; |
| 76 |
} |
| 77 |
|
| 78 |
if ( ! $yaymail_has_required_deps ) { |
| 79 |
add_action( |
| 80 |
'admin_init', |
| 81 |
function() { |
| 82 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 83 |
} |
| 84 |
); |
| 85 |
|
| 86 |
// Return early to prevent loading the plugin. |
| 87 |
return; |
| 88 |
} |
| 89 |
|
| 90 |
require_once __DIR__ . '/vendor/autoload.php'; |
| 91 |
require_once __DIR__ . '/YaymailPluginAdapter.php'; |
| 92 |
|
| 93 |
spl_autoload_register( |
| 94 |
function ( $class ) { |
| 95 |
$prefix = 'YayMail\\'; |
| 96 |
|
| 97 |
if ( strpos( $class, $prefix ) !== 0 ) { |
| 98 |
return; |
| 99 |
} |
| 100 |
|
| 101 |
$relative = substr( $class, strlen( $prefix ) ); |
| 102 |
$relative_path = str_replace( '\\', '/', $relative ) . '.php'; |
| 103 |
|
| 104 |
$core_file = YAYMAIL_PLUGIN_PATH . 'src/' . $relative_path; |
| 105 |
|
| 106 |
// Check if yay-wp-pro active |
| 107 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 108 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 109 |
} |
| 110 |
$yaymail_wp_pro_plugin_file = 'yay-wp-email-customizer-pro/yay-wp-email-customizer.php'; |
| 111 |
$yaymail_wp_pro_active = is_plugin_active( $yaymail_wp_pro_plugin_file ) || is_plugin_active_for_network( $yaymail_wp_pro_plugin_file ); |
| 112 |
|
| 113 |
if ( $yaymail_wp_pro_active ) { |
| 114 |
$core_file = YAYMAIL_WP_PLUGIN_PATH . 'src/' . $relative_path; |
| 115 |
} |
| 116 |
|
| 117 |
if ( file_exists( $core_file ) ) { |
| 118 |
require $core_file; |
| 119 |
} |
| 120 |
}, |
| 121 |
true, |
| 122 |
true |
| 123 |
); |
| 124 |
/** |
| 125 |
* Initialize constants |
| 126 |
*/ |
| 127 |
Constants\ConstantsHandler::get_instance(); |
| 128 |
// Notices\NoticeWPMail::get_instance(); |
| 129 |
|
| 130 |
if ( ! function_exists( 'install_yaymail_admin_notice' ) ) { |
| 131 |
function install_yaymail_admin_notice() { |
| 132 |
?> |
| 133 |
<div class="error"> |
| 134 |
<p> |
| 135 |
<?php |
| 136 |
// translators: %s: search WooCommerce plugin link |
| 137 |
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>' ); |
| 138 |
?> |
| 139 |
</p> |
| 140 |
</div> |
| 141 |
<?php |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
if ( ! function_exists( 'YayMail\\init' ) ) { |
| 146 |
function init() { |
| 147 |
\YayMailScoped\YayCommerce\AdminShell\AdminShell::boot(); |
| 148 |
\YayMailScoped\YayCommerce\AdminShell\AdminShell::register_plugin( |
| 149 |
new \YaymailPluginAdapter() |
| 150 |
); |
| 151 |
if ( ! function_exists( 'WC' ) ) { |
| 152 |
add_action( 'admin_notices', 'YayMail\\install_yaymail_admin_notice' ); |
| 153 |
} else { |
| 154 |
add_action( 'before_woocommerce_init', 'YayMail\\yaymail_enable_compatible_hpos' ); |
| 155 |
do_action( 'yaymail_before_init' ); |
| 156 |
|
| 157 |
\YayMail\Initialize::get_instance(); |
| 158 |
}//end if |
| 159 |
} |
| 160 |
}//end if |
| 161 |
|
| 162 |
if ( ! function_exists( 'yaymail_enable_compatible_hpos' ) ) { |
| 163 |
function yaymail_enable_compatible_hpos() { |
| 164 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 165 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 166 |
|
| 167 |
// Set compatible for addon |
| 168 |
$plugins = get_plugins(); |
| 169 |
foreach ( array_keys( $plugins ) as $key ) { |
| 170 |
$is_yaymail_addon = strpos( $key, 'yaymail-addon' ) !== false || strpos( $key, 'email-customizer' ) !== false; |
| 171 |
if ( $is_yaymail_addon ) { |
| 172 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $key, true ); |
| 173 |
} |
| 174 |
} |
| 175 |
} |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
if ( ! wp_installing() ) { |
| 180 |
add_action( 'plugins_loaded', 'YayMail\\init' ); |
| 181 |
} |
| 182 |
|
| 183 |
register_activation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'activate' ] ); |
| 184 |
register_deactivation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'deactivate' ] ); |