Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
wp-content
/
plugins
/
elementor
/
modules
/
safe-mode
/
mu-plugin
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php if (!defined('ABSPATH')) { exit; } class Safe_Mode { const OPTION_ENABLED = 'elementor_safe_mode'; const OPTION_TOKEN = self::OPTION_ENABLED . '_token'; public function is_enabled() { return get_option(self::OPTION_ENABLED); } public function is_valid_token() { $token = isset($_COOKIE[self::OPTION_TOKEN]) ? $_COOKIE[self::OPTION_TOKEN] : null; if ($token && get_option(self::OPTION_TOKEN) === $token) { return true; } return false; } public function is_requested() { return !empty($_REQUEST['elementor-mode']) && 'safe' === $_REQUEST['elementor-mode']; } public function is_editor() { return is_admin() && isset($_GET['action']) && 'elementor' === $_GET['action']; } public function is_editor_preview() { return isset($_GET['elementor-preview']); } public function is_editor_ajax() { return is_admin() && isset($_POST['action']) && 'elementor_ajax' === $_POST['action']; } public function add_hooks() { add_filter('pre_option_active_plugins', function () { return get_option('elementor_safe_mode_allowed_plugins'); }); add_filter('pre_option_stylesheet', function () { return 'elementor-safe'; }); add_filter('pre_option_template', function () { return 'elementor-safe'; }); add_action('elementor/init', function () { do_action('elementor/safe_mode/init'); }); } public function plugin_row_meta($plugin_meta, $plugin_file, $plugin_data, $status) { if (basename(__FILE__) === $plugin_file) { $row_meta = ['docs' => '<a href="https://go.elementor.com/safe-mode/" aria-label="' . esc_attr(__('Learn More', 'elementor')) . '" target="_blank">' . __('Learn More', 'elementor') . '</a>']; $plugin_meta = array_merge($plugin_meta, $row_meta); } return $plugin_meta; } public function __construct() { add_filter('plugin_row_meta', [$this, 'plugin_row_meta'], 10, 4); $enabled_type = $this->is_enabled(); if (!$enabled_type || !$this->is_valid_token()) { return; } if (!$this->is_requested() && 'global' !== $enabled_type) { return; } if (!$this->is_editor() && !$this->is_editor_preview() && !$this->is_editor_ajax()) { return; } $this->add_hooks(); } } new Safe_Mode();