diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 57d9f726..2164afcc 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -583,6 +583,10 @@ public function path( $args, $assoc_args ) { protected function install_from_repo( $slug, $assoc_args ) { global $wp_version; + // Extract the major WordPress version (e.g., "6.3") from the full version string + list($wp_core_version) = explode( '-', $wp_version ); + $wp_core_version = implode( '.', array_slice( explode( '.', $wp_core_version ), 0, 2 ) ); + $api = plugins_api( 'plugin_information', array( 'slug' => $slug ) ); if ( is_wp_error( $api ) ) { @@ -596,7 +600,7 @@ protected function install_from_repo( $slug, $assoc_args ) { $requires_wp = isset( $api->requires ) ? $api->requires : null; $compatible_php = empty( $requires_php ) || version_compare( PHP_VERSION, $requires_php, '>=' ); - $compatible_wp = empty( $requires_wp ) || version_compare( $wp_version, $requires_wp, '>=' ); + $compatible_wp = empty( $requires_wp ) || version_compare( $wp_core_version, $requires_wp, '>=' ); if ( ! $compatible_wp ) { return new WP_Error( 'requirements_not_met', "This plugin does not work with your version of WordPress. Minimum WordPress requirement is $requires_wp" ); diff --git a/src/Theme_Command.php b/src/Theme_Command.php index d0eb984a..74af0a01 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -396,6 +396,10 @@ public function path( $args, $assoc_args ) { protected function install_from_repo( $slug, $assoc_args ) { global $wp_version; + // Extract the major WordPress version (e.g., "6.3") from the full version string + list($wp_core_version) = explode( '-', $wp_version ); + $wp_core_version = implode( '.', array_slice( explode( '.', $wp_core_version ), 0, 2 ) ); + $api = themes_api( 'theme_information', array( 'slug' => $slug ) ); if ( is_wp_error( $api ) ) { @@ -409,7 +413,7 @@ protected function install_from_repo( $slug, $assoc_args ) { $requires_wp = isset( $api->requires ) ? $api->requires : null; $compatible_php = empty( $requires_php ) || version_compare( PHP_VERSION, $requires_php, '>=' ); - $compatible_wp = empty( $requires_wp ) || version_compare( $wp_version, $requires_wp, '>=' ); + $compatible_wp = empty( $requires_wp ) || version_compare( $wp_core_version, $requires_wp, '>=' ); if ( ! $compatible_wp ) { return new WP_Error( 'requirements_not_met', "This theme does not work with your version of WordPress. Minimum WordPress requirement is $requires_wp" );