| 1 |
<?php |
| 2 |
namespace Elementor\Core\Settings\EditorPreferences; |
| 3 |
|
| 4 |
use Elementor\Controls_Manager; |
| 5 |
use Elementor\Core\Settings\Base\Model as BaseModel; |
| 6 |
use Elementor\Modules\EditorAppBar\Module as AppBarModule; |
| 7 |
use Elementor\Modules\Checklist\Module as ChecklistModule; |
| 8 |
use Elementor\Plugin; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; // Exit if accessed directly. |
| 12 |
} |
| 13 |
|
| 14 |
class Model extends BaseModel { |
| 15 |
|
| 16 |
/** |
| 17 |
* Get element name. |
| 18 |
* |
| 19 |
* Retrieve the element name. |
| 20 |
* |
| 21 |
* @return string The name. |
| 22 |
* @since 2.8.0 |
| 23 |
* @access public |
| 24 |
*/ |
| 25 |
public function get_name() { |
| 26 |
return 'editor-preferences'; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Get panel page settings. |
| 31 |
* |
| 32 |
* Retrieve the page setting for the current panel. |
| 33 |
* |
| 34 |
* @since 2.8.0 |
| 35 |
* @access public |
| 36 |
*/ |
| 37 |
public function get_panel_page_settings() { |
| 38 |
return [ |
| 39 |
'title' => esc_html__( 'User Preferences', 'elementor' ), |
| 40 |
]; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* @since 3.1.0 |
| 45 |
* @access protected |
| 46 |
*/ |
| 47 |
protected function register_controls() { |
| 48 |
$this->start_controls_section( |
| 49 |
'preferences', |
| 50 |
[ |
| 51 |
'tab' => Controls_Manager::TAB_SETTINGS, |
| 52 |
'label' => esc_html__( 'Preferences', 'elementor' ), |
| 53 |
] |
| 54 |
); |
| 55 |
|
| 56 |
$this->add_control( |
| 57 |
'editor_heading', |
| 58 |
[ |
| 59 |
'label' => esc_html__( 'Panel', 'elementor' ), |
| 60 |
'type' => Controls_Manager::HEADING, |
| 61 |
] |
| 62 |
); |
| 63 |
|
| 64 |
$this->add_control( |
| 65 |
'ui_theme', |
| 66 |
[ |
| 67 |
'label' => esc_html__( 'Display mode', 'elementor' ), |
| 68 |
'type' => Controls_Manager::CHOOSE, |
| 69 |
'options' => [ |
| 70 |
'light' => [ |
| 71 |
'title' => esc_html__( 'Light mode', 'elementor' ), |
| 72 |
'icon' => 'eicon-light-mode', |
| 73 |
], |
| 74 |
'dark' => [ |
| 75 |
'title' => esc_html__( 'Dark mode', 'elementor' ), |
| 76 |
'icon' => 'eicon-dark-mode', |
| 77 |
], |
| 78 |
'auto' => [ |
| 79 |
'title' => esc_html__( 'Auto detect', 'elementor' ), |
| 80 |
'icon' => 'eicon-header', |
| 81 |
], |
| 82 |
], |
| 83 |
'default' => 'auto', |
| 84 |
'description' => esc_html__( 'Set light or dark mode, or auto-detect to sync with your operating system settings.', 'elementor' ), |
| 85 |
] |
| 86 |
); |
| 87 |
|
| 88 |
$this->add_control( |
| 89 |
'panel_width', |
| 90 |
[ |
| 91 |
'label' => esc_html__( 'Width', 'elementor' ) . ' (px)', |
| 92 |
'type' => Controls_Manager::SLIDER, |
| 93 |
'range' => [ |
| 94 |
'px' => [ |
| 95 |
'min' => 200, |
| 96 |
'max' => 680, |
| 97 |
], |
| 98 |
], |
| 99 |
'default' => [ |
| 100 |
'size' => 300, |
| 101 |
], |
| 102 |
] |
| 103 |
); |
| 104 |
|
| 105 |
$this->add_control( |
| 106 |
'preview_heading', |
| 107 |
[ |
| 108 |
'label' => esc_html__( 'Canvas', 'elementor' ), |
| 109 |
'type' => Controls_Manager::HEADING, |
| 110 |
'separator' => 'before', |
| 111 |
] |
| 112 |
); |
| 113 |
|
| 114 |
if ( ! Plugin::$instance->experiments->is_feature_active( AppBarModule::EXPERIMENT_NAME ) ) { |
| 115 |
|
| 116 |
$this->add_control( |
| 117 |
'default_device_view', |
| 118 |
[ |
| 119 |
'label' => esc_html__( 'Default device view', 'elementor' ), |
| 120 |
'type' => Controls_Manager::SELECT, |
| 121 |
'default' => 'default', |
| 122 |
'options' => [ |
| 123 |
'default' => esc_html__( 'Default', 'elementor' ), |
| 124 |
'mobile' => esc_html__( 'Mobile', 'elementor' ), |
| 125 |
'tablet' => esc_html__( 'Tablet', 'elementor' ), |
| 126 |
'desktop' => esc_html__( 'Desktop', 'elementor' ), |
| 127 |
], |
| 128 |
'description' => esc_html__( 'Choose which device to display when clicking the Responsive Mode icon.', 'elementor' ), |
| 129 |
] |
| 130 |
); |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
$this->add_control( |
| 135 |
'edit_buttons', |
| 136 |
[ |
| 137 |
'label' => esc_html__( 'Show quick edit options', 'elementor' ), |
| 138 |
'type' => Controls_Manager::SWITCHER, |
| 139 |
'label_on' => esc_html__( 'Yes', 'elementor' ), |
| 140 |
'label_off' => esc_html__( 'No', 'elementor' ), |
| 141 |
'description' => esc_html__( 'Show additional actions while hovering over the handle of an element.', 'elementor' ), |
| 142 |
] |
| 143 |
); |
| 144 |
|
| 145 |
$this->add_control( |
| 146 |
'lightbox_in_editor', |
| 147 |
[ |
| 148 |
'label' => esc_html__( 'Expand images in lightbox', 'elementor' ), |
| 149 |
'type' => Controls_Manager::SWITCHER, |
| 150 |
'default' => 'yes', |
| 151 |
'label_on' => esc_html__( 'Yes', 'elementor' ), |
| 152 |
'label_off' => esc_html__( 'No', 'elementor' ), |
| 153 |
'description' => esc_html__( 'This only applies while you’re working in the editor. The front end won’t be affected.', 'elementor' ), |
| 154 |
] |
| 155 |
); |
| 156 |
|
| 157 |
$this->add_control( |
| 158 |
'show_hidden_elements', |
| 159 |
[ |
| 160 |
'label' => esc_html__( 'Show hidden elements', 'elementor' ), |
| 161 |
'type' => Controls_Manager::SWITCHER, |
| 162 |
'label_on' => esc_html__( 'Yes', 'elementor' ), |
| 163 |
'label_off' => esc_html__( 'No', 'elementor' ), |
| 164 |
'default' => 'yes', |
| 165 |
'description' => esc_html__( 'This refers to elements you’ve hidden in the Responsive Visibility settings.', 'elementor' ), |
| 166 |
] |
| 167 |
); |
| 168 |
|
| 169 |
if ( ChecklistModule::should_display_checklist_toggle_control() ) { |
| 170 |
$this->add_control( |
| 171 |
'get_started_heading', |
| 172 |
[ |
| 173 |
'label' => esc_html__( 'Get Started', 'elementor' ), |
| 174 |
'type' => Controls_Manager::HEADING, |
| 175 |
'separator' => 'before', |
| 176 |
] |
| 177 |
); |
| 178 |
|
| 179 |
$this->add_control( |
| 180 |
ChecklistModule::VISIBILITY_SWITCH_ID, |
| 181 |
[ |
| 182 |
'label' => esc_html__( 'Launchpad Checklist', 'elementor' ), |
| 183 |
'type' => Controls_Manager::SWITCHER, |
| 184 |
'label_on' => esc_html__( 'Show', 'elementor' ), |
| 185 |
'label_off' => esc_html__( 'Hide', 'elementor' ), |
| 186 |
'default' => Plugin::$instance->modules_manager->get_modules( 'checklist' )->is_preference_switch_on() ? 'yes' : '', |
| 187 |
'description' => esc_html__( 'Show a checklist to guide you through your first steps of website creation.', 'elementor' ), |
| 188 |
] |
| 189 |
); |
| 190 |
} |
| 191 |
|
| 192 |
$this->add_control( |
| 193 |
'design_system_heading', |
| 194 |
[ |
| 195 |
'label' => esc_html__( 'Design System', 'elementor' ), |
| 196 |
'type' => Controls_Manager::HEADING, |
| 197 |
'separator' => 'before', |
| 198 |
] |
| 199 |
); |
| 200 |
|
| 201 |
$this->add_control( |
| 202 |
'enable_styleguide_preview', |
| 203 |
[ |
| 204 |
'label' => esc_html__( 'Show global settings', 'elementor' ), |
| 205 |
'type' => Controls_Manager::SWITCHER, |
| 206 |
'default' => 'yes', |
| 207 |
'label_on' => esc_html__( 'Yes', 'elementor' ), |
| 208 |
'label_off' => esc_html__( 'No', 'elementor' ), |
| 209 |
'description' => esc_html__( 'Temporarily overlay the canvas with the style guide to preview your changes to global colors and fonts.', 'elementor' ), |
| 210 |
] |
| 211 |
); |
| 212 |
|
| 213 |
$this->add_control( |
| 214 |
'navigation_heading', |
| 215 |
[ |
| 216 |
'label' => esc_html__( 'Navigation', 'elementor' ), |
| 217 |
'type' => Controls_Manager::HEADING, |
| 218 |
'separator' => 'before', |
| 219 |
] |
| 220 |
); |
| 221 |
|
| 222 |
$this->add_control( |
| 223 |
'exit_to', |
| 224 |
[ |
| 225 |
'label' => esc_html__( 'Exit to', 'elementor' ), |
| 226 |
'type' => Controls_Manager::SELECT, |
| 227 |
'default' => 'this_post', |
| 228 |
'options' => [ |
| 229 |
'this_post' => esc_html__( 'This Post', 'elementor' ), |
| 230 |
'all_posts' => esc_html__( 'All Posts', 'elementor' ), |
| 231 |
'dashboard' => esc_html__( 'WP Dashboard', 'elementor' ), |
| 232 |
], |
| 233 |
'description' => esc_html__( 'Decide where you want to go when leaving the editor.', 'elementor' ), |
| 234 |
] |
| 235 |
); |
| 236 |
|
| 237 |
$this->end_controls_section(); |
| 238 |
} |
| 239 |
} |
| 240 |
|