mailpoet
Last commit date
assets
6 years ago
generated
6 years ago
lang
6 years ago
lib
6 years ago
lib-3rd-party
6 years ago
vendor
6 years ago
vendor-prefixed
6 years ago
views
6 years ago
index.php
6 years ago
license.txt
9 years ago
mailpoet-cron.php
6 years ago
mailpoet.php
6 years ago
mailpoet_initializer.php
6 years ago
readme.txt
6 years ago
uninstall.php
6 years ago
mailpoet_initializer.php
78 lines
| 1 | <?php |
| 2 | |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | |
| 5 | |
| 6 | use MailPoet\Config\Env; |
| 7 | use MailPoet\Config\RequirementsChecker; |
| 8 | use Tracy\Debugger; |
| 9 | |
| 10 | if (empty($mailpoet_plugin)) exit; |
| 11 | |
| 12 | require_once($mailpoet_plugin['autoloader']); |
| 13 | |
| 14 | // setup Tracy Debugger in dev mode and only for PHP version > 7.1 |
| 15 | $tracy_path = __DIR__ . '/tools/vendor/tracy.phar'; |
| 16 | if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracy_path)) { |
| 17 | require_once $tracy_path; |
| 18 | |
| 19 | if (getenv('MAILPOET_TRACY_PRODUCTION_MODE')) { |
| 20 | $log_dir = getenv('MAILPOET_TRACY_LOG_DIR'); |
| 21 | if (!$log_dir) { |
| 22 | throw new RuntimeException("Environment variable 'MAILPOET_TRACY_LOG_DIR' was not set."); |
| 23 | } |
| 24 | |
| 25 | if (!is_dir($log_dir)) { |
| 26 | @mkdir($log_dir, 0777, true); |
| 27 | } |
| 28 | |
| 29 | if (!is_writable($log_dir)) { |
| 30 | throw new RuntimeException("Logging directory '$log_dir' is not writable.'"); |
| 31 | } |
| 32 | |
| 33 | Debugger::enable(Debugger::PRODUCTION, $log_dir); |
| 34 | Debugger::$logSeverity = E_ALL; |
| 35 | } else { |
| 36 | function render_tracy() { |
| 37 | ob_start(); |
| 38 | Debugger::renderLoader(); |
| 39 | $tracy_script_html = ob_get_clean(); |
| 40 | |
| 41 | // strip 'async' to ensure all AJAX request are caught |
| 42 | // (even when fired immediately after page starts loading) |
| 43 | // see: https://github.com/nette/tracy/issues/246 |
| 44 | $tracy_script_html = str_replace('async', '', $tracy_script_html); |
| 45 | |
| 46 | // set higher number of displayed AJAX rows |
| 47 | $max_ajax_rows = 4; |
| 48 | $tracy_script_html .= "<script>window.TracyMaxAjaxRows = $max_ajax_rows;</script>\n"; |
| 49 | echo $tracy_script_html; |
| 50 | } |
| 51 | add_action('admin_enqueue_scripts', 'render_tracy', PHP_INT_MAX, 0); |
| 52 | session_start(); |
| 53 | Debugger::enable(Debugger::DEVELOPMENT); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | define('MAILPOET_VERSION', $mailpoet_plugin['version']); |
| 58 | |
| 59 | Env::init( |
| 60 | $mailpoet_plugin['filename'], |
| 61 | $mailpoet_plugin['version'], |
| 62 | DB_HOST, |
| 63 | DB_USER, |
| 64 | DB_PASSWORD, |
| 65 | DB_NAME |
| 66 | ); |
| 67 | |
| 68 | $requirements = new RequirementsChecker(); |
| 69 | $requirements_check_results = $requirements->checkAllRequirements(); |
| 70 | if (!$requirements_check_results[RequirementsChecker::TEST_PDO_EXTENSION] || |
| 71 | !$requirements_check_results[RequirementsChecker::TEST_VENDOR_SOURCE] |
| 72 | ) { |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | $initializer = MailPoet\DI\ContainerWrapper::getInstance()->get(MailPoet\Config\Initializer::class); |
| 77 | $initializer->init(); |
| 78 |