PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 7.3.1
WP Popular Posts v7.3.1
4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.4.0 6.4.1 6.4.2 7.0.0 7.0.1 7.1.0 7.2.0 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 7.4.0 trunk 2.3.7 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.5 4.0.6
wordpress-popular-posts / src / Compatibility / Elementor / widgets / widget-controls.php
wordpress-popular-posts / src / Compatibility / Elementor / widgets Last commit date
widget-controls.php 1 year ago widget.php 1 year ago
widget-controls.php
594 lines
1 <?php
2 /* General Controls */
3 $this->start_controls_section(
4 'general_section',
5 [
6 'label' => esc_html__('General', 'wordpress-popular-posts'),
7 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
8 ]
9 );
10
11 $this->add_control(
12 'header',
13 [
14 'type' => \Elementor\Controls_Manager::TEXT,
15 'label' => esc_html__('Title', 'wordpress-popular-posts'),
16 'label_block' => true,
17 'placeholder' => esc_html__('Enter your title', 'wordpress-popular-posts'),
18 'ai' => [
19 'active' => false,
20 ],
21 ]
22 );
23
24 $this->add_control(
25 'limit',
26 [
27 'type' => \Elementor\Controls_Manager::NUMBER,
28 'min' => 1,
29 'max' => 100,
30 'step' => 1,
31 'default' => 10,
32 'label' => esc_html__('Limit', 'wordpress-popular-posts'),
33 ]
34 );
35
36 $this->add_control(
37 'order_by',
38 [
39 'label' => esc_html__('Sort posts by', 'wordpress-popular-posts'),
40 'type' => \Elementor\Controls_Manager::SELECT,
41 'default' => 'views',
42 'options' => [
43 'views' => esc_html__('Total views', 'wordpress-popular-posts'),
44 'avg' => esc_html__('Avg. daily views', 'wordpress-popular-posts'),
45 'comments' => esc_html__('Comments', 'wordpress-popular-posts')
46 ]
47 ]
48 );
49
50 $this->add_control(
51 'range',
52 [
53 'label' => esc_html__('Time Range', 'wordpress-popular-posts'),
54 'type' => \Elementor\Controls_Manager::SELECT,
55 'default' => 'last24hours',
56 'options' => [
57 'last24hours' => esc_html__('Last 24 Hours', 'wordpress-popular-posts'),
58 'last7days' => esc_html__('Last 7 days', 'wordpress-popular-posts'),
59 'last30days' => esc_html__('Last 30 days', 'wordpress-popular-posts'),
60 'all' => esc_html__('All-time', 'wordpress-popular-posts'),
61 'custom' => esc_html__('Custom', 'wordpress-popular-posts')
62 ]
63 ]
64 );
65
66 $this->add_control(
67 'time_quantity',
68 [
69 'type' => \Elementor\Controls_Manager::NUMBER,
70 'min' => 1,
71 'max' => 100,
72 'step' => 1,
73 'default' => 24,
74 'label' => esc_html__('Time Quantity', 'wordpress-popular-posts'),
75 'condition' => [
76 'range' => 'custom'
77 ],
78 ]
79 );
80
81 $this->add_control(
82 'time_unit',
83 [
84 'label' => esc_html__('Time Unit', 'wordpress-popular-posts'),
85 'type' => \Elementor\Controls_Manager::SELECT,
86 'default' => 'hour',
87 'options' => [
88 'minute' => esc_html__('Minute(s)', 'wordpress-popular-posts'),
89 'hour' => esc_html__('Hour(s)', 'wordpress-popular-posts'),
90 'day' => esc_html__('Day(s)', 'wordpress-popular-posts')
91 ],
92 'condition' => [
93 'range' => 'custom'
94 ],
95 ]
96 );
97
98 $this->add_control(
99 'freshness',
100 [
101 'label' => esc_html__('Display only posts published within the selected Time Range', 'wordpress-popular-posts'),
102 'type' => \Elementor\Controls_Manager::SWITCHER,
103 'return_value' => '1',
104 'default' => '0',
105 ]
106 );
107
108 $this->end_controls_section();
109
110 /* Filters */
111 $taxonomies = get_taxonomies(['public' => true], 'objects');
112
113 $this->start_controls_section(
114 'filters_section',
115 [
116 'label' => esc_html__('Filters', 'wordpress-popular-posts'),
117 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
118 ]
119 );
120
121 $this->add_control(
122 'post_type',
123 [
124 'type' => \Elementor\Controls_Manager::TEXT,
125 'label' => esc_html__('Post Type(s)', 'wordpress-popular-posts'),
126 'label_block' => true,
127 'description' => esc_html__('Post types must be comma separated.', 'wordpress-popular-posts'),
128 'default' => 'post',
129 'ai' => [
130 'active' => false,
131 ],
132 ]
133 );
134
135 $this->add_control(
136 'exclude',
137 [
138 'type' => \Elementor\Controls_Manager::TEXT,
139 'label' => esc_html__('Post ID(s) to exclude', 'wordpress-popular-posts'),
140 'label_block' => true,
141 'description' => esc_html__('IDs must be comma separated.', 'wordpress-popular-posts'),
142 'ai' => [
143 'active' => false,
144 ],
145 ]
146 );
147
148 $this->add_control(
149 'author',
150 [
151 'type' => \Elementor\Controls_Manager::TEXT,
152 'label' => esc_html__('Author ID(s)', 'wordpress-popular-posts'),
153 'label_block' => true,
154 'description' => esc_html__('IDs must be comma separated.', 'wordpress-popular-posts'),
155 'ai' => [
156 'active' => false,
157 ],
158 ]
159 );
160
161 if ( $taxonomies ) {
162 foreach( $taxonomies as $taxonomy ) {
163 if ( 'post_format' == $taxonomy->name ) {
164 continue;
165 }
166
167 $label = $taxonomy->labels->singular_name . ' ('. $taxonomy->name .')';
168
169 $this->add_control(
170 'wpp_taxonomy_slug_' . $taxonomy->name,
171 [
172 'label' => esc_html($label),
173 'type' => \Elementor\Controls_Manager::SWITCHER,
174 'return_value' => $taxonomy->name,
175 'default' => 0,
176 ]
177 );
178
179 $this->add_control(
180 'wpp_taxonomy_' . $taxonomy->name . '_terms',
181 [
182 'type' => \Elementor\Controls_Manager::TEXT,
183 'label' => esc_html__('Term ID(s)', 'wordpress-popular-posts'),
184 'label_block' => true,
185 'description' => esc_html__('Term IDs must be comma separated, prefix a minus sign to exclude.', 'wordpress-popular-posts'),
186 'ai' => [
187 'active' => false,
188 ]
189 ]
190 );
191 }
192 }
193
194 $this->end_controls_section();
195
196 /* Posts settings */
197 $this->start_controls_section(
198 'posts_settings_section',
199 [
200 'label' => esc_html__('Posts settings', 'wordpress-popular-posts'),
201 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
202 'condition' => [
203 'theme' => ''
204 ],
205 ]
206 );
207
208 if ( function_exists('the_ratings_results') ) :
209 $this->add_control(
210 'rating',
211 [
212 'label' => esc_html__('Display post rating', 'wordpress-popular-posts'),
213 'type' => \Elementor\Controls_Manager::SWITCHER,
214 'return_value' => '1',
215 'default' => '0',
216 ]
217 );
218 endif;
219
220 $this->add_control(
221 'shorten_title',
222 [
223 'label' => esc_html__('Shorten title', 'wordpress-popular-posts'),
224 'type' => \Elementor\Controls_Manager::SWITCHER,
225 'return_value' => '1',
226 'default' => '0',
227 ]
228 );
229
230 $this->add_control(
231 'title_length',
232 [
233 'label' => esc_html__('Shorten title to', 'wordpress-popular-posts'),
234 'type' => \Elementor\Controls_Manager::NUMBER,
235 'min' => 1,
236 'max' => 999,
237 'step' => 1,
238 'default' => 25,
239 'condition' => [
240 'shorten_title' => '1'
241 ],
242 ]
243 );
244
245 $this->add_control(
246 'title_by_words',
247 [
248 'type' => \Elementor\Controls_Manager::SELECT,
249 'default' => '0',
250 'options' => [
251 '0' => esc_html__('characters', 'wordpress-popular-posts'),
252 '1' => esc_html__('words', 'wordpress-popular-posts')
253 ],
254 'condition' => [
255 'shorten_title' => '1'
256 ],
257 ]
258 );
259
260 $this->add_control(
261 'display_post_excerpt',
262 [
263 'label' => esc_html__('Display post excerpt', 'wordpress-popular-posts'),
264 'type' => \Elementor\Controls_Manager::SWITCHER,
265 'return_value' => '1',
266 'default' => '0',
267 ]
268 );
269
270 $this->add_control(
271 'excerpt_format',
272 [
273 'label' => esc_html__('Keep text format and links', 'wordpress-popular-posts'),
274 'type' => \Elementor\Controls_Manager::SWITCHER,
275 'return_value' => '1',
276 'default' => '0',
277 'condition' => [
278 'display_post_excerpt' => '1'
279 ],
280 ]
281 );
282
283 $this->add_control(
284 'excerpt_length',
285 [
286 'label' => esc_html__('Excerpt length', 'wordpress-popular-posts'),
287 'type' => \Elementor\Controls_Manager::NUMBER,
288 'min' => 1,
289 'step' => 1,
290 'default' => 55,
291 'condition' => [
292 'display_post_excerpt' => '1'
293 ],
294 ]
295 );
296
297 $this->add_control(
298 'excerpt_by_words',
299 [
300 'type' => \Elementor\Controls_Manager::SELECT,
301 'default' => '0',
302 'options' => [
303 '0' => esc_html__('characters', 'wordpress-popular-posts'),
304 '1' => esc_html__('words', 'wordpress-popular-posts')
305 ],
306 'condition' => [
307 'display_post_excerpt' => '1'
308 ],
309 ]
310 );
311
312 $this->add_control(
313 'display_post_thumbnail',
314 [
315 'label' => esc_html__('Display post thumbnail', 'wordpress-popular-posts'),
316 'type' => \Elementor\Controls_Manager::SWITCHER,
317 'return_value' => '1',
318 'default' => '0',
319 ]
320 );
321
322 $this->add_control(
323 'thumbnail_build',
324 [
325 'type' => \Elementor\Controls_Manager::SELECT,
326 'label_block' => true,
327 'default' => 'manual',
328 'options' => [
329 'manual' => esc_html__('Set size manually', 'wordpress-popular-posts'),
330 'predefined' => esc_html__('Use predefined size', 'wordpress-popular-posts')
331 ],
332 'condition' => [
333 'display_post_thumbnail' => '1'
334 ],
335 ]
336 );
337
338 $this->add_control(
339 'thumbnail_width',
340 [
341 'label' => esc_html__('Thumbnail width', 'wordpress-popular-posts'),
342 'type' => \Elementor\Controls_Manager::NUMBER,
343 'min' => 1,
344 'step' => 1,
345 'default' => 75,
346 'description' => esc_html__('Size in px units (pixels)', 'wordpress-popular-posts'),
347 'condition' => [
348 'display_post_thumbnail' => '1',
349 'thumbnail_build' => 'manual'
350 ],
351 ]
352 );
353
354 $this->add_control(
355 'thumbnail_height',
356 [
357 'label' => esc_html__('Thumbnail height', 'wordpress-popular-posts'),
358 'type' => \Elementor\Controls_Manager::NUMBER,
359 'min' => 1,
360 'step' => 1,
361 'default' => 75,
362 'description' => esc_html__('Size in px units (pixels)', 'wordpress-popular-posts'),
363 'condition' => [
364 'display_post_thumbnail' => '1',
365 'thumbnail_build' => 'manual'
366 ],
367 ]
368 );
369
370 $size_options = [];
371
372 if ( $this->available_sizes ) {
373 foreach($this->available_sizes as $slug => $data) {
374 $slug = sanitize_title($slug);
375 $size_options[$slug] = $slug;
376 }
377 }
378
379 if ( $size_options ) {
380 $this->add_control(
381 'thumbnail_size',
382 [
383 'type' => \Elementor\Controls_Manager::SELECT,
384 'default' => 'thumbnail',
385 'options' => $size_options,
386 'condition' => [
387 'display_post_thumbnail' => '1',
388 'thumbnail_build' => 'predefined'
389 ],
390 ]
391 );
392 }
393
394 $this->end_controls_section();
395
396 /* Stats Tag settings */
397 $this->start_controls_section(
398 'stats_settings_section',
399 [
400 'label' => esc_html__('Stats Tag settings', 'wordpress-popular-posts'),
401 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
402 'condition' => [
403 'theme' => ''
404 ],
405 ]
406 );
407
408 $this->add_control(
409 'stats_comments',
410 [
411 'label' => esc_html__('Display comments count', 'wordpress-popular-posts'),
412 'type' => \Elementor\Controls_Manager::SWITCHER,
413 'return_value' => 1,
414 'default' => 0,
415 ]
416 );
417
418 $this->add_control(
419 'stats_views',
420 [
421 'label' => esc_html__('Display views', 'wordpress-popular-posts'),
422 'type' => \Elementor\Controls_Manager::SWITCHER,
423 'return_value' => '1',
424 'default' => '1',
425 ]
426 );
427
428 $this->add_control(
429 'stats_author',
430 [
431 'label' => esc_html__('Display author', 'wordpress-popular-posts'),
432 'type' => \Elementor\Controls_Manager::SWITCHER,
433 'return_value' => '1',
434 'default' => '0',
435 ]
436 );
437
438 $this->add_control(
439 'stats_date',
440 [
441 'label' => esc_html__('Display date', 'wordpress-popular-posts'),
442 'type' => \Elementor\Controls_Manager::SWITCHER,
443 'return_value' => '1',
444 'default' => '0',
445 ]
446 );
447
448 $this->add_control(
449 'stats_date_format',
450 [
451 'label' => esc_html__('Date Format', 'wordpress-popular-posts'),
452 'type' => \Elementor\Controls_Manager::SELECT,
453 'default' => 'F j, Y',
454 'options' => [
455 'relative' => esc_html__('Relative', 'wordpress-popular-posts'),
456 'F j, Y' => esc_html__('Month Day, Year', 'wordpress-popular-posts'),
457 'Y/m/d' => esc_html__('yyyy/mm/dd', 'wordpress-popular-posts'),
458 'm/d/Y' => esc_html__('mm/dd/yyyy', 'wordpress-popular-posts'),
459 'd/m/Y' => esc_html__('dd/mm/yyyy', 'wordpress-popular-posts'),
460 'wp_date_format' => esc_html__('WordPress Date Format', 'wordpress-popular-posts')
461 ],
462 'condition' => [
463 'stats_date' => '1'
464 ],
465 ]
466 );
467
468 $this->end_controls_section();
469
470 /* HTML */
471 $this->start_controls_section(
472 'html_section',
473 [
474 'label' => esc_html__('HTML Markup settings', 'wordpress-popular-posts'),
475 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
476 ]
477 );
478
479 $registered_themes = $this->themer->get_themes();
480 ksort($registered_themes);
481
482 $theme_options = [
483 '' => 'Default'
484 ];
485
486 foreach( $registered_themes as $slug => $data ) {
487 $theme_options[$slug] = esc_html($data['json']['name']);
488 }
489
490 $this->add_control(
491 'theme',
492 [
493 'label' => esc_html__('Theme', 'wordpress-popular-posts'),
494 'type' => \Elementor\Controls_Manager::SELECT,
495 'default' => '',
496 'options' => $theme_options
497 ]
498 );
499
500 $this->add_control(
501 'theme_customization_note',
502 [
503 'type' => \Elementor\Controls_Manager::ALERT,
504 'alert_type' => 'warning',
505 'content' => '<a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/6.-Styling-the-list#customizing-an-existing-theme">' . esc_html__('How do I customize this theme?', 'wordpress-popular-posts') . '</a>',
506 'condition' => [
507 'theme!' => ''
508 ],
509 ]
510 );
511
512 $this->add_control(
513 'header_start',
514 [
515 'label' => esc_html__('Before title', 'wordpress-popular-posts'),
516 'type' => \Elementor\Controls_Manager::TEXTAREA,
517 'rows' => 5,
518 'default' => '<h2>',
519 'ai' => [
520 'active' => false,
521 ],
522 'condition' => [
523 'theme' => ''
524 ],
525 ]
526 );
527
528 $this->add_control(
529 'header_end',
530 [
531 'label' => esc_html__('After title', 'wordpress-popular-posts'),
532 'type' => \Elementor\Controls_Manager::TEXTAREA,
533 'rows' => 5,
534 'default' => '</h2>',
535 'ai' => [
536 'active' => false,
537 ],
538 'condition' => [
539 'theme' => ''
540 ],
541 ]
542 );
543
544 $this->add_control(
545 'wpp_start',
546 [
547 'label' => esc_html__('Before popular posts', 'wordpress-popular-posts'),
548 'type' => \Elementor\Controls_Manager::TEXTAREA,
549 'rows' => 5,
550 'default' => '<ul class="wpp-list">',
551 'ai' => [
552 'active' => false,
553 ],
554 'condition' => [
555 'theme' => ''
556 ],
557 ]
558 );
559
560 $this->add_control(
561 'wpp_end',
562 [
563 'label' => esc_html__('After popular posts', 'wordpress-popular-posts'),
564 'type' => \Elementor\Controls_Manager::TEXTAREA,
565 'rows' => 5,
566 'default' => '</ul>',
567 'ai' => [
568 'active' => false,
569 ],
570 'condition' => [
571 'theme' => ''
572 ],
573 ]
574 );
575
576 $this->add_control(
577 'post_html',
578 [
579 'label' => esc_html__('Post HTML markup', 'wordpress-popular-posts'),
580 'type' => \Elementor\Controls_Manager::TEXTAREA,
581 'rows' => 10,
582 'default' => '<li class="{current_class}">{thumb} {title} <span class="wpp-meta post-stats">{stats}</span><p class="wpp-excerpt">{excerpt}</p></li>',
583 'description' => '<a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/2.-Template-tags#content-tags" target="_blank">' . esc_html__('Content Tags List', 'wordpress-popular-posts') . '</a>',
584 'ai' => [
585 'active' => false,
586 ],
587 'condition' => [
588 'theme' => ''
589 ],
590 ]
591 );
592
593 $this->end_controls_section();
594