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 / UserDashboardWidget.php

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

129 lines 3.8 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 * User Dashboard Widget.
7 * Displays user dashboard with favorites and recommendations.
8 */
9 class UserDashboardWidget extends BaseWidget
10 {
11 /**
12 * Expected settings keys for this widget.
13 */
14 private const SETTINGS_KEYS = ['logo', 'recommended', 'fav', 'signup', 'flaturl'];
15
16 /**
17 * Settings sanitization rules.
18 */
19 private const SANITIZERS = [
20 'logo' => 'url',
21 'recommended' => 'text',
22 'fav' => 'text',
23 'signup' => 'text',
24 'flaturl' => 'text',
25 ];
26
27 public function get_name()
28 {
29 return 'wpdmuserdashboard';
30 }
31
32 public function get_title()
33 {
34 return __('User Dashboard', WPDM_ELEMENTOR);
35 }
36
37 public function get_icon()
38 {
39 return 'eicon-thumbnails-half';
40 }
41
42 protected function register_controls()
43 {
44 $this->start_controls_section(
45 'content_section',
46 [
47 'label' => __('Parameters', WPDM_ELEMENTOR),
48 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
49 ]
50 );
51
52 $this->add_control(
53 'logo',
54 [
55 'label' => __('Logo URL', WPDM_ELEMENTOR),
56 'type' => \Elementor\Controls_Manager::TEXT,
57 'input_type' => 'url',
58 'placeholder' => __('Logo URL', WPDM_ELEMENTOR),
59 'description' => __('Image URL to show on top of the dashboard', WPDM_ELEMENTOR)
60 ]
61 );
62
63 $this->add_control(
64 'recommended',
65 [
66 'label' => __('Recommended', WPDM_ELEMENTOR),
67 'type' => \Elementor\Controls_Manager::TEXT,
68 'input_type' => 'text',
69 'default' => 'recent',
70 'placeholder' => __('Category slug or "recent"', WPDM_ELEMENTOR),
71 'description' => __('Use category slug or "recent" for latest items', WPDM_ELEMENTOR)
72 ]
73 );
74
75 $this->add_control(
76 'fav',
77 [
78 'label' => __('Show Favorites Section', WPDM_ELEMENTOR),
79 'type' => \Elementor\Controls_Manager::CHOOSE,
80 'options' => [
81 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'],
82 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check']
83 ],
84 'default' => '1'
85 ]
86 );
87
88 $this->add_control(
89 'signup',
90 [
91 'label' => __('Show Login + Signup', WPDM_ELEMENTOR),
92 'type' => \Elementor\Controls_Manager::CHOOSE,
93 'options' => [
94 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'],
95 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check']
96 ],
97 'default' => '1',
98 'description' => __('Show signup form when user is not logged in', WPDM_ELEMENTOR)
99 ]
100 );
101
102 $this->add_control(
103 'flaturl',
104 [
105 'label' => __('Flat URL', WPDM_ELEMENTOR),
106 'type' => \Elementor\Controls_Manager::CHOOSE,
107 'options' => [
108 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'],
109 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check']
110 ],
111 'default' => '0'
112 ]
113 );
114
115 $this->end_controls_section();
116 }
117
118 protected function render()
119 {
120 $settings = $this->getCleanSettings(self::SETTINGS_KEYS);
121 $settings = $this->sanitizeSettings($settings, self::SANITIZERS);
122
123 echo $this->wrapOutput(
124 WPDM()->user->dashboard->dashboard($settings),
125 'user-dashboard-widget'
126 );
127 }
128 }
129