| @@ 12-36 (lines=25) @@ | ||
| 9 | * | |
| 10 | * @synopsis --pod=<pod> --<field>=<value> | |
| 11 | */ | |
| 12 | 	function add( $args, $assoc_args ) { | |
| 13 | ||
| 14 | $pod = $assoc_args['pod']; | |
| 15 | $item = pods_var_raw( 'item', $assoc_args ); | |
| 16 | ||
| 17 | unset( $assoc_args['pod'] ); | |
| 18 | ||
| 19 | 		if ( isset( $assoc_args['item'] ) ) { | |
| 20 | unset( $assoc_args['item'] ); | |
| 21 | } | |
| 22 | ||
| 23 | 		if ( ! empty( $assoc_args ) ) { | |
| 24 | $id = pods( $pod, $item )->save( $assoc_args ); | |
| 25 | ||
| 26 | 			if ( 0 < $id ) { | |
| 27 | WP_CLI::success( __( 'Pod item added', 'pods' ) ); | |
| 28 | 				WP_CLI::line( "ID: {$id}" ); | |
| 29 | 			} else { | |
| 30 | WP_CLI::error( __( 'Error saving pod item', 'pods' ) ); | |
| 31 | } | |
| 32 | 		} else { | |
| 33 | WP_CLI::error( __( 'No data sent for saving', 'pods' ) ); | |
| 34 | } | |
| 35 | ||
| 36 | } | |
| 37 | ||
| 38 | /** | |
| 39 | * | |
| @@ 43-67 (lines=25) @@ | ||
| 40 | * | |
| 41 | * @synopsis --pod=<pod> [--item=<item>] --<field>=<value> | |
| 42 | */ | |
| 43 | 	function save( $args, $assoc_args ) { | |
| 44 | ||
| 45 | $pod = $assoc_args['pod']; | |
| 46 | $item = pods_var_raw( 'item', $assoc_args ); | |
| 47 | ||
| 48 | unset( $assoc_args['pod'] ); | |
| 49 | ||
| 50 | 		if ( isset( $assoc_args['item'] ) ) { | |
| 51 | unset( $assoc_args['item'] ); | |
| 52 | } | |
| 53 | ||
| 54 | 		if ( ! empty( $assoc_args ) ) { | |
| 55 | $id = pods( $pod, $item )->save( $assoc_args ); | |
| 56 | ||
| 57 | 			if ( 0 < $id ) { | |
| 58 | WP_CLI::success( __( 'Pod item saved', 'pods' ) ); | |
| 59 | 				WP_CLI::line( "ID: {$id}" ); | |
| 60 | 			} else { | |
| 61 | WP_CLI::error( __( 'Error saving pod item', 'pods' ) ); | |
| 62 | } | |
| 63 | 		} else { | |
| 64 | WP_CLI::error( __( 'No data sent for saving', 'pods' ) ); | |
| 65 | } | |
| 66 | ||
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * | |