Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 27
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
wpcomsh_minimum_php_version_notice
0.00% covered (danger)
0.00%
0 / 27
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * PHP version notices file.
4 *
5 * @package wpcomsh
6 */
7
8/**
9 * Adds an admin notice if the PHP version needs to be updated.
10 *
11 * This notice is currently not hooked! See p7DVsv-fbI-p2 for more information.
12 */
13function wpcomsh_minimum_php_version_notice() {
14    $minimum_php_version = '8.0.0';
15
16    if ( ! wpcom_site_has_feature( WPCOM_Features::SFTP ) ) {
17        return;
18    }
19
20    if ( version_compare( PHP_VERSION, $minimum_php_version, '>=' ) ) {
21        return;
22    }
23
24    $eol_date = '2022-11-28 00:00:00';
25    $eol_date = date_i18n( get_option( 'date_format' ), strtotime( get_date_from_gmt( $eol_date ) ) );
26
27    $message = sprintf(
28        /* translators: 1: version number such as 1.0.0; 2: a localized date using the user chosen date format; 3: version number such as 1.0.0; 4: A URL. */
29        __(
30            'You are currently using PHP <strong>%1$s</strong> which will no longer receive security updates as of %2$s. Please update to PHP %3$s or higher by changing your <a href="%4$s">hosting configuration</a>.',
31            'wpcomsh'
32        ),
33        PHP_VERSION,
34        $eol_date,
35        $minimum_php_version,
36        esc_url(
37            sprintf(
38                'https://wordpress.com/hosting-config/%s',
39                ( new Automattic\Jetpack\Status() )->get_site_suffix()
40            )
41        )
42    );
43
44    printf(
45        '<div class="notice wpcomsh-notice">
46            <span class="notice__icon-wrapper notice__icon-wrapper-orange">
47                <span class="dashicons dashicons-warning"></span>
48            </span>
49            <span class="notice__content">
50                <span class="notice__text">%s</span>
51            </span>
52        </div>',
53        wp_kses_post( $message )
54    );
55}
56// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
57// add_action( 'admin_notices', 'wpcomsh_minimum_php_version_notice' );