PluginProbe
Elementor Website Builder – more than just a page builder / 3.16.2
Elementor Website Builder – more than just a page builder v3.16.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 -117 4.2.23.16.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 }
@@ -27,8 +26,18 @@
27 26 * Settings page ID for Elementor tools.
28 27 */
29 28 const PAGE_ID = 'elementor-tools';
30 29
30 + private function register_admin_menu( MainMenu $menu ) {
31 + $menu->add_submenu( [
32 + 'page_title' => esc_html__( 'Tools', 'elementor' ),
33 + 'menu_title' => esc_html__( 'Tools', 'elementor' ),
34 + 'menu_slug' => self::PAGE_ID,
35 + 'function' => [ $this, 'display_settings_page' ],
36 + 'index' => 50,
37 + ] );
38 + }
39 +
31 40 /**
32 41 * Clear cache.
33 42 *
34 43 * Delete post meta containing the post CSS file data. And delete the actual
@@ -50,26 +59,8 @@
50 59
51 60 wp_send_json_success();
52 61 }
53 62
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 63 /**
73 64 * Recreate kit.
74 65 *
75 66 * Recreate default kit (only when default kit does not exist).
@@ -152,32 +143,21 @@
152 143 $rollback_versions = $this->get_rollback_versions();
153 144 $version = Utils::get_super_global_value( $_GET, 'version' );
154 145
155 146 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' ) );
147 + wp_die( esc_html__( 'Error occurred, The version selected is invalid. Try selecting different version.', 'elementor' ) );
157 148 }
158 149
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 );
150 + $plugin_slug = basename( ELEMENTOR__FILE__, '.php' );
169 151
170 - if ( ! ( $rollback instanceof Rollback ) ) {
171 - $plugin_slug = basename( ELEMENTOR__FILE__, '.php' );
172 -
173 - $rollback = new Rollback( [
152 + $rollback = new Rollback(
153 + [
174 154 'version' => $version,
175 155 'plugin_name' => ELEMENTOR_PLUGIN_BASE,
176 156 'plugin_slug' => $plugin_slug,
177 157 'package_url' => sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, $version ),
178 - ] );
179 - }
158 + ]
159 + );
180 160
181 161 $rollback->run();
182 162
183 163 wp_die(
@@ -197,14 +177,19 @@
197 177 */
198 178 public function __construct() {
199 179 parent::__construct();
200 180
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 - } );
181 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
182 + add_action( 'elementor/admin/menu_registered/elementor', function( MainMenu $menu ) {
183 + $this->register_admin_menu( $menu );
184 + } );
185 + } else {
186 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
187 + $admin_menu->register( static::PAGE_ID, new Tools_Menu_Item( $this ) );
188 + }, Settings::ADMIN_MENU_PRIORITY + 20 );
189 + }
204 190
205 191 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 192 add_action( 'wp_ajax_elementor_replace_url', [ $this, 'ajax_elementor_replace_url' ] );
208 193 add_action( 'wp_ajax_elementor_recreate_kit', [ $this, 'ajax_elementor_recreate_kit' ] );
209 194
210 195 add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] );
@@ -209,46 +194,32 @@
209 194
210 195 add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] );
211 196 }
212 197
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 198 private function get_rollback_versions() {
223 199 $rollback_versions = get_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION );
224 -
225 200 if ( false === $rollback_versions ) {
226 201 $max_versions = 30;
227 202
228 - $versions = apply_filters( 'elementor/settings/rollback/versions', [] );
203 + require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
229 204
230 - if ( empty( $versions ) ) {
231 - require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
205 + $plugin_information = plugins_api(
206 + 'plugin_information', [
207 + 'slug' => 'elementor',
208 + ]
209 + );
232 210
233 - $plugin_information = plugins_api(
234 - 'plugin_information', [
235 - 'slug' => 'elementor',
236 - ]
237 - );
211 + if ( empty( $plugin_information->versions ) || ! is_array( $plugin_information->versions ) ) {
212 + return [];
213 + }
238 214
239 - if ( empty( $plugin_information->versions ) || ! is_array( $plugin_information->versions ) ) {
240 - return [];
241 - }
215 + uksort( $plugin_information->versions, 'version_compare' );
216 + $plugin_information->versions = array_reverse( $plugin_information->versions );
242 217
243 - uksort( $plugin_information->versions, 'version_compare' );
244 - $versions = array_keys( array_reverse( $plugin_information->versions ) );
245 - }
246 -
247 218 $rollback_versions = [];
248 219
249 220 $current_index = 0;
250 - foreach ( $versions as $version ) {
221 + foreach ( $plugin_information->versions as $version => $download_link ) {
251 222 if ( $max_versions <= $current_index ) {
252 223 break;
253 224 }
254 225
@@ -275,9 +246,9 @@
275 246 if ( version_compare( $version, ELEMENTOR_VERSION, '>=' ) ) {
276 247 continue;
277 248 }
278 249
279 - ++$current_index;
250 + $current_index++;
280 251 $rollback_versions[] = $version;
281 252 }
282 253
283 254 set_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION, $rollback_versions, WEEK_IN_SECONDS );
@@ -310,13 +281,13 @@
310 281 'sections' => [
311 282 'tools' => [
312 283 'fields' => [
313 284 'clear_cache' => [
314 - 'label' => esc_html__( 'Elementor Cache', 'elementor' ),
285 + 'label' => esc_html__( 'Regenerate CSS & Data', 'elementor' ),
315 286 'field_args' => [
316 287 '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' ),
288 + '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' ) ),
289 + '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 290 ],
320 291 ],
321 292 'reset_api_data' => [
322 293 'label' => esc_html__( 'Sync Library', 'elementor' ),
@@ -321,9 +292,9 @@
321 292 'reset_api_data' => [
322 293 'label' => esc_html__( 'Sync Library', 'elementor' ),
323 294 'field_args' => [
324 295 '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' ) ),
296 + '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 297 '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 298 ],
328 299 ],
329 300 ],
@@ -334,19 +305,17 @@
334 305 'label' => esc_html__( 'Replace URL', 'elementor' ),
335 306 'sections' => [
336 307 'replace_url' => [
337 308 'callback' => function() {
309 + $intro_text = sprintf(
310 + /* translators: %s: WordPress backups documentation. */
311 + __( '<strong>Important:</strong> It is strongly recommended that you <a target="_blank" href="%s">backup your database</a> before using Replace URL.', 'elementor' ),
312 + 'https://go.elementor.com/wordpress-backups/'
313 + );
314 + $intro_text = '<div>' . $intro_text . '</div>';
315 +
338 316 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 - );
317 + Utils::print_unescaped_internal_string( $intro_text );
349 318 },
350 319 'fields' => [
351 320 'replace_url' => [
352 321 'label' => esc_html__( 'Update Site Address (URL)', 'elementor' ),
@@ -351,9 +320,9 @@
351 320 'replace_url' => [
352 321 'label' => esc_html__( 'Update Site Address (URL)', 'elementor' ),
353 322 'field_args' => [
354 323 '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' ) ),
324 + '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" class="button elementor-button-spinner" id="elementor-replace-url-button">%s</button>', wp_create_nonce( 'elementor_replace_url' ), esc_html__( 'Replace URL', 'elementor' ) ),
356 325 '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 326 ],
358 327 ],
359 328 ],
@@ -381,32 +350,29 @@
381 350 'label' => esc_html__( 'Rollback Version', 'elementor' ),
382 351 'field_args' => [
383 352 'type' => 'raw_html',
384 353 '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' )
354 + $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>',
355 + wp_nonce_url( admin_url( 'admin-post.php?action=elementor_rollback&version=VERSION' ), 'elementor_rollback' ),
356 + esc_html__( 'Reinstall', 'elementor' )
388 357 ),
389 - 'desc' => $this->get_warning_span( esc_html__( 'Warning: Please back up your database before making the rollback.', 'elementor' ) ),
358 + 'desc' => '<span style="color: red;">' . esc_html__( 'Warning: Please backup your database before making the rollback.', 'elementor' ) . '</span>',
390 359 ],
391 360 ],
392 361 ],
393 362 ],
394 363 'beta' => [
395 - 'show_if' => $this->display_beta_tester(),
396 364 'label' => esc_html__( 'Become a Beta Tester', 'elementor' ),
397 365 'callback' => function() {
398 366 echo '<p>' .
399 367 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 368 '</p>';
401 - echo '<p>' . sprintf(
369 + echo sprintf(
402 370 /* 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>';
371 + esc_html__( '%1$sClick here%2$s to join our first-to-know email updates.', 'elementor' ),
372 + '<a id="beta-tester-first-to-know" href="#">',
373 + '</a>'
374 + );
409 375 },
410 376 'fields' => [
411 377 'beta' => [
412 378 'label' => esc_html__( 'Beta Tester', 'elementor' ),
@@ -416,9 +382,9 @@
416 382 'options' => [
417 383 'no' => esc_html__( 'Disable', 'elementor' ),
418 384 'yes' => esc_html__( 'Enable', 'elementor' ),
419 385 ],
420 - 'desc' => $this->get_warning_span( esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) ),
386 + 'desc' => '<span style="color: red;">' . esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) . '</span>',
421 387 ],
422 388 ],
423 389 ],
424 390 ],
@@ -459,27 +425,6 @@
459 425 * @return bool
460 426 */
461 427 public static function can_user_rollback_versions() {
462 428 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 429 }
485 430 }