| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDM\Elementor\Widgets; |
| 4 |
|
| 5 |
/** |
| 6 |
* User Profile Widget. |
| 7 |
* Displays user profile. |
| 8 |
* Note: This widget is currently disabled in Main.php |
| 9 |
*/ |
| 10 |
class UserProfileWidget extends BaseWidget |
| 11 |
{ |
| 12 |
/** |
| 13 |
* Expected settings keys for this widget. |
| 14 |
*/ |
| 15 |
private const SETTINGS_KEYS = ['template']; |
| 16 |
|
| 17 |
/** |
| 18 |
* Settings sanitization rules. |
| 19 |
*/ |
| 20 |
private const SANITIZERS = [ |
| 21 |
'template' => 'text', |
| 22 |
]; |
| 23 |
|
| 24 |
public function get_name() |
| 25 |
{ |
| 26 |
return 'wpdm-user-profile'; |
| 27 |
} |
| 28 |
|
| 29 |
public function get_title() |
| 30 |
{ |
| 31 |
return __('User Profile', WPDM_ELEMENTOR); |
| 32 |
} |
| 33 |
|
| 34 |
public function get_icon() |
| 35 |
{ |
| 36 |
return 'eicon-user-circle-o'; |
| 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 |
'template', |
| 51 |
[ |
| 52 |
'label' => __('Link Template', WPDM_ELEMENTOR), |
| 53 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 54 |
'options' => get_wpdm_link_templates(), |
| 55 |
'default' => 'link-template-default' |
| 56 |
] |
| 57 |
); |
| 58 |
|
| 59 |
$this->end_controls_section(); |
| 60 |
} |
| 61 |
|
| 62 |
protected function render() |
| 63 |
{ |
| 64 |
$settings = $this->getCleanSettings(self::SETTINGS_KEYS); |
| 65 |
$settings = $this->sanitizeSettings($settings, self::SANITIZERS); |
| 66 |
|
| 67 |
echo $this->wrapOutput( |
| 68 |
WPDM()->user->profile->profile($settings), |
| 69 |
'user-profile-widget' |
| 70 |
); |
| 71 |
} |
| 72 |
} |
| 73 |
|