| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.5/wp-content/plugins/woocommerce/packages/blueprint/src/Cli/ |
Upload File : |
<?php
namespace Automattic\WooCommerce\Blueprint\Cli;
use Automattic\WooCommerce\Blueprint\ExportSchema;
use Automattic\WooCommerce\Blueprint\UseWPFunctions;
/**
* Class ExportCli
*
* This class handles the CLI commands for exporting schemas.
*
* @package Automattic\WooCommerce\Blueprint\Cli
*/
class ExportCli {
use UseWPFunctions;
/**
* The path where the exported schema will be saved.
*
* @var string The path where the exported schema will be saved.
*/
private string $save_to;
/**
* ExportCli constructor.
*
* @param string $save_to The path where the exported schema will be saved.
*/
public function __construct( $save_to ) {
$this->save_to = $save_to;
}
/**
* Run the export process.
*
* @param array $args The arguments for the export process.
*/
public function run( $args = array() ) {
if ( ! isset( $args['steps'] ) ) {
$args['steps'] = array();
}
$exporter = new ExportSchema();
$result = $exporter->export( $args['steps'] );
if ( is_wp_error( $result ) ) {
\WP_CLI::error( $result->get_error_message() );
return;
}
$is_saved = $this->wp_filesystem_put_contents( $this->save_to, wp_json_encode( $result, JSON_PRETTY_PRINT ) );
if ( false === $is_saved ) {
\WP_CLI::error( "Failed to save to {$this->save_to}" );
} else {
\WP_CLI::success( "Exported JSON to {$this->save_to}" );
}
}
}