PluginProbe
Elementor Website Builder – more than just a page builder / 3.3.0
Elementor Website Builder – more than just a page builder v3.3.0
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 | includes/settings/tools.php +51 -8 3.2.53.3.0 View file →
@@ -1,7 +1,9 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 +use Elementor\Core\Kits\Manager;
5 +
4 6 if ( ! defined( 'ABSPATH' ) ) {
5 7 exit; // Exit if accessed directly.
6 8 }
7 9
@@ -60,8 +62,38 @@
60 62 wp_send_json_success();
61 63 }
62 64
63 65 /**
66 + * Recreate kit.
67 + *
68 + * Recreate default kit (only when default kit does not exist).
69 + *
70 + * Fired by `wp_ajax_elementor_recreate_kit` action.
71 + *
72 + * @since 1.0.0
73 + * @access public
74 + */
75 + public function ajax_elementor_recreate_kit() {
76 + check_ajax_referer( 'elementor_recreate_kit', '_nonce' );
77 +
78 + $kit = Plugin::$instance->kits_manager->get_active_kit();
79 +
80 + if ( $kit->get_id() ) {
81 + wp_send_json_error( [ 'message' => __( 'There\'s already an active kit.', 'elementor' ) ], 400 );
82 + }
83 +
84 + $created_default_kit = Plugin::$instance->kits_manager->create_default();
85 +
86 + if ( ! $created_default_kit ) {
87 + wp_send_json_error( [ 'message' => __( 'An error occurred while trying to create a kit.', 'elementor' ) ], 500 );
88 + }
89 +
90 + update_option( Manager::OPTION_ACTIVE, $created_default_kit );
91 +
92 + wp_send_json_success( __( 'New kit have been created successfully', 'elementor' ) );
93 + }
94 +
95 + /**
64 96 * Replace URLs.
65 97 *
66 98 * Sends an ajax request to replace old URLs to new URLs. This method also
67 99 * updates all the Elementor data.
@@ -135,12 +167,11 @@
135 167 parent::__construct();
136 168
137 169 add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 205 );
138 170
139 - if ( ! empty( $_POST ) ) {
140 - add_action( 'wp_ajax_elementor_clear_cache', [ $this, 'ajax_elementor_clear_cache' ] );
141 - add_action( 'wp_ajax_elementor_replace_url', [ $this, 'ajax_elementor_replace_url' ] );
142 - }
171 + add_action( 'wp_ajax_elementor_clear_cache', [ $this, 'ajax_elementor_clear_cache' ] );
172 + add_action( 'wp_ajax_elementor_replace_url', [ $this, 'ajax_elementor_replace_url' ] );
173 + add_action( 'wp_ajax_elementor_recreate_kit', [ $this, 'ajax_elementor_recreate_kit' ] );
143 174
144 175 add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] );
145 176 }
146 177
@@ -215,9 +246,9 @@
215 246 $rollback_html .= "<option value='{$version}'>$version</option>";
216 247 }
217 248 $rollback_html .= '</select>';
218 249
219 - return [
250 + $tabs = [
220 251 'general' => [
221 252 'label' => __( 'General', 'elementor' ),
222 253 'sections' => [
223 254 'tools' => [
@@ -222,13 +253,13 @@
222 253 'sections' => [
223 254 'tools' => [
224 255 'fields' => [
225 256 'clear_cache' => [
226 - 'label' => __( 'Regenerate CSS', 'elementor' ),
257 + 'label' => esc_html__( 'Regenerate CSS & Data', 'elementor' ),
227 258 'field_args' => [
228 259 'type' => 'raw_html',
229 - 'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-clear-cache-button">%s</button>', wp_create_nonce( 'elementor_clear_cache' ), __( 'Regenerate Files', 'elementor' ) ),
230 - 'desc' => __( 'Styles set in Elementor are saved in CSS files in the uploads folder. Recreate those files, according to the most recent settings.', 'elementor' ),
260 + 'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-clear-cache-button">%s</button>', wp_create_nonce( 'elementor_clear_cache' ), esc_html__( 'Regenerate Files & Data', 'elementor' ) ),
261 + 'desc' => esc_html__( 'Styles set in Elementor are saved in CSS files in the uploads folder and in the site’s database. Recreate those files and settings, according to the most recent settings.', 'elementor' ),
231 262 ],
232 263 ],
233 264 'reset_api_data' => [
234 265 'label' => __( 'Sync Library', 'elementor' ),
@@ -327,8 +358,20 @@
327 358 ],
328 359 ],
329 360 ],
330 361 ];
362 +
363 + if ( ! Plugin::$instance->kits_manager->get_active_kit()->get_id() ) {
364 + $tabs['general']['sections']['tools']['fields']['recreate_kit'] = [
365 + 'label' => __( 'Recreate Kit', 'elementor' ),
366 + 'field_args' => [
367 + 'type' => 'raw_html',
368 + 'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-recreate-kit-button">%s</button>', wp_create_nonce( 'elementor_recreate_kit' ), __( 'Recreate Kit', 'elementor' ) ),
369 + 'desc' => __( 'It seems like your site doesn\'t have any active Kit. The active Kit includes all of your Site Settings. By recreating your Kit you will able to start edit your Site Settings again.', 'elementor' ),
370 + ],
371 + ];
372 + }
373 + return $tabs;
331 374 }
332 375
333 376 /**
334 377 * Get tools page title.