pluginsUrl('', $file); self::$viewsPath = self::$path . '/views'; self::$assetsPath = self::$path . '/assets'; self::$assetsUrl = WPFunctions::get()->pluginsUrl('/assets', $file); self::$utilPath = self::$path . '/lib/Util'; $wpUploadDir = WPFunctions::get()->wpUploadDir(); self::$tempPath = $wpUploadDir['basedir'] . '/' . self::$pluginName; self::$cachePath = self::$path . '/generated/twig/'; self::$tempUrl = $wpUploadDir['baseurl'] . '/' . self::$pluginName; self::$languagesPath = self::$path . '/../../languages/plugins/'; self::$libPath = self::$path . '/lib'; self::$pluginPrefix = WPFunctions::get()->applyFilters('mailpoet_db_prefix', 'mailpoet_'); self::initDbParameters($dbHost, $dbUser, $dbPassword, $dbName); // back compatibility for older Premium plugin with underscore naming self::$plugin_name = self::$pluginName; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps self::$temp_path = self::$tempPath; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps } /** * @see https://codex.wordpress.org/Editing_wp-config.php#Set_Database_Host for possible DB_HOSTS values */ private static function initDbParameters($dbHost, $dbUser, $dbPassword, $dbName) { $parsedHost = WPFunctions::get()->parseDbHost($dbHost); if ($parsedHost === false) { throw new \InvalidArgumentException('Invalid db host configuration.'); } [$host, $port, $socket, $isIpv6] = $parsedHost; global $wpdb; self::$dbPrefix = $wpdb->prefix . self::$pluginPrefix; self::$dbHost = $host; self::$dbIsIpv6 = $isIpv6; self::$dbPort = $port; self::$dbSocket = $socket; self::$dbName = $dbName; self::$dbUsername = $dbUser; self::$dbPassword = $dbPassword; self::$dbCharset = $wpdb->charset; self::$dbCollation = $wpdb->collate; self::$dbCharsetCollate = $wpdb->get_charset_collate(); self::$dbTimezoneOffset = self::getDbTimezoneOffset(); } public static function getDbTimezoneOffset($offset = false) { $offset = ($offset) ? $offset : WPFunctions::get()->getOption('gmt_offset'); $offset = (float)($offset); $mins = $offset * 60; $sgn = ($mins < 0 ? -1 : 1); $mins = abs($mins); $hrs = floor($mins / 60); $mins -= $hrs * 60; return sprintf('%+03d:%02d', $hrs * $sgn, $mins); } }