PluginProbe
Download Manager Addons for Elementor / trunk
Download Manager Addons for Elementor vtrunk
trunk 1.0.5 1.2.3 1.2.5 1.3.0
wpdm-elementor / src / widgets / SearchResultWidget.php

SearchResultWidget.php in Download Manager Addons for Elementor trunk, at src/widgets/SearchResultWidget.php

96 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDM\Elementor\Widgets;
4
5 /**
6 * Search Result Widget.
7 * Displays search box and search results.
8 */
9 class SearchResultWidget extends BaseWidget
10 {
11 /**
12 * Expected settings keys for this widget.
13 */
14 private const SETTINGS_KEYS = ['template', 'init', 'cols'];
15
16 /**
17 * Settings sanitization rules.
18 */
19 private const SANITIZERS = [
20 'template' => 'text',
21 'init' => 'text',
22 'cols' => 'int',
23 ];
24
25 public function get_name()
26 {
27 return 'wpdmsearchresult';
28 }
29
30 public function get_title()
31 {
32 return __('Search Result', WPDM_ELEMENTOR);
33 }
34
35 public function get_icon()
36 {
37 return 'eicon-search-results';
38 }
39
40 protected function register_controls()
41 {
42 $this->start_controls_section(
43 'content_section',
44 [
45 'label' => __('Parameters', WPDM_ELEMENTOR),
46 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
47 ]
48 );
49
50 $this->add_control(
51 'template',
52 [
53 'label' => __('Link Template', WPDM_ELEMENTOR),
54 'type' => \Elementor\Controls_Manager::SELECT2,
55 'options' => get_wpdm_link_templates(),
56 'default' => 'link-template-default'
57 ]
58 );
59
60 $this->add_control(
61 'init',
62 [
63 'label' => __('Show Initial Results', WPDM_ELEMENTOR),
64 'type' => \Elementor\Controls_Manager::CHOOSE,
65 'options' => [
66 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'],
67 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check']
68 ],
69 'default' => '1',
70 'description' => __('Show latest packages before search', WPDM_ELEMENTOR)
71 ]
72 );
73
74 $this->add_control(
75 'cols',
76 [
77 'label' => __('Columns', WPDM_ELEMENTOR),
78 'type' => \Elementor\Controls_Manager::NUMBER,
79 'min' => 1,
80 'max' => 4,
81 'default' => 3
82 ]
83 );
84
85 $this->end_controls_section();
86 }
87
88 protected function render()
89 {
90 $settings = $this->getCleanSettings(self::SETTINGS_KEYS);
91 $settings = $this->sanitizeSettings($settings, self::SANITIZERS);
92
93 echo WPDM()->package->shortCodes->searchResult($settings);
94 }
95 }
96