'2022-11-28', '8.0' => '2023-11-26', '8.1' => '2024-11-25', '8.2' => '2025-12-08', '8.3' => '2026-11-23', '8.4' => '2027-11-23', ); /** * Run the check. * * @return array Check result. * * @since 4.9.0 */ public static function run(): array { $current_version = PHP_VERSION; $major_minor = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION; $details = array( 'current_version' => $current_version, 'recommended' => '8.2+', ); // Check if version is end of life. $is_eol = false; $eol_date = null; $days_to_eol = null; if ( isset( self::$eol_dates[ $major_minor ] ) ) { $eol_date = self::$eol_dates[ $major_minor ]; $eol_time = strtotime( $eol_date ); // Validate strtotime result before using it. if ( false !== $eol_time && $eol_time > 0 ) { $is_eol = ( time() > $eol_time ); $days_to_eol = (int) floor( ( $eol_time - time() ) / DAY_IN_SECONDS ); $details['eol_date'] = $eol_date; $details['days_to_eol'] = $days_to_eol; } } // PHP 7.x is end of life. if ( version_compare( $current_version, '8.0', '<' ) ) { return static::fail( 'critical', sprintf( /* translators: %s: PHP version */ __( 'Your site is running PHP %s, which no longer receives security updates. This makes your site vulnerable to known security issues that will never be fixed.', '0-day-analytics' ), $current_version ), __( 'Contact your hosting provider to upgrade to PHP 8.2 or higher. Most modern WordPress plugins and themes work well with PHP 8.2.', '0-day-analytics' ), $details ); } // PHP 8.0 is end of life. if ( version_compare( $current_version, '8.1', '<' ) ) { return static::fail( 'high', sprintf( /* translators: %s: PHP version */ __( 'Your site is running PHP %s, which no longer receives security updates as of November 2023.', '0-day-analytics' ), $current_version ), __( 'Contact your hosting provider to upgrade to PHP 8.2 or higher for better security and performance.', '0-day-analytics' ), $details ); } // PHP 8.1 is approaching end of life. if ( version_compare( $current_version, '8.2', '<' ) ) { if ( $is_eol ) { return static::fail( 'high', sprintf( /* translators: %s: PHP version */ __( 'Your site is running PHP %s, which no longer receives security updates.', '0-day-analytics' ), $current_version ), __( 'Contact your hosting provider to upgrade to PHP 8.2 or higher.', '0-day-analytics' ), $details ); } return static::warning( sprintf( /* translators: 1: PHP version, 2: number of days */ __( 'Your site is running PHP %1$s. Security support ends in %2$d days. Consider upgrading to PHP 8.2 or higher.', '0-day-analytics' ), $current_version, $days_to_eol ), __( 'Contact your hosting provider to upgrade to PHP 8.2 or higher for better security and performance.', '0-day-analytics' ), $details ); } // PHP 8.2+ is good. return static::pass( sprintf( /* translators: %s: PHP version */ __( 'Your site is running PHP %s, which is a current version receiving security updates.', '0-day-analytics' ), $current_version ), $details ); } } }