mailpoet
Last commit date
assets
1 day ago
generated
1 day ago
lang
1 day ago
lib
1 day ago
lib-3rd-party
4 months ago
vendor
1 day ago
vendor-prefixed
1 day ago
views
1 day ago
.gitleaksignore
1 year ago
index.php
3 years ago
license.txt
4 years ago
mailpoet-cron.php
4 months ago
mailpoet.php
1 day ago
mailpoet_initializer.php
3 months ago
readme.txt
1 day ago
mailpoet.php
181 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | |
| 5 | |
| 6 | /* |
| 7 | * Plugin Name: MailPoet |
| 8 | * Version: 5.28.1 |
| 9 | * Plugin URI: https://www.mailpoet.com |
| 10 | * Description: Create and send newsletters, post notifications and welcome emails from your WordPress. |
| 11 | * Author: MailPoet |
| 12 | * Author URI: https://www.mailpoet.com |
| 13 | * Requires at least: 6.9 |
| 14 | * Text Domain: mailpoet |
| 15 | * Domain Path: /lang |
| 16 | * |
| 17 | * WC requires at least: 10.6 |
| 18 | * WC tested up to: 10.7 |
| 19 | * |
| 20 | * @package WordPress |
| 21 | * @author MailPoet |
| 22 | * @since 3.0.0-beta.1 |
| 23 | */ |
| 24 | |
| 25 | $mailpoetPlugin = [ |
| 26 | 'version' => '5.28.1', |
| 27 | 'filename' => __FILE__, |
| 28 | 'path' => dirname(__FILE__), |
| 29 | 'autoloader' => dirname(__FILE__) . '/vendor/autoload_packages.php', |
| 30 | 'initializer' => dirname(__FILE__) . '/mailpoet_initializer.php', |
| 31 | ]; |
| 32 | |
| 33 | const MAILPOET_MINIMUM_REQUIRED_WP_VERSION = '6.9'; // L-1 version, not the latest |
| 34 | const MAILPOET_MINIMUM_REQUIRED_WOOCOMMERCE_VERSION = '10.6'; // L-1 version, not the latest |
| 35 | |
| 36 | |
| 37 | // Display WP version error notice |
| 38 | function mailpoet_wp_version_notice() { |
| 39 | $notice = str_replace( |
| 40 | '[link]', |
| 41 | '<a href="https://kb.mailpoet.com/article/152-minimum-requirements-for-mailpoet-3#wp_version" target="_blank">', |
| 42 | sprintf( |
| 43 | // translators: %s is the number of minimum WordPress version that MailPoet requires |
| 44 | __('MailPoet plugin requires WordPress version %s or newer. Please read our [link]instructions[/link] on how to resolve this issue.', 'mailpoet'), |
| 45 | MAILPOET_MINIMUM_REQUIRED_WP_VERSION |
| 46 | ) |
| 47 | ); |
| 48 | $notice = str_replace('[/link]', '</a>', $notice); |
| 49 | printf( |
| 50 | '<div class="error"><p>%1$s</p></div>', |
| 51 | wp_kses( |
| 52 | $notice, |
| 53 | [ |
| 54 | 'a' => [ |
| 55 | 'href' => true, |
| 56 | 'target' => true, |
| 57 | ], |
| 58 | ] |
| 59 | ) |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | // Display WooCommerce version error notice |
| 64 | function mailpoet_woocommerce_version_notice() { |
| 65 | $notice = str_replace( |
| 66 | '[link]', |
| 67 | '<a href="https://kb.mailpoet.com/article/152-minimum-requirements-for-mailpoet-3#woocommerce-version" target="_blank">', |
| 68 | sprintf( |
| 69 | // translators: %s is the number of minimum WooCommerce version that MailPoet requires |
| 70 | __('MailPoet plugin requires WooCommerce version %s or newer. Please update your WooCommerce plugin version, or read our [link]instructions[/link] for additional options on how to resolve this issue.', 'mailpoet'), |
| 71 | MAILPOET_MINIMUM_REQUIRED_WOOCOMMERCE_VERSION |
| 72 | ) |
| 73 | ); |
| 74 | $notice = str_replace('[/link]', '</a>', $notice); |
| 75 | printf( |
| 76 | '<div class="error"><p>%1$s</p></div>', |
| 77 | wp_kses( |
| 78 | $notice, |
| 79 | [ |
| 80 | 'a' => [ |
| 81 | 'href' => true, |
| 82 | 'target' => true, |
| 83 | ], |
| 84 | ] |
| 85 | ) |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | // Display IIS server error notice |
| 90 | function mailpoet_microsoft_iis_notice() { |
| 91 | $notice = __("MailPoet plugin cannot run under Microsoft's Internet Information Services (IIS) web server. We recommend that you use a web server powered by Apache or NGINX.", 'mailpoet'); |
| 92 | printf('<div class="error"><p>%1$s</p></div>', esc_html($notice)); |
| 93 | } |
| 94 | |
| 95 | // Display missing core dependencies error notice |
| 96 | function mailpoet_core_dependency_notice() { |
| 97 | $notice = __('MailPoet cannot start because it is missing core files. Please reinstall the plugin.', 'mailpoet'); |
| 98 | printf('<div class="error"><p>%1$s</p></div>', esc_html($notice)); |
| 99 | } |
| 100 | |
| 101 | // Display PHP version error notice |
| 102 | function mailpoet_php_version_notice() { |
| 103 | $noticeP1 = sprintf( |
| 104 | // translators: %1$s is the plugin name (MailPoet or MailPoet Premium), %2$s, %3$s, and %4$s are PHP version (e.g. "8.1.30") |
| 105 | __('%1$s requires PHP version %2$s or newer (%3$s recommended). You are running version %4$s.', 'mailpoet'), |
| 106 | 'MailPoet', |
| 107 | '7.4', |
| 108 | '8.1', |
| 109 | phpversion() |
| 110 | ); |
| 111 | |
| 112 | $noticeP2 = __('Please read our [link]instructions[/link] on how to upgrade your site.', 'mailpoet'); |
| 113 | $noticeP2 = str_replace( |
| 114 | '[link]', |
| 115 | '<a href="https://kb.mailpoet.com/article/251-upgrading-the-websites-php-version" target="_blank">', |
| 116 | $noticeP2 |
| 117 | ); |
| 118 | $noticeP2 = str_replace('[/link]', '</a>', $noticeP2); |
| 119 | |
| 120 | $allowedTags = [ |
| 121 | 'a' => [ |
| 122 | 'href' => true, |
| 123 | 'target' => true, |
| 124 | ], |
| 125 | ]; |
| 126 | printf( |
| 127 | '<div class="error"><p><strong>%s</strong></p><p>%s</p></div>', |
| 128 | esc_html($noticeP1), |
| 129 | wp_kses( |
| 130 | $noticeP2, |
| 131 | $allowedTags |
| 132 | ) |
| 133 | ); |
| 134 | } |
| 135 | |
| 136 | function mailpoet_check_requirements(array $mailpoetPlugin) { |
| 137 | |
| 138 | // Check for presence of core dependencies |
| 139 | if (!file_exists($mailpoetPlugin['autoloader']) || !file_exists($mailpoetPlugin['initializer'])) { |
| 140 | add_action('admin_notices', 'mailpoet_core_dependency_notice'); |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | // Check for Microsoft IIS server |
| 145 | if (isset($_SERVER['SERVER_SOFTWARE']) && strpos(strtolower(sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE']))), 'microsoft-iis') !== false) { |
| 146 | add_action('admin_notices', 'mailpoet_microsoft_iis_notice'); |
| 147 | return false; |
| 148 | } |
| 149 | |
| 150 | // Check for minimum supported WooCommerce version |
| 151 | if (!function_exists('is_plugin_active')) { |
| 152 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 153 | } |
| 154 | if (is_plugin_active('woocommerce/woocommerce.php')) { |
| 155 | $woocommerceVersion = get_plugin_data(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php', false, false)['Version']; |
| 156 | if (version_compare($woocommerceVersion, MAILPOET_MINIMUM_REQUIRED_WOOCOMMERCE_VERSION, '<')) { |
| 157 | add_action('admin_notices', 'mailpoet_woocommerce_version_notice'); |
| 158 | return false; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // Check for minimum supported WP version |
| 163 | if (version_compare(get_bloginfo('version'), MAILPOET_MINIMUM_REQUIRED_WP_VERSION, '<')) { |
| 164 | add_action('admin_notices', 'mailpoet_wp_version_notice'); |
| 165 | return false; |
| 166 | } |
| 167 | |
| 168 | // Check for minimum supported PHP version |
| 169 | if (version_compare(phpversion(), '7.4.0', '<')) { |
| 170 | add_action('admin_notices', 'mailpoet_php_version_notice'); |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | return true; |
| 175 | } |
| 176 | |
| 177 | // Initialize plugin |
| 178 | if (mailpoet_check_requirements($mailpoetPlugin)) { |
| 179 | require_once($mailpoetPlugin['initializer']); |
| 180 | } |
| 181 |