| 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.3.3 |
| 7 |
* Author: YayCommerce |
| 8 |
* Author URI: https://yaycommerce.com |
| 9 |
* Text Domain: yaymail |
| 10 |
* WC requires at least: 3.0.0 |
| 11 |
* WC tested up to: 10.5.1 |
| 12 |
* Domain Path: /i18n/languages/ |
| 13 |
* |
| 14 |
* @package YayMail |
| 15 |
*/ |
| 16 |
|
| 17 |
namespace YayMail; |
| 18 |
|
| 19 |
defined( 'ABSPATH' ) || exit; |
| 20 |
|
| 21 |
if ( ! defined( 'YAYMAIL_PREFIX' ) ) { |
| 22 |
define( 'YAYMAIL_PREFIX', 'yaymail' ); |
| 23 |
} |
| 24 |
|
| 25 |
if ( ! defined( 'YAYMAIL_DEBUG' ) ) { |
| 26 |
define( 'YAYMAIL_DEBUG', false ); |
| 27 |
} |
| 28 |
|
| 29 |
if ( ! defined( 'YAYMAIL_VERSION' ) ) { |
| 30 |
define( 'YAYMAIL_VERSION', '4.3.3' ); |
| 31 |
} |
| 32 |
|
| 33 |
if ( ! defined( 'YAYMAIL_PLUGIN_URL' ) ) { |
| 34 |
define( 'YAYMAIL_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 35 |
} |
| 36 |
|
| 37 |
if ( ! defined( 'YAYMAIL_PLUGIN_PATH' ) ) { |
| 38 |
define( 'YAYMAIL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 39 |
} |
| 40 |
|
| 41 |
if ( ! defined( 'YAYMAIL_PLUGIN_BASENAME' ) ) { |
| 42 |
define( 'YAYMAIL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 43 |
} |
| 44 |
|
| 45 |
if ( ! defined( 'YAYMAIL_IS_DEVELOPMENT' ) ) { |
| 46 |
define( 'YAYMAIL_IS_DEVELOPMENT', false ); |
| 47 |
} |
| 48 |
|
| 49 |
if ( ! defined( 'YAYMAIL_REST_NAMESPACE' ) ) { |
| 50 |
define( 'YAYMAIL_REST_NAMESPACE', 'yaymail/v1' ); |
| 51 |
} |
| 52 |
|
| 53 |
$yaymail_has_required_deps = true; |
| 54 |
if ( function_exists( 'YayMail\\init' ) ) { |
| 55 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-exists.php'; |
| 56 |
$yaymail_has_required_deps = false; |
| 57 |
} |
| 58 |
|
| 59 |
if ( version_compare( PHP_VERSION, '7.2', '<' ) ) { |
| 60 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-minimum-php.php'; |
| 61 |
$yaymail_has_required_deps = false; |
| 62 |
} |
| 63 |
|
| 64 |
if ( version_compare( $GLOBALS['wp_version'], '5.2', '<' ) ) { |
| 65 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-minimum-wp.php'; |
| 66 |
$yaymail_has_required_deps = false; |
| 67 |
} |
| 68 |
|
| 69 |
if ( ! $yaymail_has_required_deps ) { |
| 70 |
add_action( |
| 71 |
'admin_init', |
| 72 |
function() { |
| 73 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 74 |
} |
| 75 |
); |
| 76 |
|
| 77 |
// Return early to prevent loading the plugin. |
| 78 |
return; |
| 79 |
} |
| 80 |
|
| 81 |
require_once YAYMAIL_PLUGIN_PATH . 'vendor/autoload.php'; |
| 82 |
|
| 83 |
/** |
| 84 |
* Initialize constants |
| 85 |
*/ |
| 86 |
Constants\ConstantsHandler::get_instance(); |
| 87 |
|
| 88 |
if ( ! function_exists( 'install_yaymail_admin_notice' ) ) { |
| 89 |
function install_yaymail_admin_notice() { |
| 90 |
?> |
| 91 |
<div class="error"> |
| 92 |
<p> |
| 93 |
<?php |
| 94 |
// translators: %s: search WooCommerce plugin link |
| 95 |
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>' ); |
| 96 |
?> |
| 97 |
</p> |
| 98 |
</div> |
| 99 |
<?php |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
if ( ! function_exists( 'YayMail\\init' ) ) { |
| 104 |
function init() { |
| 105 |
\YayMail\YayCommerceMenu\RegisterMenu::get_instance(); |
| 106 |
\YayMail\License\LicenseHandler::get_instance(); |
| 107 |
if ( ! function_exists( 'WC' ) ) { |
| 108 |
add_action( 'admin_notices', 'YayMail\\install_yaymail_admin_notice' ); |
| 109 |
} else { |
| 110 |
add_action( 'before_woocommerce_init', 'YayMail\\yaymail_enable_compatible_hpos' ); |
| 111 |
do_action( 'yaymail_before_init' ); |
| 112 |
|
| 113 |
\YayMail\Initialize::get_instance(); |
| 114 |
}//end if |
| 115 |
} |
| 116 |
}//end if |
| 117 |
|
| 118 |
if ( ! function_exists( 'yaymail_enable_compatible_hpos' ) ) { |
| 119 |
function yaymail_enable_compatible_hpos() { |
| 120 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 121 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 122 |
|
| 123 |
// Set compatible for addon |
| 124 |
$plugins = get_plugins(); |
| 125 |
foreach ( array_keys( $plugins ) as $key ) { |
| 126 |
$is_yaymail_addon = strpos( $key, 'yaymail-addon' ) !== false || strpos( $key, 'email-customizer' ) !== false; |
| 127 |
if ( $is_yaymail_addon ) { |
| 128 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $key, true ); |
| 129 |
} |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
if ( ! wp_installing() ) { |
| 136 |
add_action( 'plugins_loaded', 'YayMail\\init' ); |
| 137 |
} |
| 138 |
|
| 139 |
register_activation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'activate' ] ); |
| 140 |
register_deactivation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'deactivate' ] ); |
| 141 |
|