PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.1
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.1.1
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / admin-legacy-core / inc / wp-cli.php

wp-cli.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.1, at admin-legacy-core/inc/wp-cli.php

133 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WP CLI
4 *
5 * 1. Run `wp cartflows info` Info.
6 *
7 * @since 1.6.15
8 *
9 * @package Cartflows
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Cartflows_WP_CLI' ) && class_exists( 'WP_CLI_Command' ) ) :
18
19 /**
20 * Cartflows WP CLI
21 */
22 class Cartflows_WP_CLI extends WP_CLI_Command {
23
24 /**
25 * Get All Flows & Steps
26 *
27 * Example: wp cartflows list
28 *
29 * @param array $args Arguments.
30 * @param array $assoc_args Associated Arguments.
31 * @alias list
32 * @return void
33 */
34 public function flow_list( $args, $assoc_args ) {
35
36 $flows = Cartflows_Helper::get_instance()->get_flows_and_steps();
37
38 $fields = array(
39 'ID',
40 'title',
41 'page_builder',
42 'category',
43 'type',
44 );
45
46 $this->display( $assoc_args, $fields, $flows );
47 }
48
49 /**
50 * Display
51 *
52 * @since 1.6.15
53 * @param array $assoc_args Arguments.
54 * @param array $fields Format fields.
55 * @param array $items Items list.
56 * @return void.
57 */
58 private function display( $assoc_args = array(), $fields = array(), $items = array() ) {
59 $formatter = new \WP_CLI\Formatter( $assoc_args, $fields );
60
61 $formatter->display_items( $items );
62 }
63
64 /**
65 * Sync Library.
66 *
67 * Sync the library and create the .json files.
68 *
69 * Use: `wp cartflows sync`
70 *
71 * @since 1.6.15
72 * @param array $args Arguments.
73 * @param array $assoc_args Associated Arguments.
74 * @return void.
75 */
76 public function sync( $args = array(), $assoc_args = array() ) {
77 CartFlows_Batch_Process::get_instance()->process_batch();
78 }
79
80 /**
81 * Sync Library.
82 *
83 * Sync the library and create the .json files.
84 *
85 * Use: `wp cartflows sync_all elementor`
86 * Use: `wp cartflows sync_all beaver-builder`
87 * Use: `wp cartflows sync_all gutenberg`
88 * Use: `wp cartflows sync_all divi`
89 *
90 * @since 1.6.15
91 * @param array $args Arguments.
92 * @param array $assoc_args Associated Arguments.
93 * @return void.
94 */
95 public function sync_all( $args = array(), $assoc_args = array() ) {
96
97 $stored = get_site_option( '_cartflows_common', array() );
98 $stored['default_page_builder'] = $args[0];
99 update_option( '_cartflows_common', $stored );
100
101 CartFlows_Batch_Process::get_instance()->process_batch();
102 }
103
104 /**
105 * Import flows
106 *
107 * Example: wp cartflows import_flows
108 *
109 * @since 1.6.15
110 * @param array $args Arguments.
111 * @param array $assoc_args Associated Arguments.
112 * @return void
113 */
114 public function import_flows( $args = array(), $assoc_args = array() ) {
115 $file_url = isset( $args[0] ) ? $args[0] : '';
116
117 if ( empty( $file_url ) ) {
118 WP_CLI::error( 'Error: Empty file' );
119 }
120
121 $flows = json_decode( file_get_contents( $file_url ), true ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
122
123 CartFlows_Importer::get_instance()->import_from_json_data( $flows );
124 }
125 }
126
127 /**
128 * Add Command
129 */
130 WP_CLI::add_command( 'cartflows', 'Cartflows_WP_CLI' );
131
132 endif;
133