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}" ); } } }