Skip to content

Commit 07e868b

Browse files
authored
Allow usage as wp cli package (#41)
1 parent 495ab87 commit 07e868b

13 files changed

+21
-18
lines changed

change_log.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
= 1.5 =
2+
- Updated the plugin to allow its usage as a WP-CLI package.
3+
14
= 1.4 =
25
- Fixed an issue where the version comparison performed when using `wp gf update` with an add-on slug uses the Gravity Forms version number.
36
- Added support for using `--version=beta` with the `wp gf install` and `wp gf update` commands. Add-On beta releases are not currently supported.

class-gf-cli.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
defined( 'ABSPATH' ) || die();
3+
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
44

55
// Include the Gravity Forms add-on framework
66
GFForms::include_addon_framework();

cli.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Gravity Forms CLI
44
Plugin URI: https://gravityforms.com
55
Description: Manage Gravity Forms with the WP CLI.
6-
Version: 1.4
6+
Version: 1.5
77
Author: Rocketgenius
88
Author URI: https://gravityforms.com
99
License: GPL-2.0+
@@ -27,17 +27,15 @@
2727
along with this program. If not, see http://www.gnu.org/licenses.
2828
*/
2929

30-
defined( 'ABSPATH' ) || die();
30+
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
3131

3232
// Defines the current version of the CLI add-on
33-
define( 'GF_CLI_VERSION', '1.4' );
33+
define( 'GF_CLI_VERSION', '1.5' );
3434

3535
define( 'GF_CLI_MIN_GF_VERSION', '1.9.17.8' );
3636

37-
add_action( 'init', array( 'GF_CLI_Bootstrap', 'load_cli' ), 1 );
38-
3937
// After GF is loaded, load the CLI add-on
40-
add_action( 'gform_loaded', array( 'GF_CLI_Bootstrap', 'load_addon' ), 1 );
38+
defined( 'ABSPATH' ) && add_action( 'gform_loaded', array( 'GF_CLI_Bootstrap', 'load_addon' ), 1 );
4139

4240

4341

@@ -71,7 +69,7 @@ public static function load_cli() {
7169
if ( defined( 'WP_CLI' ) && WP_CLI ) {
7270

7371
// Checks for files within the includes directory, and includes them.
74-
foreach ( glob( plugin_dir_path( __FILE__ ) . 'includes/*.php' ) as $filename ) {
72+
foreach ( glob( dirname( __FILE__ ) . '/includes/*.php' ) as $filename ) {
7573
require_once( $filename );
7674
}
7775
$command_args = array( 'before_invoke' => array( 'GF_CLI_Bootstrap', 'before_invoke' ) );
@@ -101,6 +99,8 @@ public static function before_invoke() {
10199
}
102100
}
103101

102+
GF_CLI_Bootstrap::load_cli();
103+
104104
/**
105105
* Returns an instance of the GF_CLI class
106106
*

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gravityforms/gravityformscli",
33
"description": "A set of WP-CLI commands to manage Gravity Forms.",
4-
"type": "wordpress-plugin",
4+
"type": "wp-cli-package",
55
"homepage": "https://github.com/gravityforms/gravityformscli",
66
"support": {
77
"issues": "https://gravityforms.com"

includes/class-gf-cli-entry-notification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
defined( 'ABSPATH' ) || die();
3+
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
44

55
/**
66
* Send Gravity Forms Notifications.

includes/class-gf-cli-entry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
defined( 'ABSPATH' ) || die();
3+
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
44

55
/**
66
* Manage Gravity Forms Entries.

includes/class-gf-cli-form-field.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
defined( 'ABSPATH' ) || die();
3+
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
44

55
/**
66
* Manage Gravity Forms Form Fields.

includes/class-gf-cli-form-notification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
defined( 'ABSPATH' ) || die();
3+
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
44

55
/**
66
* Manage Gravity Forms Notifications.

includes/class-gf-cli-form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
defined( 'ABSPATH' ) || die();
3+
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
44

55
/**
66
* Manage Gravity Forms.

includes/class-gf-cli-license.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
defined( 'ABSPATH' ) || die();
3+
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
44

55
/**
66
* Manage the Gravity Forms License Key.

0 commit comments

Comments
 (0)