| 1 |
<?php defined( 'ABSPATH' ) or die(); |
| 2 |
|
| 3 |
class Brizy_Import_WpCli extends WP_CLI_Command { |
| 4 |
/** |
| 5 |
* Import a Demo |
| 6 |
* |
| 7 |
* ## OPTIONS |
| 8 |
* |
| 9 |
* <id> |
| 10 |
* : The id of the demo to import. |
| 11 |
* |
| 12 |
* ## EXAMPLES |
| 13 |
* |
| 14 |
* 1. wp brizy demo import 33 |
| 15 |
* - This will import the whole demo with the id 33. |
| 16 |
* |
| 17 |
* @param array $args |
| 18 |
* @param array $assoc_args |
| 19 |
* |
| 20 |
* @throws \WP_CLI\ExitException |
| 21 |
*/ |
| 22 |
public function import( array $args, array $assoc_args ) { |
| 23 |
|
| 24 |
if ( empty( $args[0] ) ) { |
| 25 |
WP_CLI::error( 'Please specify the id off the demo to import' ); |
| 26 |
} |
| 27 |
|
| 28 |
WP_CLI::log( 'Demo import started...' ); |
| 29 |
|
| 30 |
$import = new Brizy_Import_Import( $args[0] ); |
| 31 |
|
| 32 |
try { |
| 33 |
$import->import(); |
| 34 |
WP_CLI::success( 'Demo imported successfully' ); |
| 35 |
} catch ( Exception $e ) { |
| 36 |
WP_CLI::error( $e->getMessage() ); |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|