PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.4.6
Easy Elements for Elementor – Addons & Website Templates v1.4.6
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / widgets / post-tag / post-tag.php

post-tag.php in Easy Elements for Elementor – Addons & Website Templates 1.4.6, at widgets/post-tag/post-tag.php

361 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Widgets;
3 use Elementor\Widget_Base;
4 use Elementor\Controls_Manager;
5 use Elementor\Group_Control_Typography;
6 use Elementor\Group_Control_Border;
7 use Elementor\Group_Control_Box_Shadow;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 class Easyel_Free_Post_Tags_Widget extends \Elementor\Widget_Base {
14
15 public function get_name() {
16 return 'eel-post-tags';
17 }
18
19 public function get_title() {
20 return __( 'Current Post Tags', 'easy-elements' );
21 }
22
23 public function get_icon() {
24 return 'easyicon easyelIcon-post-tag';
25 }
26
27 public function get_categories() {
28 return [ 'easyelements_category' ];
29 }
30
31 public function get_keywords() {
32 return [ 'tags', 'post tags', 'meta', 'taxonomy', 'blog', 'text' ];
33 }
34
35 public function get_style_depends() {
36 return [
37 'eel-post-tags',
38 ];
39 }
40
41
42 protected function register_controls() {
43
44 $this->start_controls_section(
45 'tags_content',
46 [
47 'label' => __( 'Tags', 'easy-elements' ),
48 'tab' => Controls_Manager::TAB_CONTENT,
49 ]
50 );
51
52 $this->add_control(
53 'show_label',
54 [
55 'label' => __( 'Show Label', 'easy-elements' ),
56 'type' => Controls_Manager::SWITCHER,
57 'label_on' => __( 'Yes', 'easy-elements' ),
58 'label_off' => __( 'No', 'easy-elements' ),
59 'default' => 'yes',
60 ]
61 );
62
63 $this->add_control(
64 'label_text',
65 [
66 'label' => __( 'Label Text', 'easy-elements' ),
67 'type' => Controls_Manager::TEXT,
68 'default' => __( 'Tags:', 'easy-elements' ),
69 'condition' => [
70 'show_label' => 'yes',
71 ],
72 ]
73 );
74
75 $this->add_control( 'separator', [
76 'label' => __( 'Separator', 'easy-elements' ),
77 'type' => Controls_Manager::TEXT,
78 'default' => '',
79 'description' => __( 'e.g. , or | or leave empty', 'easy-elements' ),
80 ]);
81
82 $this->end_controls_section();
83
84 // ===================== STYLE: WRAPPER =====================
85 $this->start_controls_section( 'wrapper_style', [
86 'label' => __( 'Wrapper', 'easy-elements' ),
87 'tab' => Controls_Manager::TAB_STYLE,
88 ]);
89
90 $this->add_responsive_control( 'wrapper_alignment', [
91 'label' => __( 'Alignment', 'easy-elements' ),
92 'type' => Controls_Manager::CHOOSE,
93 'options' => [
94 'flex-start' => [ 'title' => __( 'Left', 'easy-elements' ), 'icon' => 'eicon-h-align-left' ],
95 'center' => [ 'title' => __( 'Center', 'easy-elements' ), 'icon' => 'eicon-h-align-center' ],
96 'flex-end' => [ 'title' => __( 'Right', 'easy-elements' ), 'icon' => 'eicon-h-align-right' ],
97 ],
98 'selectors' => [
99 '{{WRAPPER}} .eel-post-tags-widget' => 'justify-content: {{VALUE}};',
100 ],
101 ]);
102
103 $this->add_responsive_control( 'wrapper_gap', [
104 'label' => __( 'Gap', 'easy-elements' ),
105 'type' => Controls_Manager::SLIDER,
106 'range' => [ 'px' => [ 'min' => 0, 'max' => 30 ] ],
107 'selectors' => [
108 '{{WRAPPER}} .eel-post-tags-widget' => 'gap: {{SIZE}}{{UNIT}};',
109 ],
110 ]);
111
112 $this->end_controls_section();
113
114 // ===================== STYLE: TITLE LABEL =====================
115 $this->start_controls_section(
116 'title_style',
117 [
118 'label' => __( 'Title Label', 'easy-elements' ),
119 'tab' => Controls_Manager::TAB_STYLE,
120 ]
121 );
122
123 $this->add_control(
124 'title_color',
125 [
126 'label' => __( 'Color', 'easy-elements' ),
127 'type' => Controls_Manager::COLOR,
128 'selectors' => [
129 '{{WRAPPER}} .eel-post-tags-widget .eel-tags-label' => 'color: {{VALUE}};',
130 ],
131 ]
132 );
133
134 $this->add_responsive_control(
135 'title_margin',
136 [
137 'label' => __( 'Margin', 'easy-elements' ),
138 'type' => Controls_Manager::DIMENSIONS,
139 'size_units' => [ 'px', '%', 'em' ],
140 'selectors' => [
141 '{{WRAPPER}} .eel-post-tags-widget .eel-tags-label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
142 ],
143 ]
144 );
145
146 $this->add_group_control(
147 Group_Control_Typography::get_type(),
148 [
149 'name' => 'title_typography',
150 'selector' => '{{WRAPPER}} .eel-post-tags-widget .eel-tags-label',
151 ]
152 );
153
154 $this->end_controls_section();
155
156 $this->start_controls_section(
157 'tags_style',
158 [
159 'label' => __( 'Tag', 'easy-elements' ),
160 'tab' => Controls_Manager::TAB_STYLE,
161 ]
162 );
163
164 $this->add_group_control(
165 Group_Control_Typography::get_type(),
166 [
167 'name' => 'tags_typography',
168 'selector' => '{{WRAPPER}} .eel-post-tags-widget a',
169 ]
170 );
171
172 $this->start_controls_tabs( 'tabs_tag_style' );
173
174 // Normal Tab
175 $this->start_controls_tab(
176 'tab_tag_normal',
177 [
178 'label' => __( 'Normal', 'easy-elements' ),
179 ]
180 );
181
182 $this->add_control(
183 'tags_color',
184 [
185 'label' => __( 'Text Color', 'easy-elements' ),
186 'type' => Controls_Manager::COLOR,
187 'selectors' => [
188 '{{WRAPPER}} .eel-post-tags-widget a' => 'color: {{VALUE}};',
189 ],
190 ]
191 );
192
193 $this->add_group_control(
194 \Elementor\Group_Control_Background::get_type(),
195 [
196 'name' => 'tags__bg_color',
197 'label' => __('Background', 'easy-elements'),
198 'types' => ['classic', 'gradient'],
199 'selector' => '{{WRAPPER}} .eel-post-tags-widget a',
200 ]
201 );
202
203 $this->add_group_control( Group_Control_Border::get_type(), [
204 'name' => 'tags_border',
205 'selector' => '{{WRAPPER}} .eel-post-tags-widget a',
206 ]);
207
208 $this->add_group_control( Group_Control_Box_Shadow::get_type(), [
209 'name' => 'tags_box_shadow',
210 'selector' => '{{WRAPPER}} .eel-post-tags-widget a',
211 ]);
212
213 $this->end_controls_tab();
214
215 // Hover Tab
216 $this->start_controls_tab(
217 'tab_tag_hover',
218 [
219 'label' => __( 'Hover', 'easy-elements' ),
220 ]
221 );
222
223 $this->add_control(
224 'tags_hover_color',
225 [
226 'label' => __( 'Text Color', 'easy-elements' ),
227 'type' => Controls_Manager::COLOR,
228 'selectors' => [
229 '{{WRAPPER}} .eel-post-tags-widget a:hover' => 'color: {{VALUE}};',
230 ],
231 ]
232 );
233
234 $this->add_group_control(
235 \Elementor\Group_Control_Background::get_type(),
236 [
237 'name' => 'tags_hover_bg_color',
238 'label' => __('Background', 'easy-elements'),
239 'types' => ['classic', 'gradient'],
240 'selector' => '{{WRAPPER}} .eel-post-tags-widget a:hover',
241 ]
242 );
243
244 $this->add_group_control( Group_Control_Border::get_type(), [
245 'name' => 'tags_hover_border',
246 'selector' => '{{WRAPPER}} .eel-post-tags-widget a:hover',
247 ]);
248
249 $this->add_group_control( Group_Control_Box_Shadow::get_type(), [
250 'name' => 'tags_hover_box_shadow',
251 'selector' => '{{WRAPPER}} .eel-post-tags-widget a:hover',
252 ]);
253
254 $this->end_controls_tab();
255
256 $this->end_controls_tabs();
257
258 $this->add_responsive_control( 'tags_border_radius', [
259 'label' => __( 'Border Radius', 'easy-elements' ),
260 'type' => Controls_Manager::DIMENSIONS,
261 'size_units' => [ 'px', '%' ],
262 'separator' => 'before',
263 'selectors' => [
264 '{{WRAPPER}} .eel-post-tags-widget a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
265 ],
266 ]);
267
268 $this->add_responsive_control(
269 'tags_margin',
270 [
271 'label' => __( 'Margin', 'easy-elements' ),
272 'type' => Controls_Manager::DIMENSIONS,
273 'size_units' => [ 'px', '%', 'em' ],
274 'selectors' => [
275 '{{WRAPPER}} .eel-post-tags-widget a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
276 ],
277 ]
278 );
279
280 $this->add_responsive_control(
281 'tags_padding',
282 [
283 'label' => __( 'Padding', 'easy-elements' ),
284 'type' => Controls_Manager::DIMENSIONS,
285 'size_units' => [ 'px', '%', 'em' ],
286 'selectors' => [
287 '{{WRAPPER}} .eel-post-tags-widget a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
288 ],
289 ]
290 );
291
292 $this->end_controls_section();
293
294 }
295
296 protected function render() {
297 // Password protected post check
298 if ( post_password_required() ) {
299 return;
300 }
301
302 $settings = $this->get_settings_for_display();
303
304 $post_id = function_exists('easyel_get_prepared_post_id')
305 ? easyel_get_prepared_post_id()
306 : get_the_ID();
307
308 $post_obj = get_post( $post_id );
309 if ( ! $post_obj instanceof \WP_Post ) {
310 return;
311 }
312
313 // Setup global post for template functions
314 global $post;
315 $original_post = $post;
316 $post = $post_obj;
317 setup_postdata( $post );
318
319 $tags = get_the_tags();
320 if ( ! $tags || is_wp_error( $tags ) ) {
321 wp_reset_postdata();
322 $post = $original_post;
323 return;
324 }
325
326 $separator = $settings['separator'] ?? '';
327
328 echo '<div class="eel-post-tags-widget">';
329
330 if ( 'yes' === ( $settings['show_label'] ?? 'no' ) && ! empty( $settings['label_text'] ) ) {
331 echo '<span class="eel-tags-label">' . esc_html( $settings['label_text'] ) . '</span>';
332 }
333
334 $tag_links = [];
335 foreach ( $tags as $tag ) {
336 $tag_links[] = '<a href="' . esc_url( get_tag_link( $tag->term_id ) ) . '" rel="tag">' . esc_html( $tag->name ) . '</a>';
337 }
338
339 if ( $separator ) {
340 echo wp_kses(
341 implode(
342 '<span class="eel-tags-sep">' . esc_html( $separator ) . '</span>',
343 $tag_links
344 ),
345 easyel_allowed_html()
346 );
347 } else {
348 echo wp_kses(
349 implode( '', $tag_links ),
350 easyel_allowed_html()
351 );
352 }
353
354 echo '</div>';
355
356 // Reset global post
357 wp_reset_postdata();
358 $post = $original_post;
359 }
360
361 }