| 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.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: 6.9 |
| 14 |
* Requires PHP: 5.4 |
| 15 |
* WC requires at least: 3.0.0 |
| 16 |
* WC tested up to: 10.6.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.3.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 |
$yaymail_has_required_deps = true; |
| 59 |
if ( function_exists( 'YayMail\\init' ) ) { |
| 60 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-exists.php'; |
| 61 |
$yaymail_has_required_deps = false; |
| 62 |
} |
| 63 |
|
| 64 |
if ( version_compare( PHP_VERSION, '7.2', '<' ) ) { |
| 65 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-minimum-php.php'; |
| 66 |
$yaymail_has_required_deps = false; |
| 67 |
} |
| 68 |
|
| 69 |
if ( version_compare( $GLOBALS['wp_version'], '5.2', '<' ) ) { |
| 70 |
require_once plugin_dir_path( __FILE__ ) . 'templates/fallbacks/fallback-minimum-wp.php'; |
| 71 |
$yaymail_has_required_deps = false; |
| 72 |
} |
| 73 |
|
| 74 |
if ( ! $yaymail_has_required_deps ) { |
| 75 |
add_action( |
| 76 |
'admin_init', |
| 77 |
function() { |
| 78 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 79 |
} |
| 80 |
); |
| 81 |
|
| 82 |
// Return early to prevent loading the plugin. |
| 83 |
return; |
| 84 |
} |
| 85 |
|
| 86 |
require_once YAYMAIL_PLUGIN_PATH . 'vendor/autoload.php'; |
| 87 |
|
| 88 |
/** |
| 89 |
* Initialize constants |
| 90 |
*/ |
| 91 |
Constants\ConstantsHandler::get_instance(); |
| 92 |
|
| 93 |
if ( ! function_exists( 'install_yaymail_admin_notice' ) ) { |
| 94 |
function install_yaymail_admin_notice() { |
| 95 |
?> |
| 96 |
<div class="error"> |
| 97 |
<p> |
| 98 |
<?php |
| 99 |
// translators: %s: search WooCommerce plugin link |
| 100 |
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>' ); |
| 101 |
?> |
| 102 |
</p> |
| 103 |
</div> |
| 104 |
<?php |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
if ( ! function_exists( 'YayMail\\init' ) ) { |
| 109 |
function init() { |
| 110 |
\YayMail\YayCommerceMenu\RegisterMenu::get_instance(); |
| 111 |
\YayMail\License\LicenseHandler::get_instance(); |
| 112 |
if ( ! function_exists( 'WC' ) ) { |
| 113 |
add_action( 'admin_notices', 'YayMail\\install_yaymail_admin_notice' ); |
| 114 |
} else { |
| 115 |
add_action( 'before_woocommerce_init', 'YayMail\\yaymail_enable_compatible_hpos' ); |
| 116 |
do_action( 'yaymail_before_init' ); |
| 117 |
|
| 118 |
\YayMail\Initialize::get_instance(); |
| 119 |
}//end if |
| 120 |
} |
| 121 |
}//end if |
| 122 |
|
| 123 |
if ( ! function_exists( 'yaymail_enable_compatible_hpos' ) ) { |
| 124 |
function yaymail_enable_compatible_hpos() { |
| 125 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 126 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 127 |
|
| 128 |
// Set compatible for addon |
| 129 |
$plugins = get_plugins(); |
| 130 |
foreach ( array_keys( $plugins ) as $key ) { |
| 131 |
$is_yaymail_addon = strpos( $key, 'yaymail-addon' ) !== false || strpos( $key, 'email-customizer' ) !== false; |
| 132 |
if ( $is_yaymail_addon ) { |
| 133 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $key, true ); |
| 134 |
} |
| 135 |
} |
| 136 |
} |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
if ( ! wp_installing() ) { |
| 141 |
add_action( 'plugins_loaded', 'YayMail\\init' ); |
| 142 |
} |
| 143 |
|
| 144 |
register_activation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'activate' ] ); |
| 145 |
register_deactivation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'deactivate' ] ); |
| 146 |
|