PluginProbe
Elementor Website Builder – more than just a page builder / 3.2.5
Elementor Website Builder – more than just a page builder v3.2.5
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/safe-mode/module.php +101 -102 4.2.23.2.5 View file →
@@ -5,12 +5,11 @@
5 5 use Elementor\Settings;
6 6 use Elementor\Tools;
7 7 use Elementor\TemplateLibrary\Source_Local;
8 8 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
9 -use Elementor\Utils;
10 9
11 10 if ( ! defined( 'ABSPATH' ) ) {
12 - exit; // Exit if accessed directly.
11 + exit; // Exit if accessed directly
13 12 }
14 13
15 14 class Module extends \Elementor\Core\Base\Module {
16 15
@@ -38,18 +37,18 @@
38 37 */
39 38 public function add_admin_button( $tools_page ) {
40 39 $tools_page->add_fields( Settings::TAB_GENERAL, 'tools', [
41 40 'safe_mode' => [
42 - 'label' => esc_html__( 'Safe Mode', 'elementor' ),
41 + 'label' => __( 'Safe Mode', 'elementor' ),
43 42 'field_args' => [
44 43 'type' => 'select',
45 - 'std' => $this->is_enabled() ? 'global' : '',
44 + 'std' => $this->is_enabled(),
46 45 'options' => [
47 - '' => esc_html__( 'Disable', 'elementor' ),
48 - 'global' => esc_html__( 'Enable', 'elementor' ),
46 + '' => __( 'Disable', 'elementor' ),
47 + 'global' => __( 'Enable', 'elementor' ),
49 48
50 49 ],
51 - 'desc' => esc_html__( 'Safe Mode allows you to troubleshoot issues by only loading the editor, without loading the theme or any other plugin.', 'elementor' ),
50 + 'desc' => __( 'Safe Mode allows you to troubleshoot issues by only loading the editor, without loading the theme or any other plugin.', 'elementor' ),
52 51 ],
53 52 ],
54 53 ] );
55 54 }
@@ -63,16 +62,9 @@
63 62
64 63 return $value;
65 64 }
66 65
67 - /**
68 - * @throws \Exception If the safe mode cannot be enabled.
69 - */
70 66 public function ajax_enable_safe_mode( $data ) {
71 - if ( ! current_user_can( 'install_plugins' ) ) {
72 - throw new \Exception( 'Access denied.' );
73 - }
74 -
75 67 // It will run `$this->>update_safe_mode`.
76 68 update_option( 'elementor_safe_mode', 'yes' );
77 69
78 70 $document = Plugin::$instance->documents->get( $data['editor_post_id'] );
@@ -98,9 +90,9 @@
98 90 add_option( 'elementor_safe_mode_created_mu_dir', true );
99 91 }
100 92
101 93 if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
102 - wp_die( esc_html__( 'Cannot enable Safe Mode', 'elementor' ) );
94 + wp_die( __( 'Cannot enable Safe Mode', 'elementor' ) );
103 95 }
104 96
105 97 $results = copy_dir( __DIR__ . '/mu-plugin/', WPMU_PLUGIN_DIR );
106 98
@@ -107,15 +99,15 @@
107 99 if ( is_wp_error( $results ) ) {
108 100 return;
109 101 }
110 102
111 - $token = hash( 'sha256', wp_rand() );
103 + $token = md5( wp_rand() );
112 104
113 105 // Only who own this key can use 'elementor-safe-mode'.
114 106 update_option( self::OPTION_TOKEN, $token );
115 107
116 108 // Save for later use.
117 - setcookie( self::OPTION_TOKEN, $token, time() + HOUR_IN_SECONDS, COOKIEPATH, '', is_ssl(), true );
109 + setcookie( self::OPTION_TOKEN, $token, time() + HOUR_IN_SECONDS, COOKIEPATH );
118 110 }
119 111
120 112 public function disable_safe_mode() {
121 113 if ( ! current_user_can( 'install_plugins' ) ) {
@@ -137,9 +129,9 @@
137 129 delete_option( 'theme_mods_elementor-safe' );
138 130 delete_option( 'elementor_safe_mode_created_mu_dir' );
139 131
140 132 delete_option( self::OPTION_TOKEN );
141 - setcookie( self::OPTION_TOKEN, '', 1, '', '', is_ssl(), true );
133 + setcookie( self::OPTION_TOKEN, '', 1 );
142 134 }
143 135
144 136 public function filter_preview_url( $url ) {
145 137 return add_query_arg( 'elementor-mode', 'safe', $url );
@@ -154,23 +146,26 @@
154 146 <style>
155 147 .elementor-safe-mode-toast {
156 148 position: absolute;
157 149 z-index: 10000; /* Over the loading layer */
158 - inset-block-end: 10px;
159 - inset-inline-end: 10px;
150 + bottom: 10px;
160 151 width: 400px;
161 152 line-height: 30px;
162 - display: flex;
163 - flex-direction: column;
164 - gap: 20px;
165 - color: var(--e-a-color-txt);
166 - background: var(--e-a-bg-default);
153 + background: white;
167 154 padding: 20px 25px 25px;
168 155 box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
169 156 border-radius: 5px;
170 - font-family: var(--e-a-font-family);
157 + font-family: Roboto, Arial, Helvetica, Verdana, sans-serif;
171 158 }
172 159
160 + body.rtl .elementor-safe-mode-toast {
161 + left: 10px;
162 + }
163 +
164 + body:not(.rtl) .elementor-safe-mode-toast {
165 + right: 10px;
166 + }
167 +
173 168 #elementor-try-safe-mode {
174 169 display: none;
175 170 }
176 171
@@ -176,50 +171,88 @@
176 171
177 172 .elementor-safe-mode-toast .elementor-toast-content {
178 173 font-size: 13px;
179 174 line-height: 22px;
175 + color: #6D7882;
180 176 }
181 177
182 178 .elementor-safe-mode-toast .elementor-toast-content a {
183 - color: var(--e-a-color-info);
179 + color: #138FFF;
184 180 }
185 181
186 182 .elementor-safe-mode-toast .elementor-toast-content hr {
187 183 margin: 15px auto;
188 184 border: 0 none;
189 - border-block-start: var(--e-a-border);
185 + border-top: 1px solid #F1F3F5;
190 186 }
191 187
192 188 .elementor-safe-mode-toast header {
193 189 display: flex;
194 190 align-items: center;
195 - gap: 10px;
191 + justify-content: space-between;
192 + flex-wrap: wrap;
193 + margin-bottom: 20px;
196 194 }
197 195
196 + .elementor-safe-mode-toast header > * {
197 + margin-top: 10px;
198 + }
199 +
200 + .elementor-safe-mode-toast .elementor-safe-mode-button {
201 + display: inline-block;
202 + font-weight: 500;
203 + font-size: 11px;
204 + text-transform: uppercase;
205 + color: white;
206 + padding: 10px 15px;
207 + line-height: 1;
208 + background: #A4AFB7;
209 + border-radius: 3px;
210 + }
211 +
212 + #elementor-try-safe-mode .elementor-safe-mode-button {
213 + background: #39B54A;
214 + }
215 +
198 216 .elementor-safe-mode-toast header i {
199 217 font-size: 25px;
200 - color: var(--e-a-color-warning);
218 + color: #fcb92c;
201 219 }
202 220
221 + body:not(.rtl) .elementor-safe-mode-toast header i {
222 + margin-right: 10px;
223 + }
224 +
225 + body.rtl .elementor-safe-mode-toast header i {
226 + margin-left: 10px;
227 + }
228 +
203 229 .elementor-safe-mode-toast header h2 {
204 230 flex-grow: 1;
205 231 font-size: 18px;
232 + color: #6D7882;
206 233 }
207 234
208 - .elementor-safe-mode-list {
209 - display: flex;
210 - flex-direction: column;
211 - gap: 10px;
235 + .elementor-safe-mode-list-item {
236 + margin-top: 10px;
237 + list-style: outside;
212 238 }
213 239
214 - .elementor-safe-mode-list-item {
215 - margin-inline-start: 15px;
216 - list-style: outside;
240 + body:not(.rtl) .elementor-safe-mode-list-item {
241 + margin-left: 15px;
217 242 }
218 243
244 + body.rtl .elementor-safe-mode-list-item {
245 + margin-right: 15px;
246 + }
247 +
248 + .elementor-safe-mode-list-item b {
249 + font-size: 14px;
250 + }
251 +
219 252 .elementor-safe-mode-list-item-content {
220 253 font-style: italic;
221 - color: var(--e-a-color-txt);
254 + color: #a4afb7;
222 255 }
223 256
224 257 .elementor-safe-mode-list-item-title {
225 258 font-weight: 500;
@@ -225,11 +258,10 @@
225 258 font-weight: 500;
226 259 }
227 260
228 261 .elementor-safe-mode-mu-plugins {
229 - background-color: var(--e-a-bg-hover);
230 - color: var(--e-a-color-txt-hover);
231 - margin-block-start: 20px;
262 + background-color: #f1f3f5;
263 + margin-top: 20px;
232 264 padding: 10px 15px;
233 265 }
234 266 </style>
235 267 <?php
@@ -235,16 +267,16 @@
235 267 <?php
236 268 }
237 269
238 270 public function print_safe_mode_notice() {
239 - $this->print_safe_mode_css()
271 + echo $this->print_safe_mode_css();
240 272 ?>
241 273 <div class="elementor-safe-mode-toast" id="elementor-safe-mode-message">
242 274 <header>
243 - <i class="eicon-warning" aria-hidden="true"></i>
244 - <h2><?php echo esc_html__( 'Safe Mode ON', 'elementor' ); ?></h2>
245 - <a class="elementor-button elementor-safe-mode-button elementor-disable-safe-mode" target="_blank" href="<?php echo esc_url( $this->get_admin_page_url() ); ?>">
246 - <?php echo esc_html__( 'Disable Safe Mode', 'elementor' ); ?>
275 + <i class="eicon-warning"></i>
276 + <h2><?php echo __( 'Safe Mode ON', 'elementor' ); ?></h2>
277 + <a class="elementor-safe-mode-button elementor-disable-safe-mode" target="_blank" href="<?php echo $this->get_admin_page_url(); ?>">
278 + <?php echo __( 'Disable Safe Mode', 'elementor' ); ?>
247 279 </a>
248 280 </header>
249 281
250 282 <div class="elementor-toast-content">
@@ -249,35 +281,14 @@
249 281
250 282 <div class="elementor-toast-content">
251 283 <ul class="elementor-safe-mode-list">
252 284 <li class="elementor-safe-mode-list-item">
253 - <div class="elementor-safe-mode-list-item-title"><?php echo esc_html__( 'Editor successfully loaded?', 'elementor' ); ?></div>
254 - <div class="elementor-safe-mode-list-item-content">
255 - <?php
256 - echo esc_html__( 'The issue was probably caused by one of your plugins or theme.', 'elementor' );
257 - echo ' ';
258 -
259 - printf(
260 - /* translators: %1$s Link open tag, %2$s: Link close tag. */
261 - esc_html__( '%1$sClick here%2$s to troubleshoot', 'elementor' ),
262 - '<a href="' . self::DOCS_HELPED_URL . '" target="_blank">', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
263 - '</a>'
264 - );
265 - ?>
266 - </div>
285 + <div class="elementor-safe-mode-list-item-title"><?php echo __( 'Editor successfully loaded?', 'elementor' ); ?></div>
286 + <div class="elementor-safe-mode-list-item-content"><?php echo __( 'The issue was probably caused by one of your plugins or theme.', 'elementor' ); ?> <?php printf( __( '<a href="%s" target="_blank">Click here</a> to troubleshoot', 'elementor' ), self::DOCS_HELPED_URL ); ?></div>
267 287 </li>
268 288 <li class="elementor-safe-mode-list-item">
269 - <div class="elementor-safe-mode-list-item-title"><?php echo esc_html__( 'Still experiencing issues?', 'elementor' ); ?></div>
270 - <div class="elementor-safe-mode-list-item-content">
271 - <?php
272 - printf(
273 - /* translators: %1$s Link open tag, %2$s: Link close tag. */
274 - esc_html__( '%1$sClick here%2$s to troubleshoot', 'elementor' ),
275 - '<a href="' . self::DOCS_DIDNT_HELP_URL . '" target="_blank">', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
276 - '</a>'
277 - );
278 - ?>
279 - </div>
289 + <div class="elementor-safe-mode-list-item-title"><?php echo __( 'Still experiencing issues?', 'elementor' ); ?></div>
290 + <div class="elementor-safe-mode-list-item-content"><?php printf( __( '<a href="%s" target="_blank">Click here</a> to troubleshoot', 'elementor' ), self::DOCS_DIDNT_HELP_URL ); ?></div>
280 291 </li>
281 292 </ul>
282 293 <?php
283 294 $mu_plugins = wp_get_mu_plugins();
@@ -282,18 +293,9 @@
282 293 <?php
283 294 $mu_plugins = wp_get_mu_plugins();
284 295
285 296 if ( 1 < count( $mu_plugins ) ) : ?>
286 - <div class="elementor-safe-mode-mu-plugins">
287 - <?php
288 - printf(
289 - /* translators: %1$s Link open tag, %2$s: Link close tag. */
290 - esc_html__( 'Please note! We couldn\'t deactivate all of your plugins on Safe Mode. Please %1$sread more%2$s about this issue', 'elementor' ),
291 - '<a href="' . self::DOCS_MU_PLUGINS_URL . '" target="_blank">', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292 - '</a>'
293 - );
294 - ?>
295 - </div>
297 + <div class="elementor-safe-mode-mu-plugins"><?php printf( __( 'Please note! We couldn\'t deactivate all of your plugins on Safe Mode. Please <a href="%s" target="_blank">read more</a> about this issue.', 'elementor' ), self::DOCS_MU_PLUGINS_URL ); ?></div>
296 298 <?php endif; ?>
297 299 </div>
298 300 </div>
299 301
@@ -299,9 +301,9 @@
299 301
300 302 <script>
301 303 var ElementorSafeMode = function() {
302 304 var attachEvents = function() {
303 - jQuery( '.elementor-disable-safe-mode' ).on( 'click', function( e ) {
305 + jQuery( '.elementor-disable-safe-mode' ).on( 'click', function( e ) {
304 306 if ( ! elementorCommon || ! elementorCommon.ajax ) {
305 307 return;
306 308 }
307 309
@@ -317,9 +319,9 @@
317 319 location.replace( location.href.replace( '&elementor-mode=safe', '' ) );
318 320 }
319 321 },
320 322 error: function() {
321 - alert( 'An error occurred.' );
323 + alert( 'An error occurred' );
322 324 },
323 325 },
324 326 true
325 327 );
@@ -342,31 +344,31 @@
342 344 if ( ! $this->is_allowed_post_type() ) {
343 345 return;
344 346 }
345 347
346 - $this->print_safe_mode_css();
348 + echo $this->print_safe_mode_css();
347 349 ?>
348 350 <div class="elementor-safe-mode-toast" id="elementor-try-safe-mode">
349 351 <?php if ( current_user_can( 'install_plugins' ) ) : ?>
350 352 <header>
351 - <i class="eicon-warning" aria-hidden="true"></i>
352 - <h2><?php echo esc_html__( 'Can\'t Edit?', 'elementor' ); ?></h2>
353 - <a class="elementor-button e-primary elementor-safe-mode-button elementor-enable-safe-mode" target="_blank" href="<?php echo esc_url( $this->get_admin_page_url() ); ?>">
354 - <?php echo esc_html__( 'Enable Safe Mode', 'elementor' ); ?>
353 + <i class="eicon-warning"></i>
354 + <h2><?php echo __( 'Can\'t Edit?', 'elementor' ); ?></h2>
355 + <a class="elementor-safe-mode-button elementor-enable-safe-mode" target="_blank" href="<?php echo $this->get_admin_page_url(); ?>">
356 + <?php echo __( 'Enable Safe Mode', 'elementor' ); ?>
355 357 </a>
356 358 </header>
357 359 <div class="elementor-toast-content">
358 - <?php echo esc_html__( 'Having problems loading Elementor? Please enable Safe Mode to troubleshoot.', 'elementor' ); ?>
359 - <a href="<?php Utils::print_unescaped_internal_string( self::DOCS_TRY_SAFE_MODE_URL ); ?>" target="_blank"><?php echo esc_html__( 'Learn More', 'elementor' ); ?></a>
360 + <?php echo __( 'Having problems loading Elementor? Please enable Safe Mode to troubleshoot.', 'elementor' ); ?>
361 + <a href="<?php echo self::DOCS_TRY_SAFE_MODE_URL; ?>" target="_blank"><?php echo __( 'Learn More', 'elementor' ); ?></a>
360 362 </div>
361 363 <?php else : ?>
362 364 <header>
363 - <i class="eicon-warning" aria-hidden="true"></i>
364 - <h2><?php echo esc_html__( 'Can\'t Edit?', 'elementor' ); ?></h2>
365 + <i class="eicon-warning"></i>
366 + <h2><?php echo __( 'Can\'t Edit?', 'elementor' ); ?></h2>
365 367 </header>
366 368 <div class="elementor-toast-content">
367 - <?php echo esc_html__( 'If you are experiencing a loading issue, contact your site administrator to troubleshoot the problem using Safe Mode.', 'elementor' ); ?>
368 - <a href="<?php Utils::print_unescaped_internal_string( self::DOCS_TRY_SAFE_MODE_URL ); ?>" target="_blank"><?php echo esc_html__( 'Learn More', 'elementor' ); ?></a>
369 + <?php echo __( 'If you are experiencing a loading issue, contact your site administrator to troubleshoot the problem using Safe Mode.', 'elementor' ); ?>
370 + <a href="<?php echo self::DOCS_TRY_SAFE_MODE_URL; ?>" target="_blank"><?php echo __( 'Learn More', 'elementor' ); ?></a>
369 371 </div>
370 372 <?php endif; ?>
371 373 </div>
372 374
@@ -382,18 +384,15 @@
382 384
383 385 elementorCommon.ajax.addRequest(
384 386 'enable_safe_mode', {
385 387 data: {
386 - editor_post_id: '<?php
387 - // PHPCS - the method get_post_id is safe.
388 - echo Plugin::$instance->editor->get_post_id(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
389 - ?>',
388 + editor_post_id: '<?php echo Plugin::$instance->editor->get_post_id(); ?>',
390 389 },
391 390 success: function( url ) {
392 391 location.assign( url );
393 392 },
394 393 error: function() {
395 - alert( 'An error occurred.' );
394 + alert( 'An error occurred' );
396 395 },
397 396 },
398 397 true
399 398 );
@@ -424,9 +423,9 @@
424 423 return;
425 424 }
426 425
427 426 if ( ! $notice.data( 'visible' ) ) {
428 - $notice.attr( 'style', 'display: flex;' );
427 + $notice.show().data( 'visible', true );
429 428 }
430 429
431 430 // Re-check after 500ms.
432 431 setTimeout( handleTrySafeModeNotice, 500 );
@@ -432,9 +431,9 @@
432 431 setTimeout( handleTrySafeModeNotice, 500 );
433 432 };
434 433
435 434 var init = function() {
436 - setTimeout( handleTrySafeModeNotice, <?php Utils::print_unescaped_internal_string( self::EDITOR_NOTICE_TIMEOUT ); ?> );
435 + setTimeout( handleTrySafeModeNotice, <?php echo self::EDITOR_NOTICE_TIMEOUT; ?> );
437 436
438 437 attachEvents();
439 438 };
440 439
@@ -472,9 +471,9 @@
472 471 return Tools::get_url();
473 472 }
474 473
475 474 public function plugin_action_links( $actions ) {
476 - $actions['disable'] = '<a href="' . self::get_admin_page_url() . '">' . esc_html__( 'Disable Safe Mode', 'elementor' ) . '</a>';
475 + $actions['disable'] = '<a href="' . self::get_admin_page_url() . '">' . __( 'Disable Safe Mode', 'elementor' ) . '</a>';
477 476
478 477 return $actions;
479 478 }
480 479