AfterMigrationNotice.php
2 years ago
BlackFridayNotice.php
2 months ago
ChangedTrackingNotice.php
3 years ago
DatabaseEngineNotice.php
1 year ago
DeprecatedFilterNotice.php
4 years ago
DisabledMailFunctionNotice.php
2 months ago
DisabledWPCronNotice.php
1 year ago
EmailWithInvalidSegmentNotice.php
3 years ago
HeadersAlreadySentNotice.php
2 months ago
InactiveSubscribersNotice.php
2 years ago
PHPVersionWarnings.php
2 months ago
PendingApprovalNotice.php
2 years ago
PermanentNotices.php
2 months ago
PremiumFeaturesAvailableNotice.php
2 years ago
SenderDomainAuthenticationNotices.php
5 months ago
SendingQueueBodyCleanupNotice.php
2 months ago
StuckPostNotificationNotice.php
2 months ago
UnauthorizedEmailInNewslettersNotice.php
5 months ago
UnauthorizedEmailNotice.php
5 months ago
WooCommerceVersionWarning.php
1 year ago
WordPressPlaygroundNotice.php
1 year ago
index.php
3 years ago
PHPVersionWarnings.php
44 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Util\Notices; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Util\Helpers; |
| 9 | use MailPoet\WP\Functions as WPFunctions; |
| 10 | use MailPoet\WP\Notice; |
| 11 | |
| 12 | class PHPVersionWarnings { |
| 13 | |
| 14 | const DISMISS_NOTICE_TIMEOUT_SECONDS = 2592000; // 30 days |
| 15 | const OPTION_NAME = 'dismissed-php-version-outdated-notice'; |
| 16 | |
| 17 | public function init($phpVersion, $shouldDisplay) { |
| 18 | if ($shouldDisplay && $this->isOutdatedPHPVersion($phpVersion)) { |
| 19 | return $this->display($phpVersion); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | public function isOutdatedPHPVersion($phpVersion) { |
| 24 | return version_compare($phpVersion, '8.0', '<') && !WPFunctions::get()->getTransient(self::OPTION_NAME); |
| 25 | } |
| 26 | |
| 27 | public function display($phpVersion) { |
| 28 | // translators: %s is the PHP version |
| 29 | $errorString = __('Your website is running an outdated version of PHP (%1$s), on which MailPoet might stop working in the future. We recommend upgrading to %2$s or greater. Read our [link]simple PHP upgrade guide.[/link]', 'mailpoet'); |
| 30 | $errorString = sprintf($errorString, $phpVersion, '8.1'); |
| 31 | $error = Helpers::replaceLinkTags($errorString, 'https://kb.mailpoet.com/article/251-upgrading-the-websites-php-version', [ |
| 32 | 'target' => '_blank', |
| 33 | ]); |
| 34 | |
| 35 | $extraClasses = 'mailpoet-dismissible-notice is-dismissible'; |
| 36 | |
| 37 | return Notice::displayWarning($error, $extraClasses, self::OPTION_NAME); |
| 38 | } |
| 39 | |
| 40 | public function disable() { |
| 41 | WPFunctions::get()->setTransient(self::OPTION_NAME, true, self::DISMISS_NOTICE_TIMEOUT_SECONDS); |
| 42 | } |
| 43 | } |
| 44 |