PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.0.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / widgets / profile / widget.php

widget.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.0.1, at widgets/profile/widget.php

152 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use AcyMailing\Classes\ListClass;
4 use AcyMailing\FrontControllers\FrontusersController;
5 use AcyMailing\Core\AcymParameter;
6
7 class acym_profile_widget extends WP_Widget
8 {
9 public function __construct()
10 {
11 $this->loadAcyMailing();
12
13 parent::__construct(
14 'acym_profile_widget',
15 acym_translationSprintf('ACYM_MENU', acym_translation('ACYM_MENU_PROFILE')),
16 ['description' => acym_translation('ACYM_MENU_PROFILE_DESC')]
17 );
18 }
19
20 public function form($instance)
21 {
22 $this->loadAcyMailing();
23
24 acym_addStyle(false, ACYM_CSS.'widget.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'widget.min.css'));
25
26 $listClass = new ListClass();
27 $lists = $listClass->getAllWithoutManagement();
28 foreach ($lists as $i => $oneList) {
29 if ($oneList->active == 0) {
30 unset($lists[$i]);
31 }
32 }
33
34 $params = [
35 'title' => 'Your profile',
36 'lists' => 'All',
37 'listschecked' => 'None',
38 'dropdown' => '0',
39 'hiddenlists' => 'None',
40 'fields' => '1',
41 'introtext' => '',
42 'posttext' => '',
43 'source' => 'profile __i__',
44 ];
45
46 foreach ($params as $oneParam => &$value) {
47 if (!empty($instance)) {
48 if (isset($instance[$oneParam])) {
49 $value = $instance[$oneParam];
50 } else {
51 $value = '';
52 }
53 }
54
55 if (is_array($value)) {
56 $value = implode(',', $value);
57 }
58
59 $value = esc_attr($value);
60 }
61
62 if (!isset($instance['hiddenlists']) && !empty($params['lists'])) {
63 $params['hiddenlists'] = '';
64 }
65
66 echo '<div class="acym_toggle_zone">
67 <div class="acyblock" id="mainopt_profilewidget">
68 <div class="acym_toggle_div_title">
69 <h3>'.acym_translation('ACYM_MAIN_OPTIONS').'</h3>
70 </div>
71 <div class="acym_toggle_div" style="display: none;">';
72
73 echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('title').'">'.acym_translation('ACYM_TITLE').'</label>
74 <input type="text" class="widefat" id="'.$this->get_field_id('title').'" name="'.$this->get_field_name('title').'" value="'.$params['title'].'" /></p>';
75
76
77 echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_VISIBLE_LISTS_DESC').'">'.acym_translation('ACYM_VISIBLE_LISTS').'</label>';
78 echo acym_displayParam('lists', $params['lists'], $this->get_field_name('lists')).'</p>';
79
80 echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_DROPDOWN_LISTS_DESC').'">'.acym_translation('ACYM_DROPDOWN_LISTS').'</label>';
81 echo acym_boolean($this->get_field_name('dropdown'), $params['dropdown'], $this->get_field_id('dropdown')).'</p>';
82
83 echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_LISTS_CHECKED_DEFAULT_DESC').'">'.acym_translation('ACYM_LISTS_CHECKED_DEFAULT').'</label>';
84 echo acym_displayParam('lists', $params['listschecked'], $this->get_field_name('listschecked')).'</p>';
85
86 echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_AUTO_SUBSCRIBE_TO_DESC').'">'.acym_translation('ACYM_AUTO_SUBSCRIBE_TO').'</label>';
87 echo acym_displayParam('lists', $params['hiddenlists'], $this->get_field_name('hiddenlists')).'</p>';
88
89 echo '<p><label class="acyWPconfig" title="'.acym_translation('ACYM_FIELDS_TO_DISPLAY_DESC').'">'.acym_translation('ACYM_FIELDS_TO_DISPLAY').'</label>';
90 echo acym_displayParam('fields', $params['fields'], $this->get_field_name('fields')).'</p>';
91
92 echo '</div>
93 </div>
94 <div class="acyblock" id="advopt_profilewidget">
95 <div class="acym_toggle_div_title">
96 <h3>'.acym_translation('ACYM_ADVANCED_OPTIONS').'</h3>
97 </div>
98 <div class="acym_toggle_div" style="display: none;">';
99
100 echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('introtext').'" title="'.acym_translation('ACYM_INTRO_TEXT_DESC').'">'.acym_translation('ACYM_INTRO_TEXT').'</label>
101 <textarea class="widefat" id="'.$this->get_field_id('introtext').'" name="'.$this->get_field_name('introtext').'" >'.$params['introtext'].'</textarea></p>';
102
103 echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('posttext').'" title="'.acym_translation('ACYM_POST_TEXT_DESC').'">'.acym_translation('ACYM_POST_TEXT').'</label>
104 <textarea class="widefat" id="'.$this->get_field_id('posttext').'" name="'.$this->get_field_name('posttext').'" >'.$params['posttext'].'</textarea></p>';
105
106 echo '<p><label class="acyWPconfig" for="'.$this->get_field_id('source').'" title="'.acym_translation('ACYM_SOURCE_DESC').'">'.acym_translation('ACYM_SOURCE').'</label>
107 <input type="text" class="widefat" id="'.$this->get_field_id('source').'" name="'.$this->get_field_name('source').'" value="'.$params['source'].'" /></p>';
108
109 echo '</div></div></div>';
110 }
111
112 public function widget($args, $instance)
113 {
114 $this->loadAcyMailing();
115
116 if (!acym_isElementorEdition()) {
117 acym_loadAssets('frontusers', 'profile');
118 }
119
120 echo $args['before_widget'];
121
122 if (!isset($instance['title'])) $instance['title'] = '';
123 $title = apply_filters('widget_title', $instance['title'], $instance, $args['widget_id']);
124 if (!empty($title)) {
125 echo $args['before_title'].$title.$args['after_title'];
126 }
127
128 acym_setVar('page', ACYM_COMPONENT.'_front');
129 $params = new AcymParameter($instance);
130 acym_initModule($params);
131
132 $userController = new FrontusersController();
133 $data = $userController->prepareParams((object)$instance);
134
135 if (empty($data['user']->language)) {
136 $cmsUserLanguage = acym_getCmsUserLanguage();
137 $data['user']->language = empty($cmsUserLanguage) ? acym_getLanguageTag() : $cmsUserLanguage;
138 }
139
140 acym_setVar('layout', 'profile');
141 $userController->display($data);
142
143 echo $args['after_widget'];
144 }
145
146 private function loadAcyMailing(): void
147 {
148 $ds = DIRECTORY_SEPARATOR;
149 require_once rtrim(dirname(dirname(__DIR__)), $ds).$ds.'back'.$ds.'Core'.$ds.'init.php';
150 }
151 }
152