Skip to content

Commit 3a9954c

Browse files
authored
Merge pull request #22 from amdd-tim/amdd-export-filename
adds optional filename flag for form export
2 parents f6b2b10 + bf9b45a commit 3a9954c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

includes/class-gf-cli-form.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,15 @@ function form_list( $args, $assoc_args ) {
113113
* [--porcelain]
114114
* : Overrides the standard success message with just the export file path
115115
*
116+
* [--filename=<filename>]
117+
* : The filename for the form to export. Defaults to the current date.
118+
*
116119
* ## EXAMPLES
117120
*
118121
* wp gf form export 1
119122
* wp gf form export
120123
*
121-
* @synopsis [<form-id>] [--dir=<dir>] [--porcelain]
124+
* @synopsis [<form-id>] [--dir=<dir>] [--porcelain] [--filename=<filename>]
122125
*/
123126
function export( $args, $assoc_args ) {
124127

@@ -138,7 +141,11 @@ function export( $args, $assoc_args ) {
138141
$forms_json = json_encode( $forms );
139142

140143
// Set the filename of the export
141-
$filename = 'gravityforms-export-' . date( 'Y-m-d' ) . '.json';
144+
if ( isset( $assoc_args['filename'] ) ) {
145+
$filename = $assoc_args['filename'];
146+
} else {
147+
$filename = 'gravityforms-export-' . date( 'Y-m-d' ) . '.json';
148+
}
142149

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

0 commit comments

Comments
 (0)