PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.2.0
Kubio AI Page Builder v2.2.0
2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / src / CLI / ExportDemoSiteCommand.php
kubio / lib / src / CLI Last commit date
CLI.php 3 years ago ExportDemoSiteCommand.php 2 years ago ImportDemoSiteCommand.php 2 years ago
ExportDemoSiteCommand.php
57 lines
1 <?php
2
3 namespace Kubio\CLI;
4
5 use Kubio\DemoSites\DemoSites;
6 use WP_CLI;
7
8 class ExportDemoSiteCommand {
9 /**
10 * Export website as a Kubio design.
11 *
12 * ## OPTIONS
13 *
14 * <file>
15 * : The design output file. It should have the .kds extension.
16 *
17 *
18 * ## EXAMPLES
19 *
20 * wp kubio:export-design /home/user/my-site.kds
21 *
22 * @when after_wp_load
23 * @param $args
24 * @param $assoc_args
25 * @throws \WP_CLI\ExitException
26 */
27 public function __invoke( $args, $assoc_args ) {
28
29 $file = empty( $args[0] ) ? null : $args[0];
30
31 if ( is_null( $file ) ) {
32 WP_CLI::error( 'Output file name cannot be empty' );
33 return;
34 }
35
36 if ( substr( $file, -4 ) !== '.kds' ) {
37 WP_CLI::line( "File: '{$file}' does not have the kds extension! It will be automatically added" );
38 $file = "{$file}.kds";
39 }
40
41 if ( file_exists( $file ) ) {
42 WP_CLI::error( "File: '{$file}' already exists. Please use another name!" );
43 return;
44 }
45 if ( ! is_writable( dirname( $file ) ) ) {
46 WP_CLI::error( "File: '{$file}' is not writable. Please use another location!" );
47 return;
48 }
49
50 $content = serialize( DemoSites::exportDemoSiteContent() );
51
52 file_put_contents( $file, $content );
53
54 WP_CLI::success( "Demo site successfully exported to '{$file}'." );
55 }
56 }
57