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

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

108 lines 3.0 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 * Frontend/Author Dashboard Widget.
7 * Displays author/contributor dashboard.
8 */
9 class FrontendWidget extends BaseWidget
10 {
11 /**
12 * Expected settings keys for this widget.
13 */
14 private const SETTINGS_KEYS = ['logo', 'flaturl', 'hide'];
15
16 /**
17 * Settings sanitization rules.
18 */
19 private const SANITIZERS = [
20 'logo' => 'url',
21 'flaturl' => 'text',
22 ];
23
24 public function get_name()
25 {
26 return 'wpdmfrontend';
27 }
28
29 public function get_title()
30 {
31 return __('Author Dashboard', WPDM_ELEMENTOR);
32 }
33
34 public function get_icon()
35 {
36 return 'eicon-dashboard';
37 }
38
39 protected function register_controls()
40 {
41 $this->start_controls_section(
42 'content_section',
43 [
44 'label' => __('Parameters', WPDM_ELEMENTOR),
45 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
46 ]
47 );
48
49 $this->add_control(
50 'logo',
51 [
52 'label' => __('Logo URL', WPDM_ELEMENTOR),
53 'type' => \Elementor\Controls_Manager::TEXT,
54 'input_type' => 'url',
55 'placeholder' => __('Logo URL', WPDM_ELEMENTOR),
56 'description' => __('Image URL to show on top of the dashboard', WPDM_ELEMENTOR)
57 ]
58 );
59
60 $this->add_control(
61 'flaturl',
62 [
63 'label' => __('Flat URL', 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' => '0'
70 ]
71 );
72
73 $this->add_control(
74 'hide',
75 [
76 'label' => __('Hide Elements', WPDM_ELEMENTOR),
77 'type' => \Elementor\Controls_Manager::SELECT2,
78 'multiple' => true,
79 'options' => [
80 'settings' => __('Settings', WPDM_ELEMENTOR),
81 'images' => __('Images', WPDM_ELEMENTOR),
82 'cats' => __('Categories', WPDM_ELEMENTOR),
83 'tags' => __('Tags', WPDM_ELEMENTOR)
84 ],
85 'default' => []
86 ]
87 );
88
89 $this->end_controls_section();
90 }
91
92 protected function render()
93 {
94 $settings = $this->getCleanSettings(self::SETTINGS_KEYS);
95 $settings = $this->sanitizeSettings($settings, self::SANITIZERS);
96
97 // Convert hide array to comma-separated string
98 if (isset($settings['hide']) && is_array($settings['hide'])) {
99 $settings['hide'] = implode(',', array_map('sanitize_text_field', $settings['hide']));
100 }
101
102 echo $this->wrapOutput(
103 WPDM()->authorDashboard->dashboard($settings),
104 'author-dashboard-widget'
105 );
106 }
107 }
108