mailpoet
Last commit date
assets
9 months ago
generated
9 months ago
lang
9 months ago
lib
9 months ago
lib-3rd-party
1 year ago
vendor
9 months ago
vendor-prefixed
1 year ago
views
9 months ago
.gitleaksignore
1 year ago
index.php
3 years ago
license.txt
4 years ago
mailpoet-cron.php
2 years ago
mailpoet.php
9 months ago
mailpoet_initializer.php
1 year ago
readme.txt
9 months ago
mailpoet_initializer.php
90 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 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($mailpoetPlugin)) exit; |
| 11 | |
| 12 | require_once($mailpoetPlugin['autoloader']); |
| 13 | |
| 14 | // setup Tracy Debugger in dev mode and only for PHP version > 7.1 |
| 15 | $tracyPath = __DIR__ . '/tools/vendor/tracy.phar'; |
| 16 | if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracyPath)) { |
| 17 | require_once $tracyPath; |
| 18 | |
| 19 | if (getenv('MAILPOET_TRACY_PRODUCTION_MODE')) { |
| 20 | $logDir = getenv('MAILPOET_TRACY_LOG_DIR'); |
| 21 | if (!$logDir) { |
| 22 | throw new RuntimeException("Environment variable 'MAILPOET_TRACY_LOG_DIR' was not set."); |
| 23 | } |
| 24 | |
| 25 | if (!is_dir($logDir)) { |
| 26 | @mkdir($logDir, 0777, true); |
| 27 | } |
| 28 | |
| 29 | if (!is_writable($logDir)) { |
| 30 | throw new RuntimeException("Logging directory '$logDir' is not writable.'"); |
| 31 | } |
| 32 | |
| 33 | Debugger::enable(Debugger::PRODUCTION, $logDir); |
| 34 | Debugger::$logSeverity = E_ALL; |
| 35 | } else { |
| 36 | function render_tracy() { |
| 37 | ob_start(); |
| 38 | Debugger::renderLoader(); |
| 39 | $tracyScriptHtml = 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 | $tracyScriptHtml = str_replace('async', '', $tracyScriptHtml); |
| 45 | |
| 46 | // set higher number of displayed AJAX rows |
| 47 | $maxAjaxRows = 4; |
| 48 | $tracyScriptHtml .= "<script>window.TracyMaxAjaxRows = $maxAjaxRows;</script>\n"; |
| 49 | |
| 50 | // just minor adjustments to Debugger::renderLoader() output |
| 51 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 52 | echo $tracyScriptHtml; |
| 53 | } |
| 54 | |
| 55 | add_action('admin_enqueue_scripts', 'render_tracy', PHP_INT_MAX, 0); |
| 56 | session_start(); |
| 57 | Debugger::enable(Debugger::DEVELOPMENT); |
| 58 | |
| 59 | if (getenv('MAILPOET_DISABLE_TRACY_PANEL')) { |
| 60 | Debugger::$showBar = false; |
| 61 | } |
| 62 | } |
| 63 | define('MAILPOET_DEVELOPMENT', true); |
| 64 | } |
| 65 | |
| 66 | define('MAILPOET_VERSION', $mailpoetPlugin['version']); |
| 67 | |
| 68 | Env::init( |
| 69 | $mailpoetPlugin['filename'], |
| 70 | $mailpoetPlugin['version'], |
| 71 | DB_HOST, |
| 72 | DB_USER, |
| 73 | DB_PASSWORD, |
| 74 | DB_NAME |
| 75 | ); |
| 76 | |
| 77 | $requirements = new RequirementsChecker(); |
| 78 | $requirementsCheckResults = $requirements->checkAllRequirements(); |
| 79 | if ( |
| 80 | !$requirementsCheckResults[RequirementsChecker::TEST_VENDOR_SOURCE] |
| 81 | ) { |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | // Ensure functions like get_plugins, etc. |
| 86 | require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
| 87 | |
| 88 | $initializer = MailPoet\DI\ContainerWrapper::getInstance()->get(MailPoet\Config\Initializer::class); |
| 89 | $initializer->init(); |
| 90 |