mailpoet.php
| 1 | <?php |
| 2 | |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | |
| 5 | |
| 6 | /* |
| 7 | * Plugin Name: MailPoet 3 (New) |
| 8 | * Version: 3.41.0 |
| 9 | * Plugin URI: http://www.mailpoet.com |
| 10 | * Description: Create and send newsletters, post notifications and welcome emails from your WordPress. |
| 11 | * Author: MailPoet |
| 12 | * Author URI: http://www.mailpoet.com |
| 13 | * Requires at least: 4.7 |
| 14 | * Tested up to: 5.1 |
| 15 | * |
| 16 | * @package WordPress |
| 17 | * @author MailPoet |
| 18 | * @since 3.0.0-beta.1 |
| 19 | */ |
| 20 | |
| 21 | $mailpoet_plugin = [ |
| 22 | 'version' => '3.41.0', |
| 23 | 'filename' => __FILE__, |
| 24 | 'path' => dirname(__FILE__), |
| 25 | 'autoloader' => dirname(__FILE__) . '/vendor/autoload.php', |
| 26 | 'initializer' => dirname(__FILE__) . '/mailpoet_initializer.php', |
| 27 | ]; |
| 28 | |
| 29 | function mailpoet_deactivate_plugin() { |
| 30 | deactivate_plugins(plugin_basename(__FILE__)); |
| 31 | if (!empty($_GET['activate'])) { |
| 32 | unset($_GET['activate']); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | // Check for minimum supported WP version |
| 37 | if (version_compare(get_bloginfo('version'), '4.6', '<')) { |
| 38 | add_action('admin_notices', 'mailpoet_wp_version_notice'); |
| 39 | // deactivate the plugin |
| 40 | add_action('admin_init', 'mailpoet_deactivate_plugin'); |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | // Check for minimum supported PHP version |
| 45 | if (version_compare(phpversion(), '5.6.0', '<')) { |
| 46 | add_action('admin_notices', 'mailpoet_php_version_notice'); |
| 47 | // deactivate the plugin |
| 48 | add_action('admin_init', 'mailpoet_deactivate_plugin'); |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | // Display WP version error notice |
| 53 | function mailpoet_wp_version_notice() { |
| 54 | $notice = str_replace( |
| 55 | '[link]', |
| 56 | '<a href="https://kb.mailpoet.com/article/152-minimum-requirements-for-mailpoet-3#wp_version" target="_blank">', |
| 57 | __('MailPoet plugin requires WordPress version 4.6 or newer. Please read our [link]instructions[/link] on how to resolve this issue.', 'mailpoet') |
| 58 | ); |
| 59 | $notice = str_replace('[/link]', '</a>', $notice); |
| 60 | printf('<div class="error"><p>%1$s</p></div>', $notice); |
| 61 | } |
| 62 | |
| 63 | // Display PHP version error notice |
| 64 | function mailpoet_php_version_notice() { |
| 65 | $notice = str_replace( |
| 66 | '[link]', |
| 67 | '<a href="https://kb.mailpoet.com/article/152-minimum-requirements-for-mailpoet-3#php_version" target="_blank">', |
| 68 | __('MailPoet requires PHP version 5.6 or newer (version 7.2 recommended). Please read our [link]instructions[/link] on how to upgrade your site.', 'mailpoet') |
| 69 | ); |
| 70 | $notice = str_replace('[/link]', '</a>', $notice); |
| 71 | printf('<div class="error"><p>%1$s</p></div>', $notice); |
| 72 | } |
| 73 | |
| 74 | if (isset($_SERVER['SERVER_SOFTWARE']) && strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'microsoft-iis') !== false) { |
| 75 | add_action('admin_notices', 'mailpoet_microsoft_iis_notice'); |
| 76 | // deactivate the plugin |
| 77 | add_action('admin_init', 'mailpoet_deactivate_plugin'); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | // Display IIS server error notice |
| 82 | function mailpoet_microsoft_iis_notice() { |
| 83 | $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'); |
| 84 | printf('<div class="error"><p>%1$s</p></div>', $notice); |
| 85 | } |
| 86 | |
| 87 | // Check for presence of core dependencies |
| 88 | if (!file_exists($mailpoet_plugin['autoloader']) || !file_exists($mailpoet_plugin['initializer'])) { |
| 89 | add_action('admin_notices', 'mailpoet_core_dependency_notice'); |
| 90 | // deactivate the plugin |
| 91 | add_action('admin_init', 'mailpoet_deactivate_plugin'); |
| 92 | return; |
| 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>', $notice); |
| 99 | } |
| 100 | |
| 101 | // Initialize plugin |
| 102 | require_once($mailpoet_plugin['initializer']); |
| 103 |