PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.2
Elementor Website Builder – more than just a page builder v3.13.2
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 +62 -131 4.2.33.13.2 View file →
@@ -1,12 +1,11 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 4 use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
5 +use Elementor\Core\Admin\Menu\Main as MainMenu;
5 6 use Elementor\Core\Kits\Manager;
6 7 use Elementor\Includes\Settings\AdminMenuItems\Tools_Menu_Item;
7 -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
8 -use Elementor\Includes\Settings\AdminMenuItems\Editor_One_Tools_Menu;
9 8
10 9 if ( ! defined( 'ABSPATH' ) ) {
11 10 exit; // Exit if accessed directly.
12 11 }
@@ -20,15 +19,23 @@
20 19 * @since 1.0.0
21 20 */
22 21 class Tools extends Settings_Page {
23 22
24 - const CAPABILITY = 'manage_options';
25 -
26 23 /**
27 24 * Settings page ID for Elementor tools.
28 25 */
29 26 const PAGE_ID = 'elementor-tools';
30 27
28 + private function register_admin_menu( MainMenu $menu ) {
29 + $menu->add_submenu( [
30 + 'page_title' => esc_html__( 'Tools', 'elementor' ),
31 + 'menu_title' => esc_html__( 'Tools', 'elementor' ),
32 + 'menu_slug' => self::PAGE_ID,
33 + 'function' => [ $this, 'display_settings_page' ],
34 + 'index' => 50,
35 + ] );
36 + }
37 +
31 38 /**
32 39 * Clear cache.
33 40 *
34 41 * Delete post meta containing the post CSS file data. And delete the actual
@@ -41,35 +48,13 @@
41 48 */
42 49 public function ajax_elementor_clear_cache() {
43 50 check_ajax_referer( 'elementor_clear_cache', '_nonce' );
44 51
45 - if ( ! current_user_can( static::CAPABILITY ) ) {
46 - wp_send_json_error( 'Permission denied' );
47 - }
48 -
49 52 Plugin::$instance->files_manager->clear_cache();
50 53
51 54 wp_send_json_success();
52 55 }
53 56
54 - public function admin_post_elementor_site_clear_cache() {
55 - check_ajax_referer( 'elementor_site_clear_cache' );
56 -
57 - if ( ! current_user_can( static::CAPABILITY ) ) {
58 - wp_die( 'Permission denied' );
59 - }
60 -
61 - Plugin::$instance->files_manager->clear_cache();
62 -
63 - $http_referer = wp_get_raw_referer();
64 - if ( empty( $http_referer ) ) {
65 - $http_referer = admin_url( 'admin.php?page=' . static::PAGE_ID );
66 - }
67 -
68 - wp_safe_redirect( $http_referer );
69 - die;
70 - }
71 -
72 57 /**
73 58 * Recreate kit.
74 59 *
75 60 * Recreate default kit (only when default kit does not exist).
@@ -81,12 +66,8 @@
81 66 */
82 67 public function ajax_elementor_recreate_kit() {
83 68 check_ajax_referer( 'elementor_recreate_kit', '_nonce' );
84 69
85 - if ( ! current_user_can( static::CAPABILITY ) ) {
86 - wp_send_json_error( 'Permission denied' );
87 - }
88 -
89 70 $kit = Plugin::$instance->kits_manager->get_active_kit();
90 71
91 72 if ( $kit->get_id() ) {
92 73 wp_send_json_error( [ 'message' => esc_html__( 'There\'s already an active kit.', 'elementor' ) ], 400 );
@@ -116,12 +97,8 @@
116 97 */
117 98 public function ajax_elementor_replace_url() {
118 99 check_ajax_referer( 'elementor_replace_url', '_nonce' );
119 100
120 - if ( ! current_user_can( static::CAPABILITY ) ) {
121 - wp_send_json_error( 'Permission denied' );
122 - }
123 -
124 101 $from = Utils::get_super_global_value( $_POST, 'from' ) ?? '';
125 102 $to = Utils::get_super_global_value( $_POST, 'to' ) ?? '';
126 103
127 104 try {
@@ -152,32 +129,21 @@
152 129 $rollback_versions = $this->get_rollback_versions();
153 130 $version = Utils::get_super_global_value( $_GET, 'version' );
154 131
155 132 if ( empty( $version ) || ! in_array( $version, $rollback_versions, true ) ) {
156 - wp_die( esc_html__( 'An error occurred, the selected version is invalid. Try selecting different version.', 'elementor' ) );
133 + wp_die( esc_html__( 'Error occurred, The version selected is invalid. Try selecting different version.', 'elementor' ) );
157 134 }
158 135
159 - /**
160 - * Filter to allow override the rollback process.
161 - * Should return an instance of `Rollback` class.
162 - *
163 - * @since 3.16.0
164 - *
165 - * @param Rollback|null $rollback The rollback instance.
166 - * @param string $version The version to roll back to.
167 - */
168 - $rollback = apply_filters( 'elementor/settings/rollback', null, $version );
136 + $plugin_slug = basename( ELEMENTOR__FILE__, '.php' );
169 137
170 - if ( ! ( $rollback instanceof Rollback ) ) {
171 - $plugin_slug = basename( ELEMENTOR__FILE__, '.php' );
172 -
173 - $rollback = new Rollback( [
138 + $rollback = new Rollback(
139 + [
174 140 'version' => $version,
175 141 'plugin_name' => ELEMENTOR_PLUGIN_BASE,
176 142 'plugin_slug' => $plugin_slug,
177 143 'package_url' => sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, $version ),
178 - ] );
179 - }
144 + ]
145 + );
180 146
181 147 $rollback->run();
182 148
183 149 wp_die(
@@ -197,14 +163,19 @@
197 163 */
198 164 public function __construct() {
199 165 parent::__construct();
200 166
201 - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
202 - $this->register_editor_one_menu( $menu_data_provider );
203 - } );
167 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
168 + add_action( 'elementor/admin/menu_registered/elementor', function( MainMenu $menu ) {
169 + $this->register_admin_menu( $menu );
170 + } );
171 + } else {
172 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
173 + $admin_menu->register( static::PAGE_ID, new Tools_Menu_Item( $this ) );
174 + }, Settings::ADMIN_MENU_PRIORITY + 20 );
175 + }
204 176
205 177 add_action( 'wp_ajax_elementor_clear_cache', [ $this, 'ajax_elementor_clear_cache' ] );
206 - add_action( 'admin_post_elementor_site_clear_cache', [ $this, 'admin_post_elementor_site_clear_cache' ] );
207 178 add_action( 'wp_ajax_elementor_replace_url', [ $this, 'ajax_elementor_replace_url' ] );
208 179 add_action( 'wp_ajax_elementor_recreate_kit', [ $this, 'ajax_elementor_recreate_kit' ] );
209 180
210 181 add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] );
@@ -209,46 +180,32 @@
209 180
210 181 add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] );
211 182 }
212 183
213 - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) {
214 - $menu_data_provider->register_menu( new Editor_One_Tools_Menu() );
215 - }
216 -
217 - public function get_warning_span( string $text ): string {
218 - $color = 'var(--e-one-palette-error-main)';
219 - return sprintf( '<span style="color: %s;">%s</span>', esc_attr( $color ), esc_html( $text ) );
220 - }
221 -
222 184 private function get_rollback_versions() {
223 185 $rollback_versions = get_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION );
224 -
225 186 if ( false === $rollback_versions ) {
226 187 $max_versions = 30;
227 188
228 - $versions = apply_filters( 'elementor/settings/rollback/versions', [] );
189 + require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
229 190
230 - if ( empty( $versions ) ) {
231 - require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
191 + $plugin_information = plugins_api(
192 + 'plugin_information', [
193 + 'slug' => 'elementor',
194 + ]
195 + );
232 196
233 - $plugin_information = plugins_api(
234 - 'plugin_information', [
235 - 'slug' => 'elementor',
236 - ]
237 - );
197 + if ( empty( $plugin_information->versions ) || ! is_array( $plugin_information->versions ) ) {
198 + return [];
199 + }
238 200
239 - if ( empty( $plugin_information->versions ) || ! is_array( $plugin_information->versions ) ) {
240 - return [];
241 - }
201 + uksort( $plugin_information->versions, 'version_compare' );
202 + $plugin_information->versions = array_reverse( $plugin_information->versions );
242 203
243 - uksort( $plugin_information->versions, 'version_compare' );
244 - $versions = array_keys( array_reverse( $plugin_information->versions ) );
245 - }
246 -
247 204 $rollback_versions = [];
248 205
249 206 $current_index = 0;
250 - foreach ( $versions as $version ) {
207 + foreach ( $plugin_information->versions as $version => $download_link ) {
251 208 if ( $max_versions <= $current_index ) {
252 209 break;
253 210 }
254 211
@@ -275,9 +232,9 @@
275 232 if ( version_compare( $version, ELEMENTOR_VERSION, '>=' ) ) {
276 233 continue;
277 234 }
278 235
279 - ++$current_index;
236 + $current_index++;
280 237 $rollback_versions[] = $version;
281 238 }
282 239
283 240 set_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION, $rollback_versions, WEEK_IN_SECONDS );
@@ -310,13 +267,13 @@
310 267 'sections' => [
311 268 'tools' => [
312 269 'fields' => [
313 270 'clear_cache' => [
314 - 'label' => esc_html__( 'Elementor Cache', 'elementor' ),
271 + 'label' => esc_html__( 'Regenerate CSS & Data', 'elementor' ),
315 272 'field_args' => [
316 273 'type' => 'raw_html',
317 - 'html' => sprintf( '<button data-nonce="%s" data-id="elementor-tools-general-button-clear-files-data" class="button elementor-button-spinner" id="elementor-clear-cache-button">%s</button>', wp_create_nonce( 'elementor_clear_cache' ), esc_html__( 'Clear Files & Data', 'elementor' ) ),
318 - 'desc' => esc_html__( "Clear outdated CSS files and cached data in the database (rendered HTML, JS/CSS assets, etc.). We'll regenerate those files the next time someone visits any page on your website.", 'elementor' ),
274 + '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' ) ),
275 + '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' ),
319 276 ],
320 277 ],
321 278 'reset_api_data' => [
322 279 'label' => esc_html__( 'Sync Library', 'elementor' ),
@@ -321,9 +278,9 @@
321 278 'reset_api_data' => [
322 279 'label' => esc_html__( 'Sync Library', 'elementor' ),
323 280 'field_args' => [
324 281 'type' => 'raw_html',
325 - 'html' => sprintf( '<button data-nonce="%s" data-id="elementor-tools-general-button-sync-library" class="button elementor-button-spinner" id="elementor-library-sync-button">%s</button>', wp_create_nonce( 'elementor_reset_library' ), esc_html__( 'Sync Library', 'elementor' ) ),
282 + 'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-library-sync-button">%s</button>', wp_create_nonce( 'elementor_reset_library' ), esc_html__( 'Sync Library', 'elementor' ) ),
326 283 'desc' => esc_html__( 'Elementor Library automatically updates on a daily basis. You can also manually update it by clicking on the sync button.', 'elementor' ),
327 284 ],
328 285 ],
329 286 ],
@@ -334,19 +291,17 @@
334 291 'label' => esc_html__( 'Replace URL', 'elementor' ),
335 292 'sections' => [
336 293 'replace_url' => [
337 294 'callback' => function() {
295 + $intro_text = sprintf(
296 + /* translators: %s: WordPress backups documentation. */
297 + __( '<strong>Important:</strong> It is strongly recommended that you <a target="_blank" href="%s">backup your database</a> before using Replace URL.', 'elementor' ),
298 + 'http://go.elementor.com/wordpress-backups/'
299 + );
300 + $intro_text = '<div>' . $intro_text . '</div>';
301 +
338 302 echo '<h2>' . esc_html__( 'Replace URL', 'elementor' ) . '</h2>';
339 - printf(
340 - '<p><strong>%1$s</strong> %2$s</p>',
341 - esc_html__( 'Important:', 'elementor' ),
342 - sprintf(
343 - /* translators: 1: Link open tag, 2: Link close tag. */
344 - esc_html__( 'It is strongly recommended to %1$sbackup the database%2$s before using replacing URLs.', 'elementor' ),
345 - '<a href="https://go.elementor.com/wordpress-backups/" target="_blank">',
346 - '</a>'
347 - )
348 - );
303 + Utils::print_unescaped_internal_string( $intro_text );
349 304 },
350 305 'fields' => [
351 306 'replace_url' => [
352 307 'label' => esc_html__( 'Update Site Address (URL)', 'elementor' ),
@@ -351,9 +306,9 @@
351 306 'replace_url' => [
352 307 'label' => esc_html__( 'Update Site Address (URL)', 'elementor' ),
353 308 'field_args' => [
354 309 'type' => 'raw_html',
355 - 'html' => sprintf( '<input type="text" name="from" placeholder="https://old.example.com" class="large-text"><input type="text" name="to" placeholder="https://new.example.com" class="large-text"><button data-nonce="%s" data-id="elementor-tools-replace_url-button-replace-url" class="button elementor-button-spinner" id="elementor-replace-url-button">%s</button>', wp_create_nonce( 'elementor_replace_url' ), esc_html__( 'Replace URL', 'elementor' ) ),
310 + 'html' => sprintf( '<input type="text" name="from" placeholder="http://old-url.com" class="large-text"><input type="text" name="to" placeholder="http://new-url.com" class="large-text"><button data-nonce="%s" class="button elementor-button-spinner" id="elementor-replace-url-button">%s</button>', wp_create_nonce( 'elementor_replace_url' ), esc_html__( 'Replace URL', 'elementor' ) ),
356 311 'desc' => esc_html__( 'Enter your old and new URLs for your WordPress installation, to update all Elementor data (Relevant for domain transfers or move to \'HTTPS\').', 'elementor' ),
357 312 ],
358 313 ],
359 314 ],
@@ -381,32 +336,29 @@
381 336 'label' => esc_html__( 'Rollback Version', 'elementor' ),
382 337 'field_args' => [
383 338 'type' => 'raw_html',
384 339 'html' => sprintf(
385 - $rollback_html . '<button data-placeholder-text="%1$s v{VERSION}" data-placeholder-url="%2$s" class="button elementor-button-spinner elementor-rollback-button">%1$s</button>',
386 - esc_html__( 'Reinstall', 'elementor' ),
387 - wp_nonce_url( admin_url( 'admin-post.php?action=elementor_rollback&version=VERSION' ), 'elementor_rollback' )
340 + $rollback_html . '<a data-placeholder-text="' . esc_html__( 'Reinstall', 'elementor' ) . ' v{VERSION}" href="#" data-placeholder-url="%s" class="button elementor-button-spinner elementor-rollback-button">%s</a>',
341 + wp_nonce_url( admin_url( 'admin-post.php?action=elementor_rollback&version=VERSION' ), 'elementor_rollback' ),
342 + esc_html__( 'Reinstall', 'elementor' )
388 343 ),
389 - 'desc' => $this->get_warning_span( esc_html__( 'Warning: Please back up your database before making the rollback.', 'elementor' ) ),
344 + 'desc' => '<span style="color: red;">' . esc_html__( 'Warning: Please backup your database before making the rollback.', 'elementor' ) . '</span>',
390 345 ],
391 346 ],
392 347 ],
393 348 ],
394 349 'beta' => [
395 - 'show_if' => $this->display_beta_tester(),
396 350 'label' => esc_html__( 'Become a Beta Tester', 'elementor' ),
397 351 'callback' => function() {
398 352 echo '<p>' .
399 353 esc_html__( 'Turn-on Beta Tester, to get notified when a new beta version of Elementor or Elementor Pro is available. The Beta version will not install automatically. You always have the option to ignore it.', 'elementor' ) .
400 354 '</p>';
401 - echo '<p>' . sprintf(
355 + echo sprintf(
402 356 /* translators: 1: Link open tag, 2: Link close tag. */
403 - esc_html__( '%1$sClick here%2$s %3$sto join our first-to-know email updates.%4$s', 'elementor' ),
404 - '<a id="beta-tester-first-to-know" class="elementor-become-a-beta-tester" href="#">',
405 - '</a>',
406 - '<span class="elementor-become-a-beta-tester">',
407 - '</span>',
408 - ) . '</p>';
357 + esc_html__( '%1$sClick here%2$s to join our first-to-know email updates.', 'elementor' ),
358 + '<a id="beta-tester-first-to-know" href="#">',
359 + '</a>'
360 + );
409 361 },
410 362 'fields' => [
411 363 'beta' => [
412 364 'label' => esc_html__( 'Beta Tester', 'elementor' ),
@@ -416,9 +368,9 @@
416 368 'options' => [
417 369 'no' => esc_html__( 'Disable', 'elementor' ),
418 370 'yes' => esc_html__( 'Enable', 'elementor' ),
419 371 ],
420 - 'desc' => $this->get_warning_span( esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) ),
372 + 'desc' => '<span style="color: red;">' . esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) . '</span>',
421 373 ],
422 374 ],
423 375 ],
424 376 ],
@@ -459,27 +411,6 @@
459 411 * @return bool
460 412 */
461 413 public static function can_user_rollback_versions() {
462 414 return current_user_can( 'activate_plugins' ) && current_user_can( 'update_plugins' );
463 - }
464 -
465 - /**
466 - * Check if the beta tester should be displayed.
467 - *
468 - * @since 3.19.0
469 - *
470 - * @return bool
471 - */
472 - public function display_beta_tester(): bool {
473 - $display_beta_tester = true;
474 - /**
475 - * Filter to allow override the display of the beta tester.
476 - *
477 - * @param bool $display_beta_tester Whether to display the beta tester.
478 - *
479 - * @since 3.19.0
480 - *
481 - * return bool
482 - */
483 - return apply_filters( 'elementor/admin/show_beta_tester', $display_beta_tester );
484 415 }
485 416 }