PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / general / header-toggle / config.php
shop-press / Elementor / widgets / general / header-toggle Last commit date
config.php 2 years ago
config.php
305 lines
1 <?php
2
3 namespace ShopPress\Elementor\Widgets;
4
5 use Elementor\Utils;
6 use Elementor\Plugin;
7 use Elementor\Widget_Base;
8 use Elementor\Controls_Manager;
9 use Elementor\Group_Control_Image_Size;
10 use ShopPress\Elementor\ShopPressWidgets;
11
12 defined( 'ABSPATH' ) || exit;
13
14 class HeaderToggle extends ShopPressWidgets {
15
16 public function get_name() {
17 return 'sp-header-toggle';
18 }
19
20 public function get_title() {
21 return esc_html__( 'Off-Canvas', 'shop-press' );
22 }
23
24 public function get_icon() {
25 return 'sp-widget sp-eicon-header-toggle';
26 }
27
28 public function get_categories() {
29 return array( 'sp_general' );
30 }
31
32 public function get_script_depends() {
33 return array( 'sp-header-toggle' );
34 }
35
36 public function get_style_depends() {
37 return array( 'sp-header-toggle' );
38 }
39
40 protected function register_controls() {
41 // Content options Start
42 $this->start_controls_section(
43 'section_text_content',
44 array(
45 'label' => esc_html__( 'Content Toggle Settings', 'shop-press' ),
46 )
47 );
48 $this->add_control(
49 'placeholder',
50 array(
51 'label' => __( 'Placeholder', 'shop-press' ),
52 'type' => Controls_Manager::CHOOSE,
53 'default' => 'icon',
54 'toggle' => true,
55 'options' => array(
56 'image' => array(
57 'title' => __( 'Image', 'shop-press' ),
58 'icon' => 'eicon-image',
59 ),
60 'icon' => array(
61 'title' => __( 'Icon', 'shop-press' ),
62 'icon' => 'eicon-icon-box',
63 ),
64 'text' => array(
65 'title' => __( 'Text', 'shop-press' ),
66 'icon' => 'eicon-text',
67 ),
68 ),
69 )
70 );
71
72 $this->add_control(
73 'image',
74 array(
75 'label' => __( 'Choose Image', 'shop-press' ),
76 'type' => Controls_Manager::MEDIA,
77 'dynamic' => array(
78 'active' => true,
79 ),
80 'default' => array(
81 'url' => Utils::get_placeholder_image_src(),
82 ),
83 'condition' => array(
84 'placeholder' => array(
85 'image',
86 'svg',
87 ),
88 ),
89 )
90 );
91 $this->add_group_control(
92 Group_Control_Image_Size::get_type(),
93 array(
94 'name' => 'image', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `image_size` and `image_custom_dimension`.
95 'default' => 'large',
96 'separator' => 'none',
97 'condition' => array(
98 'placeholder' => array(
99 'image',
100 ),
101 ),
102 )
103 );
104
105 $this->add_control(
106 'icon',
107 array(
108 'label' => esc_html__( 'Icon', 'shop-press' ),
109 'type' => Controls_Manager::ICONS,
110 'default' => array(
111 'value' => 'fas fa-bars',
112 'library' => 'fa-solid',
113 ),
114 'condition' => array(
115 'placeholder' => array(
116 'icon',
117 ),
118 ),
119 )
120 );
121
122 $this->add_control(
123 'text',
124 array(
125 'label' => esc_html__( 'Text', 'shop-press' ),
126 'type' => Controls_Manager::TEXT,
127 'default' => __( 'Login', 'shop-press' ),
128 'condition' => array(
129 'placeholder' => array(
130 'text',
131 'icon',
132 ),
133 ),
134 'dynamic' => array(
135 'active' => true,
136 ),
137 )
138 );
139
140 $this->add_control(
141 'close_icon',
142 array(
143 'label' => esc_html__( 'Close Icon', 'shop-press' ),
144 'type' => Controls_Manager::ICONS,
145 'default' => array(
146 'value' => 'fas fa-times',
147 'library' => 'fa-solid',
148 ),
149 )
150 );
151
152 $this->add_control(
153 'header_toggle_template',
154 array(
155 'label' => esc_html__( 'Choose template', 'shop-press' ),
156 'description' => esc_html__( 'Please head over to WP Dashboard > Templates > Saved Templates and add a template. You can then choose the template you like here.', 'shop-press' ),
157 'type' => Controls_Manager::SELECT,
158 'default' => '0',
159 'options' => $this->templates(),
160 )
161 );
162
163 $this->add_control(
164 'open_in',
165 array(
166 'label' => esc_html__( 'Opening type', 'shop-press' ),
167 'description' => esc_html__( 'There is 3 type to show header toggle. Dropdown, Drawer, Popup', 'shop-press' ),
168 'type' => Controls_Manager::SELECT,
169 'default' => 'dropdown',
170 'options' => array(
171 'dropdown' => 'Dropdown',
172 'drawer' => 'Drawer',
173 'popup' => 'Popup',
174 ),
175 )
176 );
177 $this->end_controls_section();
178
179 $this->register_group_styler(
180 'wrapper',
181 __( 'Wrapper', 'shop-press' ),
182 array(
183 'wrapper' => array(
184 'label' => __( 'Wrapper', 'shop-press' ),
185 'selector' => '.sp-header-toggle',
186 'wrapper' => '{{WRAPPER}}',
187 ),
188 ),
189 );
190
191 $this->register_group_styler(
192 'section_styling_placeholder',
193 __( 'Placeholder', 'shop-press' ),
194 array(
195 'placeholder_wrapper' => array(
196 'label' => __( 'Wrapper', 'shop-press' ),
197 'selector' => '.sp-header-toggle-click',
198 'wrapper' => '{{WRAPPER}}',
199 ),
200 'placeholder_image' => array(
201 'label' => __( 'Image', 'shop-press' ),
202 'selector' => '.sp-header-toggle-click img',
203 'wrapper' => '{{WRAPPER}}',
204 ),
205 'placeholder_icon' => array(
206 'label' => __( 'Icon', 'shop-press' ),
207 'selector' => '.sp-header-toggle-click i',
208 'wrapper' => '{{WRAPPER}}',
209 ),
210 'close_icon_wrapper' => array(
211 'label' => __( 'Close Icon Wrapper', 'shop-press' ),
212 'selector' => '.shop-press-heaader-toggle-close',
213 'wrapper' => '{{WRAPPER}}',
214 ),
215 'close_icon' => array(
216 'label' => __( 'Close Icon', 'shop-press' ),
217 'selector' => '.shop-press-heaader-toggle-close i',
218 'wrapper' => '{{WRAPPER}}',
219 ),
220 'placeholder_text' => array(
221 'label' => __( 'Text', 'shop-press' ),
222 'selector' => '.sp-header-toggle-click .header-toggle-text',
223 'wrapper' => '{{WRAPPER}}',
224 ),
225 ),
226 );
227
228 $this->register_group_styler(
229 'section_styling_placeholder_active',
230 __( 'Active Placeholder', 'shop-press' ),
231 array(
232 'placeholder_active_wrapper' => array(
233 'label' => __( 'Wrapper', 'shop-press' ),
234 'selector' => '.sp-header-toggle-click.active',
235 'wrapper' => '{{WRAPPER}}',
236 ),
237 'placeholder_active_image' => array(
238 'label' => __( 'Image', 'shop-press' ),
239 'selector' => '.sp-header-toggle-click.active img',
240 'wrapper' => '{{WRAPPER}}',
241 ),
242 'placeholder_active_icon' => array(
243 'label' => __( 'Icon', 'shop-press' ),
244 'selector' => '.sp-header-toggle-click.active i',
245 'wrapper' => '{{WRAPPER}}',
246 ),
247 'placeholder_active_text' => array(
248 'label' => __( 'Text', 'shop-press' ),
249 'selector' => '.sp-header-toggle-click.active .header-toggle-text',
250 'wrapper' => '{{WRAPPER}}',
251 ),
252 ),
253 );
254
255 $this->register_group_styler(
256 'section_styling_toggle',
257 __( 'Toggle Content', 'shop-press' ),
258 array(
259 'toggle_wrapper' => array(
260 'label' => __( 'Wrapper', 'shop-press' ),
261 'selector' => '.sp-header-toggle-content-wrap',
262 'wrapper' => '{{WRAPPER}}',
263 ),
264 ),
265 );
266
267 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
268 }
269 public function templates() {
270 $get_templates = Plugin::instance()->templates_manager->get_source( 'local' )->get_items();
271 $templates = array(
272 '0' => __( 'Elementor template is not defined yet.', 'shop-press' ),
273 );
274 if ( ! empty( $get_templates ) ) {
275 $templates = array(
276 '0' => __( 'Select elementor template', 'shop-press' ),
277 );
278 foreach ( $get_templates as $template ) {
279 $templates[ $template['title'] ] = $template['title'] . ' (' . $template['type'] . ')';
280 }
281 }
282 return $templates;
283 }
284
285 protected function render() {
286 $settings = $this->get_settings_for_display();
287
288 do_action( 'shoppress/widget/before_render', $settings );
289
290 $args = array(
291 'open_in' => $settings['open_in'],
292 'placeholder' => $settings['placeholder'],
293 'image' => $settings['image'],
294 'image_size' => $settings['image_size'],
295 'image_custom_dimension' => $settings['image_custom_dimension'],
296 'text' => $settings['text'],
297 'icon' => $settings['icon'],
298 'header_toggle_template' => $settings['header_toggle_template'],
299 'close_icon' => $settings['close_icon'],
300 );
301
302 sp_load_builder_template( 'general/off-canvas', $args );
303 }
304 }
305