| @@ -2,137 +2,139 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: YayMail - WooCommerce Email Customizer |
| 4 | 4 | * Plugin URI: https://yaycommerce.com/yaymail-woocommerce-email-customizer/ |
| 5 | 5 | * Description: Create awesome transactional emails with a drag and drop email builder |
| 6 | - * Version: 3.3 | |
| 6 | + * Version: 4.3.3 | |
| 7 | 7 | * Author: YayCommerce |
| 8 | 8 | * Author URI: https://yaycommerce.com |
| 9 | 9 | * Text Domain: yaymail |
| 10 | 10 | * WC requires at least: 3.0.0 |
| 11 | - * WC tested up to: 7.9.0 | |
| 11 | + * WC tested up to: 10.5.1 | |
| 12 | 12 | * Domain Path: /i18n/languages/ |
| 13 | + * | |
| 14 | + * @package YayMail | |
| 13 | 15 | */ |
| 14 | 16 | |
| 15 | 17 | namespace YayMail; |
| 16 | 18 | |
| 17 | -use YayMail\License\LicenseHandler; | |
| 18 | - | |
| 19 | 19 | defined( 'ABSPATH' ) || exit; |
| 20 | 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 | 21 | if ( ! defined( 'YAYMAIL_PREFIX' ) ) { |
| 33 | - define( 'YAYMAIL_PREFIX', 'yaymail' ); | |
| 22 | + define( 'YAYMAIL_PREFIX', 'yaymail' ); | |
| 34 | 23 | } |
| 35 | 24 | |
| 36 | 25 | if ( ! defined( 'YAYMAIL_DEBUG' ) ) { |
| 37 | - define( 'YAYMAIL_DEBUG', false ); | |
| 26 | + define( 'YAYMAIL_DEBUG', false ); | |
| 38 | 27 | } |
| 39 | 28 | |
| 40 | 29 | if ( ! defined( 'YAYMAIL_VERSION' ) ) { |
| 41 | - define( 'YAYMAIL_VERSION', '3.3' ); | |
| 30 | + define( 'YAYMAIL_VERSION', '4.3.3' ); | |
| 42 | 31 | } |
| 43 | 32 | |
| 44 | 33 | if ( ! defined( 'YAYMAIL_PLUGIN_URL' ) ) { |
| 45 | - define( 'YAYMAIL_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); | |
| 34 | + define( 'YAYMAIL_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); | |
| 46 | 35 | } |
| 47 | 36 | |
| 48 | 37 | if ( ! defined( 'YAYMAIL_PLUGIN_PATH' ) ) { |
| 49 | - define( 'YAYMAIL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); | |
| 38 | + define( 'YAYMAIL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); | |
| 50 | 39 | } |
| 51 | 40 | |
| 52 | 41 | if ( ! defined( 'YAYMAIL_PLUGIN_BASENAME' ) ) { |
| 53 | - define( 'YAYMAIL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); | |
| 42 | + define( 'YAYMAIL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); | |
| 54 | 43 | } |
| 55 | 44 | |
| 56 | -spl_autoload_register( | |
| 57 | - function ( $class ) { | |
| 58 | - $prefix = __NAMESPACE__; | |
| 59 | - $base_dir = __DIR__ . '/includes'; | |
| 45 | +if ( ! defined( 'YAYMAIL_IS_DEVELOPMENT' ) ) { | |
| 46 | + define( 'YAYMAIL_IS_DEVELOPMENT', false ); | |
| 47 | +} | |
| 60 | 48 | |
| 61 | - $len = strlen( $prefix ); | |
| 62 | - if ( strncmp( $prefix, $class, $len ) !== 0 ) { | |
| 63 | - return; | |
| 64 | - } | |
| 49 | +if ( ! defined( 'YAYMAIL_REST_NAMESPACE' ) ) { | |
| 50 | + define( 'YAYMAIL_REST_NAMESPACE', 'yaymail/v1' ); | |
| 51 | +} | |
| 65 | 52 | |
| 66 | - $relative_class_name = substr( $class, $len ); | |
| 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 | +} | |
| 67 | 58 | |
| 68 | - $file = $base_dir . str_replace( '\\', '/', $relative_class_name ) . '.php'; | |
| 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 | +} | |
| 69 | 63 | |
| 70 | - if ( file_exists( $file ) ) { | |
| 71 | - require $file; | |
| 72 | - } | |
| 73 | - } | |
| 74 | -); | |
| 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 | +} | |
| 75 | 68 | |
| 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 | - } | |
| 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; | |
| 89 | 79 | } |
| 90 | 80 | |
| 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(); | |
| 81 | +require_once YAYMAIL_PLUGIN_PATH . 'vendor/autoload.php'; | |
| 96 | 82 | |
| 97 | - $yaymail_addons = array_filter( | |
| 98 | - $plugins, | |
| 99 | - function( $key ) { | |
| 100 | - return strpos( $key, 'yaymail-addon' ) !== false || strpos( $key, 'email-customizer' ) !== false || strpos( $key, 'yaymail-premium-addon' ) !== false || strpos( $key, 'yaymail-conditional-logic' ) !== false; | |
| 101 | - }, | |
| 102 | - ARRAY_FILTER_USE_KEY | |
| 103 | - ); | |
| 83 | +/** | |
| 84 | + * Initialize constants | |
| 85 | + */ | |
| 86 | +Constants\ConstantsHandler::get_instance(); | |
| 104 | 87 | |
| 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 | - } | |
| 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 | + } | |
| 115 | 101 | } |
| 116 | 102 | |
| 117 | 103 | 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 | - } | |
| 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' ); | |
| 126 | 112 | |
| 127 | - Plugin::getInstance(); | |
| 128 | - I18n::loadPluginTextdomain(); | |
| 129 | - Page\Settings::getInstance(); | |
| 130 | - MailBuilder\WooTemplate::getInstance(); | |
| 131 | - MailBuilder\YaymailElement::getInstance(); | |
| 132 | - } | |
| 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 | 133 | } |
| 134 | 134 | |
| 135 | -add_action( 'plugins_loaded', 'YayMail\\init' ); | |
| 135 | +if ( ! wp_installing() ) { | |
| 136 | + add_action( 'plugins_loaded', 'YayMail\\init' ); | |
| 137 | +} | |
| 136 | 138 | |
| 137 | -register_activation_hook( __FILE__, array( 'YayMail\\Plugin', 'activate' ) ); | |
| 138 | -register_deactivation_hook( __FILE__, array( 'YayMail\\Plugin', 'deactivate' ) ); | |
| 139 | +register_activation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'activate' ] ); | |
| 140 | +register_deactivation_hook( __FILE__, [ \YayMail\Engine\ActDeact::class, 'deactivate' ] ); | |