mailpoet.php
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | |
| 5 | |
| 6 | /* |
| 7 | * Plugin Name: MailPoet |
| 8 | * Version: 4.5.2 |
| 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: 5.8 |
| 14 | * Text Domain: mailpoet |
| 15 | * Domain Path: /lang |
| 16 | * |
| 17 | * WC requires at least: 6.9.0 |
| 18 | * WC tested up to: 7.1.0 |
| 19 | * |
| 20 | * @package WordPress |
| 21 | * @author MailPoet |
| 22 | * @since 3.0.0-beta.1 |
| 23 | */ |
| 24 | |
| 25 | $mailpoetPlugin = [ |
| 26 | 'version' => '4.5.2', |
| 27 | 'filename' => __FILE__, |
| 28 | 'path' => dirname(__FILE__), |
| 29 | 'autoloader' => dirname(__FILE__) . '/vendor/autoload.php', |
| 30 | 'initializer' => dirname(__FILE__) . '/mailpoet_initializer.php', |
| 31 | ]; |
| 32 | |
| 33 | function mailpoet_deactivate_plugin() { |
| 34 | deactivate_plugins(plugin_basename(__FILE__)); |
| 35 | if (!empty($_GET['activate'])) { |
| 36 | unset($_GET['activate']); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // Check for minimum supported WP version |
| 41 | if (version_compare(get_bloginfo('version'), '5.8', '<')) { |
| 42 | add_action('admin_notices', 'mailpoet_wp_version_notice'); |
| 43 | // deactivate the plugin |
| 44 | add_action('admin_init', 'mailpoet_deactivate_plugin'); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | // Check for minimum supported PHP version |
| 49 | if (version_compare(phpversion(), '7.2.0', '<')) { |
| 50 | add_action('admin_notices', 'mailpoet_php_version_notice'); |
| 51 | // deactivate the plugin |
| 52 | add_action('admin_init', 'mailpoet_deactivate_plugin'); |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | // Display WP version error notice |
| 57 | function mailpoet_wp_version_notice() { |
| 58 | $notice = str_replace( |
| 59 | '[link]', |
| 60 | '<a href="https://kb.mailpoet.com/article/152-minimum-requirements-for-mailpoet-3#wp_version" target="_blank">', |
| 61 | __('MailPoet plugin requires WordPress version 5.8 or newer. Please read our [link]instructions[/link] on how to resolve this issue.', 'mailpoet') |
| 62 | ); |
| 63 | $notice = str_replace('[/link]', '</a>', $notice); |
| 64 | printf( |
| 65 | '<div class="error"><p>%1$s</p></div>', |
| 66 | wp_kses( |
| 67 | $notice, |
| 68 | [ |
| 69 | 'a' => [ |
| 70 | 'href' => true, |
| 71 | 'target' => true, |
| 72 | ], |
| 73 | ] |
| 74 | ) |
| 75 | ); |
| 76 | } |
| 77 | |
| 78 | // Display PHP version error notice |
| 79 | function mailpoet_php_version_notice() { |
| 80 | $noticeP1 = __('MailPoet requires PHP version 7.2 or newer (8.0 recommended). You are running version [version].', 'mailpoet'); |
| 81 | $noticeP1 = str_replace('[version]', phpversion(), $noticeP1); |
| 82 | |
| 83 | $noticeP2 = __('Please read our [link]instructions[/link] on how to upgrade your site.', 'mailpoet'); |
| 84 | $noticeP2 = str_replace( |
| 85 | '[link]', |
| 86 | '<a href="https://kb.mailpoet.com/article/251-upgrading-the-websites-php-version" target="_blank">', |
| 87 | $noticeP2 |
| 88 | ); |
| 89 | $noticeP2 = str_replace('[/link]', '</a>', $noticeP2); |
| 90 | |
| 91 | $noticeP3 = __('If you can’t upgrade the PHP version, [link]install this version[/link] of MailPoet. Remember to not update MailPoet ever again!', 'mailpoet'); |
| 92 | $noticeP3 = str_replace( |
| 93 | '[link]', |
| 94 | '<a href="https://downloads.wordpress.org/plugin/mailpoet.3.74.3.zip" target="_blank">', |
| 95 | $noticeP3 |
| 96 | ); |
| 97 | $noticeP3 = str_replace('[/link]', '</a>', $noticeP3); |
| 98 | |
| 99 | $allowedTags = [ |
| 100 | 'a' => [ |
| 101 | 'href' => true, |
| 102 | 'target' => true, |
| 103 | ], |
| 104 | ]; |
| 105 | printf( |
| 106 | '<div class="error"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>', |
| 107 | esc_html($noticeP1), |
| 108 | wp_kses( |
| 109 | $noticeP2, |
| 110 | $allowedTags |
| 111 | ), |
| 112 | wp_kses( |
| 113 | $noticeP3, |
| 114 | $allowedTags |
| 115 | ) |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | if (isset($_SERVER['SERVER_SOFTWARE']) && strpos(strtolower(sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE']))), 'microsoft-iis') !== false) { |
| 120 | add_action('admin_notices', 'mailpoet_microsoft_iis_notice'); |
| 121 | // deactivate the plugin |
| 122 | add_action('admin_init', 'mailpoet_deactivate_plugin'); |
| 123 | return; |
| 124 | } |
| 125 | |
| 126 | // Display IIS server error notice |
| 127 | function mailpoet_microsoft_iis_notice() { |
| 128 | $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'); |
| 129 | printf('<div class="error"><p>%1$s</p></div>', esc_html($notice)); |
| 130 | } |
| 131 | |
| 132 | // Check for presence of core dependencies |
| 133 | if (!file_exists($mailpoetPlugin['autoloader']) || !file_exists($mailpoetPlugin['initializer'])) { |
| 134 | add_action('admin_notices', 'mailpoet_core_dependency_notice'); |
| 135 | // deactivate the plugin |
| 136 | add_action('admin_init', 'mailpoet_deactivate_plugin'); |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | // Display missing core dependencies error notice |
| 141 | function mailpoet_core_dependency_notice() { |
| 142 | $notice = __('MailPoet cannot start because it is missing core files. Please reinstall the plugin.', 'mailpoet'); |
| 143 | printf('<div class="error"><p>%1$s</p></div>', esc_html($notice)); |
| 144 | } |
| 145 | |
| 146 | // Initialize plugin |
| 147 | require_once($mailpoetPlugin['initializer']); |
| 148 |