classes/cli/PodsAPI_CLI_Command.php
public function import_pod( $args, $assoc_args ) {

		if ( ! PodsInit::$components->is_component_active( 'migrate-packages' ) ) {
			WP_CLI::error( sprintf( __( 'Migrate Package is not activated. Try activating it: %s', 'pods' ), 'wp pods-api activate-component --component=migrate-packages' ) );
		}

		$replace = false;

		if ( ! empty( $assoc_args['replace'] ) ) {
			$replace = true;
		}

		$file = $assoc_args['file'];

		$imported = false;

		try {
			// Load PodsMigrate class file for use.
			pods_migrate();

			// Only JSON format is supported for import.
			if ( false === strpos( $file, '.json' ) ) {
				WP_CLI::error( sprintf( __( 'Invalid file format, the file must use the .json extension: %s', 'pods' ), $file ) );
			}

			$data = PodsMigrate::get_data_from_file( $file, true );

			if ( empty( $data ) ) {
				WP_CLI::error( __( 'No Pods Package data found.', 'pods' ) );
			}

			$imported = Pods_Migrate_Packages::import( $data, $replace );
		} catch ( Exception $e ) {
			WP_CLI::error( sprintf( __( 'Error exporting Pods Package: %s', 'pods' ), $e->getMessage() ) );
		}

		if ( ! empty( $imported ) ) {
			WP_CLI::success( __( 'Pods Package imported.', 'pods' ) );
		} else {
			WP_CLI::error( __( 'Pods Package not imported.', 'pods' ) );
		}

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

		if ( ! PodsInit::$components->is_component_active( 'migrate-packages' ) ) {
			WP_CLI::error( sprintf( __( 'Migrate Package is not activated. Try activating it: %s', 'pods' ), 'wp pods-api activate-component --component=migrate-packages' ) );
		}

		$replace = false;

		if ( ! empty( $assoc_args['replace'] ) ) {
			$replace = true;
		}

		$file = $assoc_args['file'];

		$imported = false;

		try {
			// Load PodsMigrate class file for use.
			pods_migrate();

			// Only JSON format is supported for import.
			if ( false === strpos( $file, '.json' ) ) {
				WP_CLI::error( sprintf( __( 'Invalid file format, the file must use the .json extension: %s', 'pods' ), $file ) );
			}

			$data = PodsMigrate::get_data_from_file( $file, true );

			if ( empty( $data ) ) {
				WP_CLI::error( __( 'No Pods Package data found.', 'pods' ) );
			}

			$imported = Pods_Migrate_Packages::import( $data, $replace );
		} catch ( Exception $e ) {
			WP_CLI::error( sprintf( __( 'Error exporting Pods Package: %s', 'pods' ), $e->getMessage() ) );
		}

		if ( ! empty( $imported ) ) {
			WP_CLI::success( __( 'Pods Package imported.', 'pods' ) );
		} else {
			WP_CLI::error( __( 'Pods Package not imported.', 'pods' ) );
		}

	}
public function import_pod ( $ args , $ assoc_args ) { if ( ! PodsInit :: $ components -> is_component_active ( 'migrate-packages' ) ) { WP_CLI :: error ( sprintf ( __ ( 'Migrate Package is not activated. Try activating it: %s' , 'pods' ) , 'wp pods-api activate-component --component=migrate-packages' ) ) ; } $ replace = false ; if ( ! empty ( $ assoc_args [ 'replace' ] ) ) { $ replace = true ; } $ file = $ assoc_args [ 'file' ] ; $ imported = false ; try { // Load PodsMigrate class file for use. pods_migrate ( ) ; // Only JSON format is supported for import. if ( false === strpos ( $ file , '.json' ) ) { WP_CLI :: error ( sprintf ( __ ( 'Invalid file format, the file must use the .json extension: %s' , 'pods' ) , $ file ) ) ; } $ data = PodsMigrate :: get_data_from_file ( $ file , true ) ; if ( empty ( $ data ) ) { WP_CLI :: error ( __ ( 'No Pods Package data found.' , 'pods' ) ) ; } $ imported = Pods_Migrate_Packages :: import ( $ data , $ replace ) ; } catch ( Exception $ e ) { WP_CLI :: error ( sprintf ( __ ( 'Error exporting Pods Package: %s' , 'pods' ) , $ e -> getMessage ( ) ) ) ; } if ( ! empty ( $ imported ) ) { WP_CLI :: success ( __ ( 'Pods Package imported.' , 'pods' ) ) ; } else { WP_CLI :: error ( __ ( 'Pods Package not imported.' , 'pods' ) ) ; } }
Import a Pods Package from a file.

## OPTIONS

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

[--replace]
: Overwrite imported items if they already exist (defaults to false).

## EXAMPLES

wp pods-api import-pod --file="pods-package.json"
wp pods-api import-pod --file="/path/to/pods-package.json"
wp pods-api import-pod --file="pods-package.json" --replace

@subcommand import-pod
Import a Pods Package from a file .