| 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: 3.2.9 |
| 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: 7.8.0 |
| 12 |
* Domain Path: /i18n/languages/ |
| 13 |
*/ |
| 14 |
|
| 15 |
namespace YayMail; |
| 16 |
|
| 17 |
use YayMail\License\LicenseHandler; |
| 18 |
|
| 19 |
defined( 'ABSPATH' ) || exit; |
| 20 |
|
| 21 |
if ( function_exists( 'YayMail\\init' ) ) { |
| 22 |
require_once plugin_dir_path( __FILE__ ) . 'includes/Fallback.php'; |
| 23 |
add_action( |
| 24 |
'admin_init', |
| 25 |
function() { |
| 26 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 27 |
} |
| 28 |
); |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
if ( ! defined( 'YAYMAIL_PREFIX' ) ) { |
| 33 |
define( 'YAYMAIL_PREFIX', 'yaymail' ); |
| 34 |
} |
| 35 |
|
| 36 |
if ( ! defined( 'YAYMAIL_DEBUG' ) ) { |
| 37 |
define( 'YAYMAIL_DEBUG', false ); |
| 38 |
} |
| 39 |
|
| 40 |
if ( ! defined( 'YAYMAIL_VERSION' ) ) { |
| 41 |
define( 'YAYMAIL_VERSION', '3.2.9' ); |
| 42 |
} |
| 43 |
|
| 44 |
if ( ! defined( 'YAYMAIL_PLUGIN_URL' ) ) { |
| 45 |
define( 'YAYMAIL_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 46 |
} |
| 47 |
|
| 48 |
if ( ! defined( 'YAYMAIL_PLUGIN_PATH' ) ) { |
| 49 |
define( 'YAYMAIL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 50 |
} |
| 51 |
|
| 52 |
if ( ! defined( 'YAYMAIL_PLUGIN_BASENAME' ) ) { |
| 53 |
define( 'YAYMAIL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 54 |
} |
| 55 |
|
| 56 |
spl_autoload_register( |
| 57 |
function ( $class ) { |
| 58 |
$prefix = __NAMESPACE__; |
| 59 |
$base_dir = __DIR__ . '/includes'; |
| 60 |
|
| 61 |
$len = strlen( $prefix ); |
| 62 |
if ( strncmp( $prefix, $class, $len ) !== 0 ) { |
| 63 |
return; |
| 64 |
} |
| 65 |
|
| 66 |
$relative_class_name = substr( $class, $len ); |
| 67 |
|
| 68 |
$file = $base_dir . str_replace( '\\', '/', $relative_class_name ) . '.php'; |
| 69 |
|
| 70 |
if ( file_exists( $file ) ) { |
| 71 |
require $file; |
| 72 |
} |
| 73 |
} |
| 74 |
); |
| 75 |
|
| 76 |
if ( ! function_exists( 'install_yaymail_admin_notice' ) ) { |
| 77 |
function install_yaymail_admin_notice() { |
| 78 |
?> |
| 79 |
<div class="error"> |
| 80 |
<p> |
| 81 |
<?php |
| 82 |
// translators: %s: search WooCommerce plugin link |
| 83 |
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>' ); |
| 84 |
?> |
| 85 |
</p> |
| 86 |
</div> |
| 87 |
<?php |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
if ( ! function_exists( 'yaymail_enable_compatible_hpos' ) ) { |
| 92 |
function yaymail_enable_compatible_hpos() { |
| 93 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 94 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 95 |
$plugins = get_plugins(); |
| 96 |
|
| 97 |
$yaymail_addons = array_filter( |
| 98 |
$plugins, |
| 99 |
function( $key ) { |
| 100 |
return strpos( $key, 'yaymail-addon' ) !== false; |
| 101 |
}, |
| 102 |
ARRAY_FILTER_USE_KEY |
| 103 |
); |
| 104 |
|
| 105 |
$addon_keys = array_keys( $yaymail_addons ); |
| 106 |
|
| 107 |
array_map( |
| 108 |
function( $key ) { |
| 109 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $key, true ); |
| 110 |
}, |
| 111 |
$addon_keys |
| 112 |
); |
| 113 |
} |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
if ( ! function_exists( 'YayMail\\init' ) ) { |
| 118 |
function init() { |
| 119 |
\YayMail\YayCommerceMenu\RegisterMenu::get_instance(); |
| 120 |
LicenseHandler::get_instance(); |
| 121 |
if ( ! function_exists( 'WC' ) ) { |
| 122 |
add_action( 'admin_notices', 'YayMail\\install_yaymail_admin_notice' ); |
| 123 |
} else { |
| 124 |
add_action( 'before_woocommerce_init', 'YayMail\\yaymail_enable_compatible_hpos' ); |
| 125 |
} |
| 126 |
|
| 127 |
Plugin::getInstance(); |
| 128 |
I18n::loadPluginTextdomain(); |
| 129 |
Page\Settings::getInstance(); |
| 130 |
MailBuilder\WooTemplate::getInstance(); |
| 131 |
MailBuilder\YaymailElement::getInstance(); |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
add_action( 'plugins_loaded', 'YayMail\\init' ); |
| 136 |
|
| 137 |
register_activation_hook( __FILE__, array( 'YayMail\\Plugin', 'activate' ) ); |
| 138 |
register_deactivation_hook( __FILE__, array( 'YayMail\\Plugin', 'deactivate' ) ); |
| 139 |
|