AI Verified

Name

Elementor Container Global Gutter Settings

About

Adds custom global gutters to elementor containers.

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

Edit the "--con-gutters" variable value and edit/add/remove media queries as desired for each responsive size. The new "Gutters" option can be found on the container main layout tab underneath the Min Height settings. Class ".con-gutters" can be added to any element for left and right padding. Variable "var(--con-gutters)" can be used in any custom unit field.

Codevault

Robert-Wattner's-Snippets

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.4

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

Snippet Source:

paypal.me/robertwattner

History

Last modified:

12/03/2024

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Elementor Container Global Gutter Settings

 
                    
1add_action( 'wp_head', function () { ?>
2<style>
3@media only screen and (min-width: 1025px) {
4 :root, .e-con {
5 /* WIDESCREEN GUTTER SIZE*/
6 --con-gutters: 60px;
7 }
8}
9 
10@media only screen and (max-width: 1024px) and (min-width: 960px) {
11 :root, .e-con {
12 /* DESKTOP GUTTER SIZE*/
13 --con-gutters: 60px;
14 }
15}
16 
17@media only screen and (max-width: 959px) and (min-width: 768px) {
18 :root, .e-con {
19 /* LAPTOP GUTTER SIZE*/
20 --con-gutters: 60px;
21 }
22}
23 
24@media only screen and (max-width: 767px) and (min-width: 601px) {
25 :root, .e-con {
26 /* TABLET EXTRA GUTTER SIZE*/
27 --con-gutters: 40px;
28 }
29}
30 
31@media only screen and (max-width: 600px) and (min-width: 481px) {
32 :root, .e-con {
33 /* TABLET GUTTER SIZE*/
34 --con-gutters: 40px;
35 }
36}
37 
38@media only screen and (max-width: 480px) and (min-width: 361px) {
39 :root, .e-con {
40 /* MOBILE EXTRA GUTTER SIZE*/
41 --con-gutters: 20px;
42 }
43}
44 
45@media only screen and (max-width: 360px) {
46 :root, .e-con {
47 /* MOBILE GUTTER SIZE*/
48 --con-gutters: 20px;
49 }
50}
51 
52.con-gutters {
53 padding-left: var(--con-gutters) !important;
54 padding-right: var(--con-gutters) !important;
55}
56 </style>
57<?php } );
58 
59// INJECT CONTROLS
60add_action('elementor/element/before_section_end', function ($element, $section_id, $args) {
61 if ('container' === $element->get_name() && 'section_layout' === $section_id) {
62 $element->start_injection([
63 'at' => 'after',
64 'of' => 'min_height',
65 ]);
66 
67 $element->add_control(
68 'custom_gutters',
69 [
70 'label' => esc_html__('Gutters', 'rw-essentials'),
71 'type' => \Elementor\Controls_Manager::SWITCHER,
72 'label_on' => esc_html__('On', 'rw-essentials'),
73 'label_off' => esc_html__('Off', 'rw-essentials'),
74 'return_value' => 'yes',
75 'default' => 'no',
76 'description' => __('Add globally controlled inline(horizontal) padding.', 'rw-essentials'),
77 'separator' => 'before',
78 ]
79 );
80 
81 $element->add_responsive_control(
82 'gutter_sides',
83 [
84 'label' => __('Gutter Sides', 'rw-essentials'),
85 'type' => \Elementor\Controls_Manager::CHOOSE,
86 'options' => [
87 'padding-inline-start: var(--padding-inline-start); padding-inline-end: var(--padding-inline-end);' => [
88 'title' => esc_html__('None', 'rw-essentials'),
89 'icon' => 'eicon-ban',
90 ],
91 '--padding-inline-start: var(--con-gutters) !important; --padding-inline-end: var(--con-gutters) !important;' => [
92 'title' => esc_html__('Both', 'rw-essentials'),
93 'icon' => 'eicon-grow',
94 ],
95 '--padding-inline-start: var(--con-gutters) !important; padding-inline-end: var(--padding-inline-end);' => [
96 'title' => esc_html__('Left', 'rw-essentials'),
97 'icon' => 'eicon-order-start',
98 ],
99 'padding-inline-start: var(--padding-inline-start); --padding-inline-end: var(--con-gutters) !important;' => [
100 'title' => esc_html__('Right', 'rw-essentials'),
101 'icon' => 'eicon-order-end',
102 ],
103 ],
104 'default' => '--padding-inline-start: var(--con-gutters) !important; --padding-inline-end: var(--con-gutters) !important;',
105 'toggle' => true,
106 'selectors' => [
107 '{{WRAPPER}}.e-con.e-grid, {{WRAPPER}} .e-grid-outline, {{WRAPPER}}.e-con.e-flex' => '{{VALUE}}',
108 ],
109 'description' => __('Gutters override padding settings on active sides.', 'rw-essentials'),
110 'condition' => [
111 'custom_gutters' => 'yes',
112 ],
113 ]
114 );
115 
116 $element->add_control(
117 'custom_gutter_size_toggle',
118 [
119 'label' => esc_html__('Custom Gutter Size', 'rw-essentials'),
120 'type' => \Elementor\Controls_Manager::SWITCHER,
121 'label_on' => esc_html__('On', 'rw-essentials'),
122 'label_off' => esc_html__('Off', 'rw-essentials'),
123 'return_value' => 'yes',
124 'default' => 'no',
125 'description' => 'Override the global gutter for THIS CONTAINER ONLY.',
126 'condition' => [
127 'custom_gutters' => 'yes',
128 ],
129 ]
130 );
131 
132 $element->add_responsive_control(
133 'custom_gutter_size',
134 [
135 'label' => esc_html__('Size', 'rw-essentials'),
136 'type' => \Elementor\Controls_Manager::SLIDER,
137 'size_units' => ['px', '%', 'vw', 'em', 'rem', 'custom'],
138 'range' => [
139 'px' => [
140 'min' => 0,
141 'max' => 500,
142 'step' => 1,
143 ],
144 '%' => [
145 'min' => 0,
146 'max' => 100,
147 'step' => 1,
148 ],
149 'vw' => [
150 'min' => 0,
151 'max' => 100,
152 'step' => 1,
153 ],
154 'em' => [
155 'min' => 0,
156 'max' => 50,
157 'step' => 0.1,
158 ],
159 'rem' => [
160 'min' => 0,
161 'max' => 50,
162 'step' => 0.1,
163 ],
164 ],
165 'default' => [
166 'size' => '',
167 'unit' => 'px',
168 ],
169 'frontend_available' => true,
170 'label_block' => true,
171 'description' => '',
172 'selectors' => [
173 '{{WRAPPER}}.e-con' => '--con-gutters: {{SIZE}}{{UNIT}} !important;',
174 ],
175 'condition' => [
176 'custom_gutters' => 'yes',
177 'custom_gutter_size_toggle' => 'yes',
178 ],
179 ]
180 );
181 
182 $element->end_injection();
183 }
184}, 10, 3);

0

Related Snippets

Please see some snippets below related to this snippet..

Elementor

AI Verified

1

PHP to Elementor

Added: 1 year ago

Last Updated: 1 year ago

How to add PHP Code to Elementor.

Elementor

Unverified

0

Form-PayPal

Added: 1 month ago

Last Updated: 1 month ago

Elementor

AI Verified

0

Elementor author posts with UAE Posts widget

Added: 2 years ago

Last Updated: 1 year ago

Display posts of only the current author archive using Elementor and "Unlimited Addons for Elementor" Posts widget

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

Elementor

AI Verified

0

Elementor Anchor Link Scroll Offset(PHP)

Added: 6 months ago

Last Updated: 6 months ago

Offset anchor menu links from the top of the page.

Elementor

Unverified

0

Elementor Anchor Link Scroll Offset

Added: 6 months ago

Last Updated: 6 months ago

Offset anchor menu links from the top of the page.

Elementor

AI Verified

0

Elementor Container Global Gutter Settings

Added: 6 months ago

Last Updated: 6 months ago

Adds custom global gutters to elementor containers.