PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.3
Elementor Website Builder – more than just a page builder v3.0.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/wp-cli/command.php +14 -51 4.2.23.0.3 View file →
@@ -6,9 +6,9 @@
6 6 use Elementor\TemplateLibrary\Source_Local;
7 7 use Elementor\Utils;
8 8
9 9 if ( ! defined( 'ABSPATH' ) ) {
10 - exit; // Exit if accessed directly.
10 + exit; // Exit if accessed directly
11 11 }
12 12
13 13 /**
14 14 * Elementor Page Builder cli tools.
@@ -20,11 +20,8 @@
20 20 *
21 21 * [--network]
22 22 * Flush CSS Cache for all the sites in the network.
23 23 *
24 - * [--regenerate]
25 - * Re-create the CSS files. Otherwise they will be created by a page visit.
26 - *
27 24 * ## EXAMPLES
28 25 *
29 26 * 1. wp elementor flush-css
30 27 * - This will flush the CSS files for elementor page builder.
@@ -31,11 +28,8 @@
31 28 *
32 29 * 2. wp elementor flush-css --network
33 30 * - This will flush the CSS files for elementor page builder for all the sites in the network.
34 31 *
35 - * 3. wp elementor flush-css --regenerate
36 - * - This will flush the CSS files for elementor page builder and re-create the new CSS files.
37 - *
38 32 * @since 2.1.0
39 33 * @access public
40 34 * @alias flush-css
41 35 */
@@ -40,71 +34,44 @@
40 34 * @alias flush-css
41 35 */
42 36 public function flush_css( $args, $assoc_args ) {
43 37 $network = ! empty( $assoc_args['network'] ) && is_multisite();
44 - $should_regenerate = ! empty( $assoc_args['regenerate'] );
45 38
46 39 if ( $network ) {
47 - $blog_ids = get_sites( [
48 - 'fields' => 'ids',
49 - 'number' => 0,
50 - ] );
40 + /** @var \WP_Site[] $blogs */
41 + $blogs = get_sites();
51 42
52 - foreach ( $blog_ids as $blog_id ) {
43 + foreach ( $blogs as $keys => $blog ) {
44 + // Cast $blog as an array instead of object
45 + $blog_id = $blog->blog_id;
46 +
53 47 switch_to_blog( $blog_id );
54 48
55 - $this->handle_flush( $should_regenerate, 'Flushed the Elementor CSS Cache for site - ' . get_option( 'home' ) );
49 + Plugin::$instance->files_manager->clear_cache();
56 50
51 + \WP_CLI::success( 'Flushed the Elementor CSS Cache for site - ' . get_option( 'home' ) );
52 +
57 53 restore_current_blog();
58 54 }
59 55 } else {
60 - $this->handle_flush( $should_regenerate, 'Flushed the Elementor CSS Cache' );
61 - }
62 - }
56 + Plugin::$instance->files_manager->clear_cache();
63 57
64 - private function handle_flush( bool $should_regenerate, string $success_message ): void {
65 - Plugin::$instance->files_manager->clear_cache();
66 -
67 - if ( $should_regenerate ) {
68 - Plugin::$instance->files_manager->generate_css();
58 + \WP_CLI::success( 'Flushed the Elementor CSS Cache' );
69 59 }
70 -
71 - \WP_CLI::success( $success_message );
72 60 }
73 61
74 62 /**
75 - * Print system info powered by Elementor
76 - *
77 - * ## EXAMPLES
78 - *
79 - * 1. wp elementor system-info
80 - * - This will print the System Info in JSON format
81 - *
82 - * @since 3.0.11
83 - * @access public
84 - * @alias system-info
85 - */
86 - public function system_info() {
87 - echo wp_json_encode( \Elementor\Tracker::get_tracking_data() );
88 - }
89 -
90 - /**
91 63 * Replace old URLs with new URLs in all Elementor pages.
92 64 *
93 - * [--force]
94 - * Suppress error messages. instead, return "0 database rows affected.".
95 - *
96 65 * ## EXAMPLES
97 66 *
98 67 * 1. wp elementor replace-urls <old> <new>
99 68 * - This will replace all <old> URLs with the <new> URL.
100 69 *
101 - * 2. wp elementor replace-urls <old> <new> --force
102 - * - This will replace all <old> URLs with the <new> URL without throw errors.
103 - *
104 70 * @access public
105 71 * @alias replace-urls
106 72 */
73 +
107 74 public function replace_urls( $args, $assoc_args ) {
108 75 if ( empty( $args[0] ) ) {
109 76 \WP_CLI::error( 'Please set the `old` URL' );
110 77 }
@@ -116,13 +83,9 @@
116 83 try {
117 84 $results = Utils::replace_urls( $args[0], $args[1] );
118 85 \WP_CLI::success( $results );
119 86 } catch ( \Exception $e ) {
120 - if ( isset( $assoc_args['force'] ) ) {
121 - \WP_CLI::success( '0 database rows affected.' );
122 - } else {
123 - \WP_CLI::error( $e->getMessage() );
124 - }
87 + \WP_CLI::error( $e->getMessage() );
125 88 }
126 89 }
127 90
128 91 /**