classes/cli/Pods_CLI_Command.php
public function export( $args, $assoc_args ) {

		$pod_name = $assoc_args['pod'];

		unset( $assoc_args['pod'] );

		$pod = pods( $pod_name, null, false );

		if ( ! $pod->valid() ) {
			WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
		}

		$params = array(
			'fields' => pods_v( 'fields', $assoc_args, null, true ),
			'depth'  => (int) pods_v( 'depth', $assoc_args, 1, true ),
		);

		// Handle custom find() params.
		$find_params = pods_v( 'params', $assoc_args, null, true );

		if ( is_string( $find_params ) ) {
			$params['params'] = array();

			if ( false !== strpos( $params['params'], '{' ) ) {
				// Pull the find params from JSON format.
				$params['params'] = json_decode( $params['params'], true );
			} else {
				// Pull the find params from string argument format.
				wp_parse_str( $find_params, $params['params'] );
			}
		}

		$data = false;

		try {
			$data = $pod->export_data( $params );
		} catch ( Exception $e ) {
			WP_CLI::error( sprintf( __( 'Error exporting pod items: %s', 'pods' ), $e->getMessage() ) );
		}

		if ( ! empty( $data ) ) {
			// Load PodsMigrate class file for use.
			pods_migrate();

			$file = $assoc_args['file'];

			$export_file = PodsMigrate::export_data_to_file( $file, $data );

			if ( $export_file ) {
				WP_CLI::success( sprintf( __( 'Pod items exported: %s', 'pods' ), $export_file ) );
			} else {
				WP_CLI::error( __( 'Pod items not exported.', 'pods' ) );
			}
		} else {
			WP_CLI::error( __( 'No pod item export data found.', 'pods' ) );
		}

	}
public function export( $args, $assoc_args ) {

		$pod_name = $assoc_args['pod'];

		unset( $assoc_args['pod'] );

		$pod = pods( $pod_name, null, false );

		if ( ! $pod->valid() ) {
			WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
		}

		$params = array(
			'fields' => pods_v( 'fields', $assoc_args, null, true ),
			'depth'  => (int) pods_v( 'depth', $assoc_args, 1, true ),
		);

		// Handle custom find() params.
		$find_params = pods_v( 'params', $assoc_args, null, true );

		if ( is_string( $find_params ) ) {
			$params['params'] = array();

			if ( false !== strpos( $params['params'], '{' ) ) {
				// Pull the find params from JSON format.
				$params['params'] = json_decode( $params['params'], true );
			} else {
				// Pull the find params from string argument format.
				wp_parse_str( $find_params, $params['params'] );
			}
		}

		$data = false;

		try {
			$data = $pod->export_data( $params );
		} catch ( Exception $e ) {
			WP_CLI::error( sprintf( __( 'Error exporting pod items: %s', 'pods' ), $e->getMessage() ) );
		}

		if ( ! empty( $data ) ) {
			// Load PodsMigrate class file for use.
			pods_migrate();

			$file = $assoc_args['file'];

			$export_file = PodsMigrate::export_data_to_file( $file, $data );

			if ( $export_file ) {
				WP_CLI::success( sprintf( __( 'Pod items exported: %s', 'pods' ), $export_file ) );
			} else {
				WP_CLI::error( __( 'Pod items not exported.', 'pods' ) );
			}
		} else {
			WP_CLI::error( __( 'No pod item export data found.', 'pods' ) );
		}

	}
public function export ( $ args , $ assoc_args ) { $ pod_name = $ assoc_args [ 'pod' ] ; unset ( $ assoc_args [ 'pod' ] ) ; $ pod = pods ( $ pod_name , null , false ) ; if ( ! $ pod -> valid ( ) ) { WP_CLI :: error ( sprintf ( __ ( 'Pod "%s" does not exist.' , 'pods' ) , $ assoc_args [ 'pod' ] ) ) ; } $ params = array ( 'fields' => pods_v ( 'fields' , $ assoc_args , null , true ) , 'depth' => ( int ) pods_v ( 'depth' , $ assoc_args , 1 , true ) , ) ; // Handle custom find() params. $ find_params = pods_v ( 'params' , $ assoc_args , null , true ) ; if ( is_string ( $ find_params ) ) { $ params [ 'params' ] = array ( ) ; if ( false !== strpos ( $ params [ 'params' ] , '{' ) ) { // Pull the find params from JSON format. $ params [ 'params' ] = json_decode ( $ params [ 'params' ] , true ) ; } else { // Pull the find params from string argument format. wp_parse_str ( $ find_params , $ params [ 'params' ] ) ; } } $ data = false ; try { $ data = $ pod -> export_data ( $ params ) ; } catch ( Exception $ e ) { WP_CLI :: error ( sprintf ( __ ( 'Error exporting pod items: %s' , 'pods' ) , $ e -> getMessage ( ) ) ) ; } if ( ! empty ( $ data ) ) { // Load PodsMigrate class file for use. pods_migrate ( ) ; $ file = $ assoc_args [ 'file' ] ; $ export_file = PodsMigrate :: export_data_to_file ( $ file , $ data ) ; if ( $ export_file ) { WP_CLI :: success ( sprintf ( __ ( 'Pod items exported: %s' , 'pods' ) , $ export_file ) ) ; } else { WP_CLI :: error ( __ ( 'Pod items not exported.' , 'pods' ) ) ; } } else { WP_CLI :: error ( __ ( 'No pod item export data found.' , 'pods' ) ) ; } }
Export all pod items to a file.

## OPTIONS

--pod=<pod>
: The pod name.

--file=<file>
: The file to save to including path (defaults to current path).

[--fields=<fields>]
: The comma-separated list of fields to export (defaults to all fields).

[--depth=<depth>]
: The depth of related objects to recursively export (default is 1 level deep, only returns IDs for related objects).

[--params=<params>]
: The params to pass into the Pods::find() call, provided in arg1=A&arg2=B or JSON format (default is limit=-1).

## EXAMPLES

wp pods export --pod=my_pod --file="items.json"
wp pods export --pod=my_pod --file="/path/to/items.json"
wp pods export --pod=my_pod --file="items.json" --fields="ID,post_title,post_content,my_field_name1,my_field_name2"
wp pods export --pod=my_pod --file="items.json" --depth=2
wp pods export --pod=my_pod --file="items.json" --params="{\"limit\":10,\"orderby\":\"t.ID DESC\"}"
wp pods export --pod=my_pod --file="items.json" --params="limit=10&orderby=t.ID DESC"
Export all pod items to a file .