PopulatorData
2 months ago
AccessControl.php
2 years ago
Activator.php
2 months ago
AssetsLoader.php
2 weeks ago
Capabilities.php
2 months ago
Changelog.php
2 months ago
DeactivationPoll.php
3 years ago
DeferredAdminNotices.php
2 months ago
Env.php
6 months ago
Hooks.php
4 weeks ago
HooksWooCommerce.php
1 month ago
Initializer.php
4 weeks ago
Installer.php
10 months ago
Localizer.php
3 years ago
Menu.php
1 month ago
PersonalDataErasers.php
1 month ago
PersonalDataExporters.php
1 month ago
PluginActivatedHook.php
3 years ago
Populator.php
2 weeks ago
PrivacyPolicy.php
1 month ago
Renderer.php
1 year ago
RendererFactory.php
3 years ago
RequirementsChecker.php
2 months ago
Router.php
2 months ago
ServicesChecker.php
3 years ago
Shortcodes.php
1 month ago
SilentUpgraderSkin.php
3 years ago
SubscriberChangesNotifier.php
2 months ago
TranslationUpdater.php
3 months ago
TwigEnvironment.php
1 year ago
TwigFileSystemCache.php
3 years ago
Updater.php
4 days ago
index.php
3 years ago
Env.php
126 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Config; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\WP\Functions as WPFunctions; |
| 9 | |
| 10 | class Env { |
| 11 | const NEWSLETTER_CONTENT_WIDTH = 1320; |
| 12 | |
| 13 | public static $version; |
| 14 | public static $pluginName; |
| 15 | public static $pluginPath; |
| 16 | public static $baseUrl; |
| 17 | public static $file; |
| 18 | public static $path; |
| 19 | public static $viewsPath; |
| 20 | public static $assetsPath; |
| 21 | public static $assetsUrl; |
| 22 | public static $utilPath; |
| 23 | public static $tempPath; |
| 24 | public static $cachePath; |
| 25 | public static $tempUrl; |
| 26 | public static $languagesPath; |
| 27 | public static $libPath; |
| 28 | public static $pluginPrefix; |
| 29 | /** @var string WP DB prefix + plugin prefix */ |
| 30 | public static $dbPrefix; |
| 31 | /** |
| 32 | * @deprecated Use global $wpdb->prefix instead |
| 33 | */ |
| 34 | public static $wpDbPrefix = ''; |
| 35 | /** |
| 36 | * @deprecated Database connection is handled by WordPress $wpdb |
| 37 | */ |
| 38 | public static $dbHost = ''; |
| 39 | /** |
| 40 | * @deprecated Database connection is handled by WordPress $wpdb |
| 41 | */ |
| 42 | public static $dbIsIpv6 = ''; |
| 43 | /** |
| 44 | * @deprecated Database connection is handled by WordPress $wpdb |
| 45 | */ |
| 46 | public static $dbSocket = ''; |
| 47 | /** |
| 48 | * @deprecated Database connection is handled by WordPress $wpdb |
| 49 | */ |
| 50 | public static $dbPort = ''; |
| 51 | /** |
| 52 | * @deprecated Use global $wpdb->dbname instead |
| 53 | */ |
| 54 | public static $dbName = ''; |
| 55 | /** |
| 56 | * @deprecated Database connection is handled by WordPress $wpdb |
| 57 | */ |
| 58 | public static $dbUsername = ''; |
| 59 | /** |
| 60 | * @deprecated Database connection is handled by WordPress $wpdb |
| 61 | */ |
| 62 | public static $dbPassword = ''; |
| 63 | /** |
| 64 | * @deprecated Use global $wpdb->charset instead |
| 65 | */ |
| 66 | public static $dbCharset = ''; |
| 67 | /** |
| 68 | * @deprecated Use global $wpdb->collate instead |
| 69 | */ |
| 70 | public static $dbCollation = ''; |
| 71 | /** |
| 72 | * @deprecated Use global $wpdb->get_charset_collate() instead |
| 73 | */ |
| 74 | public static $dbCharsetCollate = ''; |
| 75 | /** |
| 76 | * @deprecated Calculate timezone offset from WordPress gmt_offset option if needed |
| 77 | */ |
| 78 | public static $dbTimezoneOffset = ''; |
| 79 | |
| 80 | // back compatibility for older Premium plugin with underscore naming |
| 81 | // (we need to allow it to activate so it can render an update notice) |
| 82 | public static $plugin_name; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps |
| 83 | public static $temp_path; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps |
| 84 | |
| 85 | public static function init($file, $version) { |
| 86 | self::$version = $version; |
| 87 | self::$file = $file; |
| 88 | self::$path = dirname(self::$file); |
| 89 | self::$pluginName = 'mailpoet'; |
| 90 | self::$pluginPath = 'mailpoet/mailpoet.php'; |
| 91 | self::$baseUrl = WPFunctions::get()->pluginsUrl('', $file); |
| 92 | self::$viewsPath = self::$path . '/views'; |
| 93 | self::$assetsPath = self::$path . '/assets'; |
| 94 | self::$assetsUrl = WPFunctions::get()->pluginsUrl('/assets', $file); |
| 95 | self::$utilPath = self::$path . '/lib/Util'; |
| 96 | $wpUploadDir = WPFunctions::get()->wpUploadDir(); |
| 97 | self::$tempPath = $wpUploadDir['basedir'] . '/' . self::$pluginName; |
| 98 | self::$cachePath = self::$path . '/generated/twig/'; |
| 99 | self::$tempUrl = $wpUploadDir['baseurl'] . '/' . self::$pluginName; |
| 100 | self::$languagesPath = self::$path . '/../../languages/plugins/'; |
| 101 | self::$libPath = self::$path . '/lib'; |
| 102 | self::$pluginPrefix = WPFunctions::get()->applyFilters('mailpoet_db_prefix', 'mailpoet_'); |
| 103 | |
| 104 | global $wpdb; |
| 105 | self::$dbPrefix = $wpdb->prefix . self::$pluginPrefix; |
| 106 | |
| 107 | // back compatibility for older Premium plugin with underscore naming |
| 108 | self::$plugin_name = self::$pluginName; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps |
| 109 | self::$temp_path = self::$tempPath; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * @deprecated Calculate timezone offset from WordPress gmt_offset option directly if needed |
| 114 | */ |
| 115 | public static function getDbTimezoneOffset($offset = false) { |
| 116 | $offset = ($offset) ? $offset : WPFunctions::get()->getOption('gmt_offset'); |
| 117 | $offset = (float)($offset); |
| 118 | $mins = $offset * 60; |
| 119 | $sgn = ($mins < 0 ? -1 : 1); |
| 120 | $mins = abs($mins); |
| 121 | $hrs = floor($mins / 60); |
| 122 | $mins -= $hrs * 60; |
| 123 | return sprintf('%+03d:%02d', $hrs * $sgn, $mins); |
| 124 | } |
| 125 | } |
| 126 |