Skip to content

Commit c7962e1

Browse files
author
Felix Arntz
committed
Include new PHP versions in list, and only show unsupported versions as necessary.
1 parent 5d030c0 commit c7962e1

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

wpengine-phpcompat.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,30 @@ public static function init() {
6565
* Return an array of available PHP versions to test.
6666
*/
6767
function get_phpversions() {
68-
69-
return apply_filters( 'phpcompat_phpversions', array(
68+
$versions = array(
69+
'PHP 7.2' => '7.2',
70+
'PHP 7.1' => '7.1',
7071
'PHP 7.0' => '7.0',
71-
'PHP 5.6' => '5.6',
72-
'PHP 5.5' => '5.5',
73-
'PHP 5.4' => '5.4',
74-
'PHP 5.3' => '5.3',
75-
));
72+
);
73+
74+
$old_versions = array( '5.6', '5.5', '5.4', '5.3' );
75+
76+
while ( ! empty( $old_versions ) ) {
77+
$oldest = array_pop( $old_versions );
78+
79+
if ( version_compare( phpversion(), $oldest, '<' ) ) {
80+
array_push( $old_versions, $oldest );
81+
82+
foreach ( $old_versions as $old_version ) {
83+
$old_version_label = "PHP {$old_version}";
84+
85+
$versions[ $old_version_label ] = $old_version;
86+
}
87+
break;
88+
}
89+
}
90+
91+
return apply_filters( 'phpcompat_phpversions', $versions );
7692
}
7793

7894
/**

0 commit comments

Comments
 (0)