PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / faq / faq.php
elementskit-lite / widgets / faq Last commit date
faq-handler.php 3 years ago faq.php 3 weeks ago
faq.php
370 lines
1 <?php
2
3 namespace Elementor;
4
5 use \Elementor\ElementsKit_Widget_FAQ_Handler as Handler;
6 use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager;
7
8 if ( ! defined( 'ABSPATH' ) ) exit;
9
10 class ElementsKit_Widget_FAQ extends Widget_Base {
11 use \ElementsKit_Lite\Widgets\Widget_Notice;
12
13 public $base;
14
15 public function get_name() {
16 return Handler::get_name();
17 }
18
19 public function get_title() {
20 return Handler::get_title();
21 }
22
23 public function get_icon() {
24 return Handler::get_icon();
25 }
26
27 public function get_categories() {
28 return Handler::get_categories();
29 }
30
31 public function get_keywords() {
32 return Handler::get_keywords();
33 }
34
35 public function get_help_url() {
36 return 'https://wpmet.com/doc/faq/';
37 }
38
39 public function get_style_depends() {
40 return ['ekit-faq'];
41 }
42
43 protected function is_dynamic_content(): bool {
44 return false;
45 }
46
47 public function has_widget_inner_wrapper(): bool {
48 return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
49 }
50
51 protected function register_controls() {
52 $this->start_controls_section(
53 'ekit_faq_section_tab', [
54 'label' =>esc_html__( 'FAQ', 'elementskit-lite' ),
55 ]
56 );
57
58
59 $repeater = new Repeater();
60
61 $repeater->add_control(
62 'ekit_faq_title',
63 [
64 'label' =>esc_html__( 'Title', 'elementskit-lite' ),
65 'type' => Controls_Manager::TEXT,
66 'dynamic' => [
67 'active' => true,
68 ],
69 'label_block' => true,
70 'placeholder' =>esc_html__( 'Title type here', 'elementskit-lite' ),
71 'default' =>esc_html__( 'How to Change my Photo from Admin Dashboard?', 'elementskit-lite' ),
72 ]
73 );
74 $repeater->add_control(
75 'ekit_faq_content',
76 [
77 'label' =>esc_html__( 'Content', 'elementskit-lite' ),
78 'type' => Controls_Manager::TEXTAREA,
79 'dynamic' => [
80 'active' => true,
81 ],
82 'label_block' => true,
83 'placeholder' =>esc_html__( 'Description type here', 'elementskit-lite' ),
84 'default' =>esc_html__( 'Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast', 'elementskit-lite' ),
85 ]
86 );
87
88 $this->add_control(
89 'ekit_faq_content_items',
90 [
91 'label' => esc_html__('Tab content', 'elementskit-lite'),
92 'type' => Controls_Manager::REPEATER,
93 'separator' => 'before',
94 'title_field' => '{{ ekit_faq_title }}',
95 'default' => [
96 [
97 'ekit_faq_title' => 'Wait. What is WordPress?',
98 'ekit_faq_content' => 'Far far away, behind the word Mountains far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmark',
99 ],
100 [
101 'ekit_faq_title' => 'How long do I get support?',
102 'ekit_faq_content' => 'Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line',
103 ],
104 [
105 'ekit_faq_title' => 'Do I need to renew my license?',
106 'ekit_faq_content' => 'Marks and devious Semikoli but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way.',
107 ],
108 ],
109 'fields' => $repeater->get_controls(),
110 ]
111 );
112
113 //faq schema
114 $this->add_control(
115 'ekit_faq_schema',
116 [
117 'label' => esc_html__( 'FAQ Schema', 'elementskit-lite' ),
118 'type' => Controls_Manager::SWITCHER,
119 'separator' => 'before',
120 ]
121 );
122 $this->end_controls_section();
123
124 //Title Style Section
125
126 $this->start_controls_section(
127 'ekit_faq_section_title_style', [
128 'label' =>esc_html__( 'Title', 'elementskit-lite' ),
129 'tab' => Controls_Manager::TAB_STYLE,
130 ]
131 );
132
133 $this->add_control(
134 'ekit_faq_title_color', [
135 'label' =>esc_html__( 'Title Color', 'elementskit-lite' ),
136 'type' => Controls_Manager::COLOR,
137 'selectors' => [
138 '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-title' => 'color: {{VALUE}};'
139 ],
140 ]
141 );
142
143
144 $this->add_group_control(
145 Group_Control_Typography::get_type(), [
146 'name' => 'ekit_faq_title_typography_group',
147 'selector' => '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-title',
148 ]
149 );
150
151 $this->add_group_control(
152 Group_Control_Background::get_type(),
153 [
154 'name' => 'ekit_faq_title_background_group',
155 'label' => esc_html__( 'Background', 'elementskit-lite' ),
156 'types' => [ 'classic', 'gradient' ],
157 'selector' => '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-header',
158 ]
159 );
160
161 $this->add_group_control(
162 Group_Control_Border::get_type(),
163 [
164 'name' => 'ekit_faq_title_border_group',
165 'label' => esc_html__( 'Border', 'elementskit-lite' ),
166 'selector' => '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-header',
167 ]
168 );
169
170 $this->add_control(
171 'ekit_faq_border_radious',
172 [
173 'label' => esc_html__( 'Title Border Radius', 'elementskit-lite' ),
174 'type' => Controls_Manager::DIMENSIONS,
175 'size_units' => [ 'px', '%', 'em' ],
176 'selectors' => [
177 '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-header' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
178 ],
179 ]
180 );
181
182 $this->add_control(
183 'ekit_faq_title_padding',
184 [
185 'label' => esc_html__( 'Title Padding', 'elementskit-lite' ),
186 'type' => Controls_Manager::DIMENSIONS,
187 'size_units' => [ 'px', '%', 'em' ],
188 'default' => [
189 'top' => '21',
190 'right' => '40',
191 'bottom' => '21',
192 'left' => '40',
193 'unit' => 'px',
194 ],
195 'selectors' => [
196 '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-header' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
197 ],
198 ]
199 );
200
201 $this->add_control(
202 'ekit_faq_title_margin',
203 [
204 'label' => esc_html__( 'Title Margin', 'elementskit-lite' ),
205 'type' => Controls_Manager::DIMENSIONS,
206 'size_units' => [ 'px', '%', 'em' ],
207 'selectors' => [
208 '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-header' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
209 ],
210 ]
211 );
212
213
214 $this->end_controls_section();
215
216 //Content Style Section
217 $this->start_controls_section(
218 'ekit_faq_section_content_style', [
219 'label' =>esc_html__( 'Content', 'elementskit-lite' ),
220 'tab' => Controls_Manager::TAB_STYLE,
221 ]
222 );
223
224 $this->add_control(
225 'ekit_faq_content_color', [
226 'label' =>esc_html__( 'Color', 'elementskit-lite' ),
227 'type' => Controls_Manager::COLOR,
228 'selectors' => [
229 '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-body' => 'color: {{VALUE}};'
230 ],
231 ]
232 );
233
234
235 $this->add_group_control(
236 Group_Control_Typography::get_type(), [
237 'name' => 'ekit_faq_content_typography_group',
238 'selector' => '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-body',
239 ]
240 );
241
242 $this->add_group_control(
243 Group_Control_Background::get_type(),
244 [
245 'name' => 'ekit_faq_content_background_group',
246 'label' => esc_html__( 'Content Background', 'elementskit-lite' ),
247 'types' => [ 'classic', 'gradient' ],
248 'selector' => '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-body',
249 ]
250 );
251
252 $this->add_group_control(
253 Group_Control_Border::get_type(),
254 [
255 'name' => 'ekit_faq_content_border_group',
256 'label' => esc_html__( 'Content Border', 'elementskit-lite' ),
257 'selector' => '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-body',
258 ]
259 );
260
261 $this->add_control(
262 'ekit_faq_content_border_radious',
263 [
264 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ),
265 'type' => Controls_Manager::DIMENSIONS,
266 'size_units' => [ 'px', '%', 'em' ],
267 'selectors' => [
268 '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-body' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
269 ],
270 ]
271 );
272
273 $this->add_control(
274 'ekit_faq_content_padding',
275 [
276 'label' => esc_html__( 'Content Padding', 'elementskit-lite' ),
277 'type' => Controls_Manager::DIMENSIONS,
278 'size_units' => [ 'px', '%', 'em' ],
279 'default' => [
280 'top' => '30',
281 'right' => '40',
282 'bottom' => '30',
283 'left' => '40',
284 'unit' => 'px',
285 ],
286 'selectors' => [
287 '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-body' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
288 ],
289 ]
290 );
291
292 $this->add_control(
293 'ekit_faq_content_margin',
294 [
295 'label' => esc_html__( 'Content Margin', 'elementskit-lite' ),
296 'type' => Controls_Manager::DIMENSIONS,
297 'size_units' => [ 'px', '%', 'em' ],
298 'selectors' => [
299 '{{WRAPPER}} .elementskit-single-faq .elementskit-faq-body' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
300 ],
301 ]
302 );
303
304 $this->add_control(
305 'ekit_faq_container_margin',
306 [
307 'label' => esc_html__( 'Container Margin', 'elementskit-lite' ),
308 'type' => Controls_Manager::DIMENSIONS,
309 'size_units' => [ 'px', '%', 'em' ],
310 'selectors' => [
311 '{{WRAPPER}} .elementskit-single-faq:not(:last-child)' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
312 ],
313 ]
314 );
315 $this->end_controls_section();
316
317 $this->insert_pro_message();
318 }
319
320 protected function render( ) {
321 echo '<div class="ekit-wid-con" >';
322 $this->render_raw();
323 echo '</div>';
324 }
325
326 protected function render_raw( ) {
327 $settings = $this->get_settings_for_display();
328 extract($settings);
329 ?>
330
331 <?php if($ekit_faq_content_items > 0) : foreach($ekit_faq_content_items as $ekit_faq_content_item) : ?>
332 <div class="elementskit-single-faq elementor-repeater-item-<?php echo esc_attr( $ekit_faq_content_item[ '_id' ] ); ?>">
333 <div class="elementskit-faq-header">
334 <h2 class="elementskit-faq-title"><?php echo esc_html($ekit_faq_content_item['ekit_faq_title']); ?></h2>
335 </div>
336 <div class="elementskit-faq-body">
337 <?php if(!empty($ekit_faq_content_item['ekit_faq_content'])) {
338 echo wp_kses($ekit_faq_content_item['ekit_faq_content'], \ElementsKit_Lite\Utils::get_kses_array());
339 } ?>
340 </div>
341 </div>
342 <?php endforeach; endif; ?>
343 <?php
344 if ( isset( $settings['ekit_faq_schema'] ) && 'yes' === $settings['ekit_faq_schema'] ) {
345 $json = [
346 '@context' => 'https://schema.org',
347 '@type' => 'FAQPage',
348 'mainEntity' => [],
349 ];
350
351 foreach ( $settings['ekit_faq_content_items'] as $index => $item ) {
352 $faq_schema_text = !empty( $item['ekit_faq_content'] ) ? $item['ekit_faq_content'] : '';
353 $json['mainEntity'][] = [
354 '@type' => 'Question',
355 'name' => esc_html($item['ekit_faq_title']),
356 'acceptedAnswer' => [
357 '@type' => 'Answer',
358 'text' => \ElementsKit_Lite\Utils::kses( $faq_schema_text ),
359 ],
360 ];
361 }
362 ?>
363 <script type="application/ld+json"><?php echo wp_json_encode( $json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); ?></script>
364 <?php
365 }
366 ?>
367
368 <?php
369 }
370 }