Skip to content

Commit e522b03

Browse files
committed
Use version_compare directly
The built in wp functions for this are too new (Added in 5.2)
1 parent d75ff32 commit e522b03

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Plugin_Command.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ public function path( $args, $assoc_args ) {
582582
}
583583

584584
protected function install_from_repo( $slug, $assoc_args ) {
585+
global $wp_version;
585586
$api = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
586587

587588
if ( is_wp_error( $api ) ) {
@@ -594,8 +595,8 @@ protected function install_from_repo( $slug, $assoc_args ) {
594595
$requires_php = isset( $api->requires_php ) ? $api->requires_php : null;
595596
$requires_wp = isset( $api->requires ) ? $api->requires : null;
596597

597-
$compatible_php = is_php_version_compatible( $requires_php );
598-
$compatible_wp = is_wp_version_compatible( $requires_wp );
598+
$compatible_php = empty( $requires_php ) || version_compare( PHP_VERSION, $requires_php, '>=' );
599+
$compatible_wp = empty( $requires_wp ) || version_compare( $wp_version, $requires_wp, '>=' );
599600

600601
if ( ! $compatible_wp ) {
601602
return new WP_Error( 'requirements_not_met', "This plugin does not work with your version of WordPress. Minimum WordPress requirement is $requires_wp" );

src/Theme_Command.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ public function path( $args, $assoc_args ) {
395395
}
396396

397397
protected function install_from_repo( $slug, $assoc_args ) {
398+
global $wp_version;
398399
$api = themes_api( 'theme_information', array( 'slug' => $slug ) );
399400

400401
if ( is_wp_error( $api ) ) {
@@ -407,8 +408,8 @@ protected function install_from_repo( $slug, $assoc_args ) {
407408
$requires_php = isset( $api->requires_php ) ? $api->requires_php : null;
408409
$requires_wp = isset( $api->requires ) ? $api->requires : null;
409410

410-
$compatible_php = is_php_version_compatible( $requires_php );
411-
$compatible_wp = is_wp_version_compatible( $requires_wp );
411+
$compatible_php = empty( $requires_php ) || version_compare( PHP_VERSION, $requires_php, '>=' );
412+
$compatible_wp = empty( $requires_wp ) || version_compare( $wp_version, $requires_wp, '>=' );
412413

413414
if ( ! $compatible_wp ) {
414415
return new WP_Error( 'requirements_not_met', "This theme does not work with your version of WordPress. Minimum WordPress requirement is $requires_wp" );

0 commit comments

Comments
 (0)