| @@ -8,9 +8,9 @@ | ||
| 8 | 8 | use Elementor\Core\Common\Modules\Ajax\Module as Ajax; |
| 9 | 9 | use Elementor\Utils; |
| 10 | 10 | |
| 11 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | - exit; // Exit if accessed directly. | |
| 12 | + exit; // Exit if accessed directly | |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | class Module extends \Elementor\Core\Base\Module { |
| 16 | 16 | |
| @@ -41,9 +41,9 @@ | ||
| 41 | 41 | 'safe_mode' => [ |
| 42 | 42 | 'label' => esc_html__( 'Safe Mode', 'elementor' ), |
| 43 | 43 | 'field_args' => [ |
| 44 | 44 | 'type' => 'select', |
| 45 | - 'std' => $this->is_enabled() ? 'global' : '', | |
| 45 | + 'std' => $this->is_enabled(), | |
| 46 | 46 | 'options' => [ |
| 47 | 47 | '' => esc_html__( 'Disable', 'elementor' ), |
| 48 | 48 | 'global' => esc_html__( 'Enable', 'elementor' ), |
| 49 | 49 | |
| @@ -63,16 +63,9 @@ | ||
| 63 | 63 | |
| 64 | 64 | return $value; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - /** | |
| 68 | - * @throws \Exception If the safe mode cannot be enabled. | |
| 69 | - */ | |
| 70 | 67 | public function ajax_enable_safe_mode( $data ) { |
| 71 | - if ( ! current_user_can( 'install_plugins' ) ) { | |
| 72 | - throw new \Exception( 'Access denied.' ); | |
| 73 | - } | |
| 74 | - | |
| 75 | 68 | // It will run `$this->>update_safe_mode`. |
| 76 | 69 | update_option( 'elementor_safe_mode', 'yes' ); |
| 77 | 70 | |
| 78 | 71 | $document = Plugin::$instance->documents->get( $data['editor_post_id'] ); |
| @@ -107,15 +100,15 @@ | ||
| 107 | 100 | if ( is_wp_error( $results ) ) { |
| 108 | 101 | return; |
| 109 | 102 | } |
| 110 | 103 | |
| 111 | - $token = hash( 'sha256', wp_rand() ); | |
| 104 | + $token = md5( wp_rand() ); | |
| 112 | 105 | |
| 113 | 106 | // Only who own this key can use 'elementor-safe-mode'. |
| 114 | 107 | update_option( self::OPTION_TOKEN, $token ); |
| 115 | 108 | |
| 116 | 109 | // Save for later use. |
| 117 | - setcookie( self::OPTION_TOKEN, $token, time() + HOUR_IN_SECONDS, COOKIEPATH, '', is_ssl(), true ); | |
| 110 | + setcookie( self::OPTION_TOKEN, $token, time() + HOUR_IN_SECONDS, COOKIEPATH ); | |
| 118 | 111 | } |
| 119 | 112 | |
| 120 | 113 | public function disable_safe_mode() { |
| 121 | 114 | if ( ! current_user_can( 'install_plugins' ) ) { |
| @@ -137,9 +130,9 @@ | ||
| 137 | 130 | delete_option( 'theme_mods_elementor-safe' ); |
| 138 | 131 | delete_option( 'elementor_safe_mode_created_mu_dir' ); |
| 139 | 132 | |
| 140 | 133 | delete_option( self::OPTION_TOKEN ); |
| 141 | - setcookie( self::OPTION_TOKEN, '', 1, '', '', is_ssl(), true ); | |
| 134 | + setcookie( self::OPTION_TOKEN, '', 1 ); | |
| 142 | 135 | } |
| 143 | 136 | |
| 144 | 137 | public function filter_preview_url( $url ) { |
| 145 | 138 | return add_query_arg( 'elementor-mode', 'safe', $url ); |
| @@ -154,23 +147,26 @@ | ||
| 154 | 147 | <style> |
| 155 | 148 | .elementor-safe-mode-toast { |
| 156 | 149 | position: absolute; |
| 157 | 150 | z-index: 10000; /* Over the loading layer */ |
| 158 | - inset-block-end: 10px; | |
| 159 | - inset-inline-end: 10px; | |
| 151 | + bottom: 10px; | |
| 160 | 152 | width: 400px; |
| 161 | 153 | 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); | |
| 154 | + background: white; | |
| 167 | 155 | padding: 20px 25px 25px; |
| 168 | 156 | box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15); |
| 169 | 157 | border-radius: 5px; |
| 170 | - font-family: var(--e-a-font-family); | |
| 158 | + font-family: Roboto, Arial, Helvetica, Verdana, sans-serif; | |
| 171 | 159 | } |
| 172 | 160 | |
| 161 | + body.rtl .elementor-safe-mode-toast { | |
| 162 | + left: 10px; | |
| 163 | + } | |
| 164 | + | |
| 165 | + body:not(.rtl) .elementor-safe-mode-toast { | |
| 166 | + right: 10px; | |
| 167 | + } | |
| 168 | + | |
| 173 | 169 | #elementor-try-safe-mode { |
| 174 | 170 | display: none; |
| 175 | 171 | } |
| 176 | 172 | |
| @@ -176,50 +172,88 @@ | ||
| 176 | 172 | |
| 177 | 173 | .elementor-safe-mode-toast .elementor-toast-content { |
| 178 | 174 | font-size: 13px; |
| 179 | 175 | line-height: 22px; |
| 176 | + color: #6D7882; | |
| 180 | 177 | } |
| 181 | 178 | |
| 182 | 179 | .elementor-safe-mode-toast .elementor-toast-content a { |
| 183 | - color: var(--e-a-color-info); | |
| 180 | + color: #138FFF; | |
| 184 | 181 | } |
| 185 | 182 | |
| 186 | 183 | .elementor-safe-mode-toast .elementor-toast-content hr { |
| 187 | 184 | margin: 15px auto; |
| 188 | 185 | border: 0 none; |
| 189 | - border-block-start: var(--e-a-border); | |
| 186 | + border-top: 1px solid #F1F3F5; | |
| 190 | 187 | } |
| 191 | 188 | |
| 192 | 189 | .elementor-safe-mode-toast header { |
| 193 | 190 | display: flex; |
| 194 | 191 | align-items: center; |
| 195 | - gap: 10px; | |
| 192 | + justify-content: space-between; | |
| 193 | + flex-wrap: wrap; | |
| 194 | + margin-bottom: 20px; | |
| 196 | 195 | } |
| 197 | 196 | |
| 197 | + .elementor-safe-mode-toast header > * { | |
| 198 | + margin-top: 10px; | |
| 199 | + } | |
| 200 | + | |
| 201 | + .elementor-safe-mode-toast .elementor-safe-mode-button { | |
| 202 | + display: inline-block; | |
| 203 | + font-weight: 500; | |
| 204 | + font-size: 11px; | |
| 205 | + text-transform: uppercase; | |
| 206 | + color: white; | |
| 207 | + padding: 10px 15px; | |
| 208 | + line-height: 1; | |
| 209 | + background: #A4AFB7; | |
| 210 | + border-radius: 3px; | |
| 211 | + } | |
| 212 | + | |
| 213 | + #elementor-try-safe-mode .elementor-safe-mode-button { | |
| 214 | + background: #39B54A; | |
| 215 | + } | |
| 216 | + | |
| 198 | 217 | .elementor-safe-mode-toast header i { |
| 199 | 218 | font-size: 25px; |
| 200 | - color: var(--e-a-color-warning); | |
| 219 | + color: #fcb92c; | |
| 201 | 220 | } |
| 202 | 221 | |
| 222 | + body:not(.rtl) .elementor-safe-mode-toast header i { | |
| 223 | + margin-right: 10px; | |
| 224 | + } | |
| 225 | + | |
| 226 | + body.rtl .elementor-safe-mode-toast header i { | |
| 227 | + margin-left: 10px; | |
| 228 | + } | |
| 229 | + | |
| 203 | 230 | .elementor-safe-mode-toast header h2 { |
| 204 | 231 | flex-grow: 1; |
| 205 | 232 | font-size: 18px; |
| 233 | + color: #6D7882; | |
| 206 | 234 | } |
| 207 | 235 | |
| 208 | - .elementor-safe-mode-list { | |
| 209 | - display: flex; | |
| 210 | - flex-direction: column; | |
| 211 | - gap: 10px; | |
| 236 | + .elementor-safe-mode-list-item { | |
| 237 | + margin-top: 10px; | |
| 238 | + list-style: outside; | |
| 212 | 239 | } |
| 213 | 240 | |
| 214 | - .elementor-safe-mode-list-item { | |
| 215 | - margin-inline-start: 15px; | |
| 216 | - list-style: outside; | |
| 241 | + body:not(.rtl) .elementor-safe-mode-list-item { | |
| 242 | + margin-left: 15px; | |
| 217 | 243 | } |
| 218 | 244 | |
| 245 | + body.rtl .elementor-safe-mode-list-item { | |
| 246 | + margin-right: 15px; | |
| 247 | + } | |
| 248 | + | |
| 249 | + .elementor-safe-mode-list-item b { | |
| 250 | + font-size: 14px; | |
| 251 | + } | |
| 252 | + | |
| 219 | 253 | .elementor-safe-mode-list-item-content { |
| 220 | 254 | font-style: italic; |
| 221 | - color: var(--e-a-color-txt); | |
| 255 | + color: #a4afb7; | |
| 222 | 256 | } |
| 223 | 257 | |
| 224 | 258 | .elementor-safe-mode-list-item-title { |
| 225 | 259 | font-weight: 500; |
| @@ -225,11 +259,10 @@ | ||
| 225 | 259 | font-weight: 500; |
| 226 | 260 | } |
| 227 | 261 | |
| 228 | 262 | .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; | |
| 263 | + background-color: #f1f3f5; | |
| 264 | + margin-top: 20px; | |
| 232 | 265 | padding: 10px 15px; |
| 233 | 266 | } |
| 234 | 267 | </style> |
| 235 | 268 | <?php |
| @@ -235,15 +268,15 @@ | ||
| 235 | 268 | <?php |
| 236 | 269 | } |
| 237 | 270 | |
| 238 | 271 | public function print_safe_mode_notice() { |
| 239 | - $this->print_safe_mode_css() | |
| 272 | + Utils::print_unescaped_internal_string( $this->print_safe_mode_css() ); | |
| 240 | 273 | ?> |
| 241 | 274 | <div class="elementor-safe-mode-toast" id="elementor-safe-mode-message"> |
| 242 | 275 | <header> |
| 243 | - <i class="eicon-warning" aria-hidden="true"></i> | |
| 276 | + <i class="eicon-warning"></i> | |
| 244 | 277 | <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() ); ?>"> | |
| 278 | + <a class="elementor-safe-mode-button elementor-disable-safe-mode" target="_blank" href="<?php echo esc_url( $this->get_admin_page_url() ); ?>"> | |
| 246 | 279 | <?php echo esc_html__( 'Disable Safe Mode', 'elementor' ); ?> |
| 247 | 280 | </a> |
| 248 | 281 | </header> |
| 249 | 282 | |
| @@ -250,34 +283,19 @@ | ||
| 250 | 283 | <div class="elementor-toast-content"> |
| 251 | 284 | <ul class="elementor-safe-mode-list"> |
| 252 | 285 | <li class="elementor-safe-mode-list-item"> |
| 253 | 286 | <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> | |
| 287 | + <div class="elementor-safe-mode-list-item-content"><?php echo esc_html__( 'The issue was probably caused by one of your plugins or theme.', 'elementor' ); ?> <?php | |
| 288 | + // PHPCS - the constant DOCS_HELPED_URL holds a plain string. | |
| 289 | + printf( esc_html__( '<a href="%s" target="_blank">Click here</a> to troubleshoot', 'elementor' ), self::DOCS_HELPED_URL ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 290 | + ?></div> | |
| 267 | 291 | </li> |
| 268 | 292 | <li class="elementor-safe-mode-list-item"> |
| 269 | 293 | <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> | |
| 294 | + <div class="elementor-safe-mode-list-item-content"><?php | |
| 295 | + // PHPCS - the constant DOCS_DIDNT_HELP_URL holds a plain string. | |
| 296 | + printf( esc_html__( '<a href="%s" target="_blank">Click here</a> to troubleshoot', 'elementor' ), self::DOCS_DIDNT_HELP_URL ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 297 | + ?></div> | |
| 280 | 298 | </li> |
| 281 | 299 | </ul> |
| 282 | 300 | <?php |
| 283 | 301 | $mu_plugins = wp_get_mu_plugins(); |
| @@ -282,18 +300,12 @@ | ||
| 282 | 300 | <?php |
| 283 | 301 | $mu_plugins = wp_get_mu_plugins(); |
| 284 | 302 | |
| 285 | 303 | 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> | |
| 304 | + <div class="elementor-safe-mode-mu-plugins"><?php | |
| 305 | + // PHPCS - the constant DOCS_MU_PLUGINS_URL holds a plain string. | |
| 306 | + printf( esc_html__( '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 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 307 | + ?></div> | |
| 296 | 308 | <?php endif; ?> |
| 297 | 309 | </div> |
| 298 | 310 | </div> |
| 299 | 311 | |
| @@ -299,9 +311,9 @@ | ||
| 299 | 311 | |
| 300 | 312 | <script> |
| 301 | 313 | var ElementorSafeMode = function() { |
| 302 | 314 | var attachEvents = function() { |
| 303 | - jQuery( '.elementor-disable-safe-mode' ).on( 'click', function( e ) { | |
| 315 | + jQuery( '.elementor-disable-safe-mode' ).on( 'click', function( e ) { | |
| 304 | 316 | if ( ! elementorCommon || ! elementorCommon.ajax ) { |
| 305 | 317 | return; |
| 306 | 318 | } |
| 307 | 319 | |
| @@ -317,9 +329,9 @@ | ||
| 317 | 329 | location.replace( location.href.replace( '&elementor-mode=safe', '' ) ); |
| 318 | 330 | } |
| 319 | 331 | }, |
| 320 | 332 | error: function() { |
| 321 | - alert( 'An error occurred.' ); | |
| 333 | + alert( 'An error occurred' ); | |
| 322 | 334 | }, |
| 323 | 335 | }, |
| 324 | 336 | true |
| 325 | 337 | ); |
| @@ -342,16 +354,16 @@ | ||
| 342 | 354 | if ( ! $this->is_allowed_post_type() ) { |
| 343 | 355 | return; |
| 344 | 356 | } |
| 345 | 357 | |
| 346 | - $this->print_safe_mode_css(); | |
| 358 | + Utils::print_unescaped_internal_string( $this->print_safe_mode_css() ); | |
| 347 | 359 | ?> |
| 348 | 360 | <div class="elementor-safe-mode-toast" id="elementor-try-safe-mode"> |
| 349 | 361 | <?php if ( current_user_can( 'install_plugins' ) ) : ?> |
| 350 | 362 | <header> |
| 351 | - <i class="eicon-warning" aria-hidden="true"></i> | |
| 363 | + <i class="eicon-warning"></i> | |
| 352 | 364 | <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() ); ?>"> | |
| 365 | + <a class="elementor-safe-mode-button elementor-enable-safe-mode" target="_blank" href="<?php echo esc_url( $this->get_admin_page_url() ); ?>"> | |
| 354 | 366 | <?php echo esc_html__( 'Enable Safe Mode', 'elementor' ); ?> |
| 355 | 367 | </a> |
| 356 | 368 | </header> |
| 357 | 369 | <div class="elementor-toast-content"> |
| @@ -359,9 +371,9 @@ | ||
| 359 | 371 | <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 | 372 | </div> |
| 361 | 373 | <?php else : ?> |
| 362 | 374 | <header> |
| 363 | - <i class="eicon-warning" aria-hidden="true"></i> | |
| 375 | + <i class="eicon-warning"></i> | |
| 364 | 376 | <h2><?php echo esc_html__( 'Can\'t Edit?', 'elementor' ); ?></h2> |
| 365 | 377 | </header> |
| 366 | 378 | <div class="elementor-toast-content"> |
| 367 | 379 | <?php echo esc_html__( 'If you are experiencing a loading issue, contact your site administrator to troubleshoot the problem using Safe Mode.', 'elementor' ); ?> |
| @@ -391,9 +403,9 @@ | ||
| 391 | 403 | success: function( url ) { |
| 392 | 404 | location.assign( url ); |
| 393 | 405 | }, |
| 394 | 406 | error: function() { |
| 395 | - alert( 'An error occurred.' ); | |
| 407 | + alert( 'An error occurred' ); | |
| 396 | 408 | }, |
| 397 | 409 | }, |
| 398 | 410 | true |
| 399 | 411 | ); |
| @@ -424,9 +436,9 @@ | ||
| 424 | 436 | return; |
| 425 | 437 | } |
| 426 | 438 | |
| 427 | 439 | if ( ! $notice.data( 'visible' ) ) { |
| 428 | - $notice.attr( 'style', 'display: flex;' ); | |
| 440 | + $notice.show().data( 'visible', true ); | |
| 429 | 441 | } |
| 430 | 442 | |
| 431 | 443 | // Re-check after 500ms. |
| 432 | 444 | setTimeout( handleTrySafeModeNotice, 500 ); |