PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.3
Elementor Website Builder – more than just a page builder v3.1.3
4.3.0-beta3 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 All 452 releases
elementor / core / kits / documents / tabs / settings-layout.php

settings-layout.php in Elementor Website Builder – more than just a page builder 3.1.3, at core/kits/documents/tabs/settings-layout.php

220 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Kits\Documents\Tabs;
3
4 use Elementor\Plugin;
5 use Elementor\Controls_Manager;
6 use Elementor\Core\Base\Document;
7 use Elementor\Core\Responsive\Responsive;
8 use Elementor\Modules\PageTemplates\Module as PageTemplatesModule;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly
12 }
13
14 class Settings_Layout extends Tab_Base {
15
16 public function get_id() {
17 return 'settings-layout';
18 }
19
20 public function get_title() {
21 return __( 'Layout', 'elementor' );
22 }
23
24 public function get_group() {
25 return 'settings';
26 }
27
28 public function get_icon() {
29 return 'eicon-layout-settings';
30 }
31
32 public function get_help_url() {
33 return 'https://go.elementor.com/global-layout';
34 }
35
36 protected function register_tab_controls() {
37 $default_breakpoints = Responsive::get_default_breakpoints();
38
39 $this->start_controls_section(
40 'section_' . $this->get_id(),
41 [
42 'label' => __( 'Layout Settings', 'elementor' ),
43 'tab' => $this->get_id(),
44 ]
45 );
46
47 $this->add_responsive_control(
48 'container_width',
49 [
50 'label' => __( 'Content Width', 'elementor' ) . ' (px)',
51 'type' => Controls_Manager::SLIDER,
52 'default' => [
53 'size' => '1140',
54 ],
55 'tablet_default' => [
56 'size' => $default_breakpoints['lg'],
57 ],
58 'mobile_default' => [
59 'size' => $default_breakpoints['md'],
60 ],
61 'range' => [
62 'px' => [
63 'min' => 300,
64 'max' => 1500,
65 'step' => 10,
66 ],
67 ],
68 'description' => __( 'Sets the default width of the content area (Default: 1140)', 'elementor' ),
69 'selectors' => [
70 '.elementor-section.elementor-section-boxed > .elementor-container' => 'max-width: {{SIZE}}{{UNIT}}',
71 ],
72 ]
73 );
74
75 $this->add_control(
76 'space_between_widgets',
77 [
78 'label' => __( 'Widgets Space', 'elementor' ) . ' (px)',
79 'type' => Controls_Manager::SLIDER,
80 'default' => [
81 'size' => 20,
82 ],
83 'range' => [
84 'px' => [
85 'min' => 0,
86 'max' => 40,
87 ],
88 ],
89 'placeholder' => '20',
90 'description' => __( 'Sets the default space between widgets (Default: 20)', 'elementor' ),
91 'selectors' => [
92 '.elementor-widget:not(:last-child)' => 'margin-bottom: {{SIZE}}{{UNIT}}',
93 ],
94 ]
95 );
96
97 $this->add_control(
98 'page_title_selector',
99 [
100 'label' => __( 'Page Title Selector', 'elementor' ),
101 'type' => Controls_Manager::TEXT,
102 'default' => 'h1.entry-title',
103 'placeholder' => 'h1.entry-title',
104 'description' => __( 'Elementor lets you hide the page title. This works for themes that have "h1.entry-title" selector. If your theme\'s selector is different, please enter it above.', 'elementor' ),
105 'label_block' => true,
106 'selectors' => [
107 // Hack to convert the value into a CSS selector.
108 '' => '}{{VALUE}}{display: var(--page-title-display)',
109 ],
110 ]
111 );
112
113 $this->add_control(
114 'stretched_section_container',
115 [
116 'label' => __( 'Stretched Section Fit To', 'elementor' ),
117 'type' => Controls_Manager::TEXT,
118 'placeholder' => 'body',
119 'description' => __( 'Enter parent element selector to which stretched sections will fit to (e.g. #primary / .wrapper / main etc). Leave blank to fit to page width.', 'elementor' ),
120 'label_block' => true,
121 'frontend_available' => true,
122 ]
123 );
124
125 /**
126 * @var PageTemplatesModule $page_templates_module
127 */
128 $page_templates_module = Plugin::$instance->modules_manager->get_modules( 'page-templates' );
129 $page_templates = $page_templates_module->add_page_templates( [], null, null );
130
131 // Removes the Theme option from the templates because 'default' is already handled.
132 unset( $page_templates[ PageTemplatesModule::TEMPLATE_THEME ] );
133
134 $page_template_control_options = [
135 'label' => __( 'Default Page Layout', 'elementor' ),
136 'options' => [
137 // This is here because the "Theme" string is different than the default option's string.
138 'default' => __( 'Theme', 'elementor' ),
139 ] + $page_templates,
140 ];
141
142 $page_templates_module->add_template_controls( $this->parent, 'default_page_template', $page_template_control_options );
143
144 $this->end_controls_section();
145
146 $this->start_controls_section(
147 'section_breakpoints',
148 [
149 'label' => __( 'Breakpoints', 'elementor' ),
150 'tab' => $this->get_id(),
151 ]
152 );
153
154 $this->add_control(
155 'breakpoint_md_heading',
156 [
157 'label' => __( 'Mobile', 'elementor' ),
158 'type' => Controls_Manager::HEADING,
159 ]
160 );
161
162 $this->add_control(
163 Responsive::BREAKPOINT_OPTION_PREFIX . 'md',
164 [
165 'label' => __( 'Breakpoint', 'elementor' ) . ' (px)',
166 'type' => Controls_Manager::NUMBER,
167 'min' => $default_breakpoints['sm'] + 1,
168 'max' => $default_breakpoints['lg'] - 1,
169 'default' => $default_breakpoints['md'],
170 'placeholder' => $default_breakpoints['md'],
171 /* translators: %d: Breakpoint value */
172 'desc' => sprintf( __( 'Sets the breakpoint between tablet and mobile devices. Below this breakpoint mobile layout will appear (Default: %dpx).', 'elementor' ), $default_breakpoints['md'] ),
173 ]
174 );
175
176 $this->add_control(
177 'breakpoint_lg_heading',
178 [
179 'label' => __( 'Tablet', 'elementor' ),
180 'type' => Controls_Manager::HEADING,
181 ]
182 );
183
184 $this->add_control(
185 Responsive::BREAKPOINT_OPTION_PREFIX . 'lg',
186 [
187 'label' => __( 'Breakpoint', 'elementor' ) . ' (px)',
188 'type' => Controls_Manager::NUMBER,
189 'min' => $default_breakpoints['md'] + 1,
190 'max' => $default_breakpoints['xl'] - 1,
191 'default' => $default_breakpoints['lg'],
192 'placeholder' => $default_breakpoints['lg'],
193 /* translators: %d: Breakpoint value */
194 'desc' => sprintf( __( 'Sets the breakpoint between desktop and tablet devices. Below this breakpoint tablet layout will appear (Default: %dpx).', 'elementor' ), $default_breakpoints['lg'] ),
195 ]
196 );
197
198 $this->end_controls_section();
199 }
200
201 public function on_save( $data ) {
202 if ( ! isset( $data['settings'] ) || Document::STATUS_PUBLISH !== $data['settings']['post_status'] ) {
203 return;
204 }
205
206 $should_compile_css = false;
207
208 foreach ( Responsive::get_editable_breakpoints() as $breakpoint_key => $breakpoint ) {
209 $setting_key = "viewport_{$breakpoint_key}";
210 if ( isset( $data['settings'][ $setting_key ] ) ) {
211 $should_compile_css = true;
212 }
213 }
214
215 if ( $should_compile_css ) {
216 Responsive::compile_stylesheet_templates();
217 }
218 }
219 }
220