Skip to content

Commit bfcbc77

Browse files
committed
Merge branch 'master' into update-gravityapi-domain
* master: Fix network activate install flag (#26) update change log Fix form notification update command (#25) update change log update docblock sanitize the form export file name bump version; update change log Add missing gf subcommand in documentation merges changes from github out of sync with public plugin adds optional filename flag for form export entry list: same features for json as ids format Permanently delete trashed entries Add missing entry subcommand in inline documentation
2 parents 3ae9837 + 3e58946 commit bfcbc77

File tree

6 files changed

+60
-26
lines changed

6 files changed

+60
-26
lines changed

cli.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
Plugin Name: Gravity Forms CLI
44
Plugin URI: http://www.gravityforms.com
55
Description: Manage Gravity Forms with the WP CLI.
6-
Version: 1.1.1
6+
Version: 1.1.3
77
Author: Rocketgenius
88
Author URI: http://www.gravityforms.com
99
License: GPL-2.0+
1010
Text Domain: gravityformscli
1111
Domain Path: /languages
1212
1313
------------------------------------------------------------------------
14-
Copyright 2016-2018 Rocketgenius, Inc.
14+
Copyright 2016-2020 Rocketgenius, Inc.
1515
1616
This program is free software; you can redistribute it and/or modify
1717
it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
3030
defined( 'ABSPATH' ) || die();
3131

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

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

includes/class-gf-cli-entry.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ public function get( $args, $assoc_args ) {
125125
*
126126
* ## EXAMPLES
127127
*
128-
* wp gf delete 1
129-
* wp gf delete 1 3 7 10
130-
* wp gf delete 1 --force
131-
* wp gf delete $(wp gf entry list 1 --status=trash --format=ids )
128+
* wp gf entry delete 1
129+
* wp gf entry delete 1 3 7 10
130+
* wp gf entry delete 1 --force
131+
* wp gf entry delete $(wp gf entry list 1 --status=trash --format=ids ) --force
132132
*
133133
* @synopsis <entry-id>... [--force]
134134
*/
@@ -198,7 +198,7 @@ public function delete( $args, $assoc_args ) {
198198
* ## EXAMPLES
199199
*
200200
* wp gf entry create 1 --field_1=ABC [email protected] --field_3=1234 --field_4=Hello --field_5.3=John --field_5.6=Doe
201-
* wp gf entry create $(wp entry get 3 --raw --format=json)
201+
* wp gf entry create $(wp gf entry get 3 --raw --format=json)
202202
* @synopsis [<entry-json>] [<form-id>] [--<field>=<value>]
203203
*/
204204
public function create( $args, $assoc_args ) {
@@ -643,7 +643,7 @@ public function entry_list( $args, $assoc_args ) {
643643

644644
// If the fomate is set to 'ids', get the entry IDs
645645
if ( $format == 'ids' ) {
646-
$entry_ids = GFFormsModel::search_lead_ids( $form_id, $search_criteria );
646+
$entry_ids = GFAPI::get_entry_ids( $form_id, $search_criteria, array(), $paging, $total_count );
647647
echo implode( ' ', $entry_ids );
648648

649649
return;

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,35 +391,48 @@ function duplicate( $args, $assoc_args ) {
391391
* <form-id>
392392
* : The Form ID
393393
*
394+
* [<notification-id>]
395+
* : The ID of the notification to updated.
396+
*
394397
* --notification-json=<notification-json>
395-
* : The JSON representation of the form
398+
* : The JSON representation of the notification.
396399
*
397400
* ## EXAMPLES
398401
*
399402
* wp gf form notification update 1 --notification-json='{snip}'
403+
* wp gf form notification update 1 abc1 --notification-json='{snip}'
400404
*
401-
* @synopsis <form-id> --notification-json=<notification-json>
405+
* @synopsis <form-id> [<notification-id>] --notification-json=<notification-json>
402406
*/
403407
function update( $args, $assoc_args ) {
404408
$form_id = $args[0];
409+
$form = GFAPI::get_form( $form_id );
405410

406-
$notification_id = $args[1];
407-
408-
$form = GFAPI::get_form( $form_id );
409411
if ( empty( $form ) ) {
410412
WP_CLI::error( 'Form not found' );
411413
}
412414

413-
$notifications = $form['notifications'];
414-
415-
$json_config = $assoc_args['notification-json'];
416-
415+
$json_config = $assoc_args['notification-json'];
417416
$new_notification = json_decode( $json_config, ARRAY_A );
418417

419418
if ( empty( $new_notification ) ) {
420419
WP_CLI::error( 'Notification not valid' );
421420
}
422421

422+
$notification_id = rgar( $args, 1 );
423+
424+
if ( empty( $notification_id ) ) {
425+
if ( empty( $new_notification['id'] ) ) {
426+
WP_CLI::error( 'Please specify the ID of the notification to be updated' );
427+
} else {
428+
$notification_id = $new_notification['id'];
429+
}
430+
} else {
431+
$new_notification['id'] = $notification_id;
432+
}
433+
434+
$notifications = $form['notifications'];
435+
423436
$found = false;
424437
foreach ( $notifications as $key => $notification ) {
425438
if ( $notification['id'] == $notification_id ) {

includes/class-gf-cli-form.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ function form_list( $args, $assoc_args ) {
101101
* Exports forms to a Gravity Forms Form export file.
102102
*
103103
* @since 1.0-beta-1
104+
* @since 1.2 Added the optional filename arg.
104105
*
105106
* ## OPTIONS
106107
*
@@ -110,6 +111,9 @@ function form_list( $args, $assoc_args ) {
110111
* [--dir=<dir>]
111112
* : The directory for the form to export. Defaults to the current working directory.
112113
*
114+
* [--filename=<filename>]
115+
* : The filename for the form to export. Defaults to the current date.
116+
*
113117
* [--porcelain]
114118
* : Overrides the standard success message with just the export file path
115119
*
@@ -118,7 +122,7 @@ function form_list( $args, $assoc_args ) {
118122
* wp gf form export 1
119123
* wp gf form export
120124
*
121-
* @synopsis [<form-id>] [--dir=<dir>] [--porcelain]
125+
* @synopsis [<form-id>] [--dir=<dir>] [--filename=<filename>] [--porcelain]
122126
*/
123127
function export( $args, $assoc_args ) {
124128

@@ -138,7 +142,13 @@ function export( $args, $assoc_args ) {
138142
$forms_json = json_encode( $forms );
139143

140144
// Set the filename of the export
141-
$filename = 'gravityforms-export-' . date( 'Y-m-d' ) . '.json';
145+
if ( isset( $assoc_args['filename'] ) ) {
146+
$filename = $assoc_args['filename'];
147+
} else {
148+
$filename = 'gravityforms-export-' . date( 'Y-m-d' ) . '.json';
149+
}
150+
151+
$filename = sanitize_file_name( $filename );
142152

143153
// If the export directory is set
144154
if ( isset( $assoc_args['dir'] ) ) {

includes/class-gf-cli-root.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function version( $args, $assoc_args ) {
7979
* [--activate]
8080
* : If set, the plugin will be activated immediately after install.
8181
*
82-
* [--network-activate]
82+
* [--activate-network]
8383
* : If set, the plugin will be network activated immediately after install
8484
*
8585
*
@@ -89,7 +89,7 @@ public function version( $args, $assoc_args ) {
8989
* wp gf install --force
9090
* wp gf install --key=[A valid Gravity Forms License Key]
9191
* wp gf install gravityformspolls key=[1234ABC]
92-
* @synopsis [<slug>] [--key=<key>] [--version=<version>] [--force] [--activate] [--network-activate]
92+
* @synopsis [<slug>] [--key=<key>] [--version=<version>] [--force] [--activate] [--activate-network]
9393
*/
9494
public function install( $args, $assoc_args ) {
9595
$slug = isset( $args[0] ) ? $args[0] : 'gravityforms';
@@ -122,7 +122,7 @@ public function install( $args, $assoc_args ) {
122122

123123
$activate = WP_CLI\Utils\get_flag_value( $assoc_args, 'activate', false );
124124

125-
$network_activate = WP_CLI\Utils\get_flag_value( $assoc_args, 'network-activate', false );
125+
$activate_network = WP_CLI\Utils\get_flag_value( $assoc_args, 'activate-network', false );
126126

127127
$command = sprintf( 'plugin install "%s"', $download_url );
128128

@@ -138,9 +138,9 @@ public function install( $args, $assoc_args ) {
138138
$command .= ' --activate';
139139
}
140140

141-
if ( $network_activate ) {
142-
$install_assoc_args['network-activate'] = true;
143-
$command .= ' --network-activate';
141+
if ( $activate_network ) {
142+
$install_assoc_args['activate-network'] = true;
143+
$command .= ' --activate-network';
144144
}
145145

146146
$options = array(

readme.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ https://www.gravityforms.com/open-support-ticket/
181181

182182
== ChangeLog ==
183183

184+
= 1.1.3 =
185+
- Fixed an issue where the install command could not network activate plugins.
186+
187+
= 1.1.2 =
188+
- Updated the ids format of the entry list command to support the page-size and offset args. Credit: Ulrich Pogson.
189+
- Updated the form export command to support the optional filename arg e.g. wp gf form export 1 --filename=testing.json. Credit: Timothy Decker.
190+
- Fixed an error occurring when using the form notification update command without the notification-id arg.
191+
192+
= 1.1.1 =
193+
- Fixed an issue with the entry export command.
194+
184195
= 1.1 =
185196
- Added support for start_date and end_date filters for the entry export command. e.g. wp gf entry export 11 --start_date="2018-11-01" --end_date="2018-11-11"
186197
- Added the "wp gf tool system-report" command and the "wp gf tool status" alias for outputting the system report from the Gravity Forms 2.2+ System Status page.

0 commit comments

Comments
 (0)