Skip to content

Commit c9852ac

Browse files
committed
Only use major wp version in version_compare
Similar to what would happen in is_wp_version_compatible()
1 parent e522b03 commit c9852ac

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Plugin_Command.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,10 @@ public function path( $args, $assoc_args ) {
583583

584584
protected function install_from_repo( $slug, $assoc_args ) {
585585
global $wp_version;
586+
// Extract the major WordPress version (e.g., "6.3") from the full version string
587+
list($wp_core_version) = explode( '-', $wp_version );
588+
$wp_core_version = implode( '.', array_slice( explode( '.', $wp_core_version ), 0, 2 ) );
589+
586590
$api = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
587591

588592
if ( is_wp_error( $api ) ) {
@@ -596,7 +600,7 @@ protected function install_from_repo( $slug, $assoc_args ) {
596600
$requires_wp = isset( $api->requires ) ? $api->requires : null;
597601

598602
$compatible_php = empty( $requires_php ) || version_compare( PHP_VERSION, $requires_php, '>=' );
599-
$compatible_wp = empty( $requires_wp ) || version_compare( $wp_version, $requires_wp, '>=' );
603+
$compatible_wp = empty( $requires_wp ) || version_compare( $wp_core_version, $requires_wp, '>=' );
600604

601605
if ( ! $compatible_wp ) {
602606
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ public function path( $args, $assoc_args ) {
396396

397397
protected function install_from_repo( $slug, $assoc_args ) {
398398
global $wp_version;
399+
// Extract the major WordPress version (e.g., "6.3") from the full version string
400+
list($wp_core_version) = explode( '-', $wp_version );
401+
$wp_core_version = implode( '.', array_slice( explode( '.', $wp_core_version ), 0, 2 ) );
402+
399403
$api = themes_api( 'theme_information', array( 'slug' => $slug ) );
400404

401405
if ( is_wp_error( $api ) ) {
@@ -409,7 +413,7 @@ protected function install_from_repo( $slug, $assoc_args ) {
409413
$requires_wp = isset( $api->requires ) ? $api->requires : null;
410414

411415
$compatible_php = empty( $requires_php ) || version_compare( PHP_VERSION, $requires_php, '>=' );
412-
$compatible_wp = empty( $requires_wp ) || version_compare( $wp_version, $requires_wp, '>=' );
416+
$compatible_wp = empty( $requires_wp ) || version_compare( $wp_core_version, $requires_wp, '>=' );
413417

414418
if ( ! $compatible_wp ) {
415419
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)