Skip to content

Commit 269d5b1

Browse files
authored
Fix fatal error which can occur when using the version command with an add-on slug (#31)
* Fix fatal error when using add-on slug * update change log
1 parent 0229bbc commit 269d5b1

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

change_log.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
= 1.3.1 =
22
- Added support for using `--version=beta` with the `wp gf install` and `wp gf update` commands. Add-On beta releases are not currently supported.
3+
- Fixed a fatal error which can occur when using the `wp gf version` command with an add-on slug when Gravity Forms is not active or not installed.
34

45
= 1.3 =
56
- Fixed an error occurring when using the `wp gf form notification create` command.

includes/class-gf-cli-root.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class GF_CLI_Root extends WP_CLI_Command {
2929
* wp gf version gravityformspolls
3030
*/
3131
public function version( $args, $assoc_args ) {
32+
if ( ! class_exists( 'GFForms' ) ) {
33+
WP_CLI::error( 'Gravity Forms is not installed. Use the wp gf install command.' );
34+
}
35+
3236
$slug = $this->get_slug( $args );
3337

3438
if ( $slug == 'gravityforms' ) {
35-
if ( class_exists( 'GFForms' ) ) {
36-
WP_CLI::log( GFForms::$version );
37-
} else {
38-
WP_CLI::error( 'Gravity Forms is not installed. Use the wp gf install command.' );
39-
}
39+
WP_CLI::log( GFForms::$version );
4040
} else {
4141
$addon_class_names = GFAddOn::get_registered_addons();
4242
$addon_found = false;

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ If you have any ideas for improvements please submit your idea at https://www.gr
187187

188188
= 1.3.1 =
189189
- Added support for using `--version=beta` with the `wp gf install` and `wp gf update` commands. Add-On beta releases are not currently supported.
190+
- Fixed a fatal error which can occur when using the `wp gf version` command with an add-on slug when Gravity Forms is not active or not installed.
190191

191192
= 1.3 =
192193
- Fixed an error occurring when using the `wp gf form notification create` command.

0 commit comments

Comments
 (0)