PluginProbe
WP Directory Kit / 1.2.7
WP Directory Kit v1.2.7
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / classes / wdk-listing-agent-avatar.php

wdk-listing-agent-avatar.php in WP Directory Kit 1.2.7, at elementor-elements/classes/wdk-listing-agent-avatar.php

378 lines 11.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Wdk\Elementor\Widgets;
4
5 use Wdk\Elementor\Widgets\WdkElementorBase;
6 use Elementor\Widget_Base;
7 use Elementor\Controls_Manager;
8 use Elementor\Utils;
9 use Elementor\Typography;
10 use Elementor\Editor;
11 use Elementor\Plugin;
12 use Elementor\Repeater;
13 use Elementor\Core\Schemes;
14 use Elementor\Icons_Manager;
15 use Elementor\Group_Control_Typography;
16 use Elementor\Group_Control_Border;
17 use Elementor\Group_Control_Box_Shadow;
18
19 if (!defined('ABSPATH'))
20 exit; // Exit if accessed directly
21
22 /**
23 * @since 1.1.0
24 */
25 class WdkListingAgentAvatar extends WdkElementorBase {
26
27 public $field_id = NULL;
28 public $fields_list = array();
29
30 public function __construct($data = array(), $args = null) {
31
32 \Elementor\Controls_Manager::add_tab(
33 'tab_conf',
34 esc_html__('Settings', 'wpdirectorykit')
35 );
36
37 \Elementor\Controls_Manager::add_tab(
38 'tab_layout',
39 esc_html__('Layout', 'wpdirectorykit')
40 );
41
42 \Elementor\Controls_Manager::add_tab(
43 'tab_content',
44 esc_html__('Main', 'wpdirectorykit')
45 );
46
47 if ($this->is_edit_mode_load()) {
48 $this->enqueue_styles_scripts();
49 }
50
51 parent::__construct($data, $args);
52
53 }
54
55 /**
56 * Retrieve the list of categories the widget belongs to.
57 *
58 * Used to determine where to display the widget in the editor.
59 *
60 * Note that currently Elementor supports only one category.
61 * When multiple categories passed, Elementor uses the first one.
62 *
63 * @since 1.1.0
64 *
65 * @access public
66 *
67 * @return array Widget categories.
68 */
69 public function get_categories() {
70 return [ 'wdk-elementor-listing-preview' ];
71 }
72
73 /**
74 * Retrieve the widget name.
75 *
76 * @since 1.1.0
77 *
78 * @access public
79 *
80 * @return string Widget name.
81 */
82 public function get_name() {
83 return 'wdk-listing-agent-avatar';
84 }
85
86 /**
87 * Retrieve the widget title.
88 *
89 * @since 1.1.0
90 *
91 * @access public
92 *
93 * @return string Widget title.
94 */
95 public function get_title() {
96 return esc_html__('Wdk Listing Agent Avatar', 'wpdirectorykit');
97 }
98
99 /**
100 * Retrieve the widget icon.
101 *
102 * @since 1.1.0
103 *
104 * @access public
105 *
106 * @return string Widget icon.
107 */
108 public function get_icon() {
109 return 'eicon-image-rollover';
110 }
111
112 /**
113 * Register the widget controls.
114 *
115 * Adds different input fields to allow the user to change and customize the widget settings.
116 *
117 * @since 1.1.0
118 *
119 * @access protected
120 */
121 protected function register_controls() {
122 $this->generate_controls_conf();
123 $this->generate_controls_layout();
124 $this->generate_controls_styles();
125 $this->generate_controls_content();
126
127 $this->insert_pro_message('1');
128 parent::register_controls();
129 }
130
131 /**
132 * Render the widget output on the frontend.
133 *
134 * Written in PHP and used to generate the final HTML.
135 *
136 * @since 1.1.0
137 *
138 * @access protected
139 */
140 protected function render() {
141 parent::render();
142 global $wdk_listing_id;
143
144 $this->data['id_element'] = $this->get_id();
145 $this->data['settings'] = $this->get_settings();
146
147 $this->data['user_avatar_url'] = '';
148 $this->data['userdata'] = array();
149 $this->data['user_id'] = '';
150
151 if(!Plugin::$instance->editor->is_edit_mode()){
152 $this->WMVC->model('listing_m');
153 if($this->data['settings']['index_user'] == 0) {
154 $listing = $this->WMVC->listing_m->get($wdk_listing_id, TRUE);
155 if($listing && wmvc_show_data('user_id_editor', $listing)) {
156 $userdata = get_userdata(wmvc_show_data('user_id_editor', $listing));
157 if($userdata) {
158 $this->data['user_id'] = wmvc_show_data('user_id_editor', $listing);
159 $this->data['userdata'] = $userdata;
160 $this->data['user_avatar_url'] = get_avatar_url($this->data['user_id']);
161 }
162 }
163 } else {
164
165 $this->WMVC->model('listingusers_m');
166
167 $this->WMVC->db->limit(1);
168 $this->WMVC->db->offset($this->data['settings']['index_user']-1);
169
170 $listing_alt_agents = $this->WMVC->listingusers_m->get($wdk_listing_id);
171 if(!empty($listing_alt_agents)) {
172 $listing_alt_agents = current($listing_alt_agents);
173 $userdata = get_userdata(wmvc_show_data('user_id', $listing_alt_agents));
174 if($userdata) {
175 $this->data['user_id'] = wmvc_show_data('user_id', $listing_alt_agents);
176 $this->data['userdata'] = $userdata;
177 $this->data['user_avatar_url'] = get_avatar_url($this->data['user_id']);
178 }
179 }
180
181 }
182
183 }
184
185 $this->data['is_edit_mode']= false;
186 if(Plugin::$instance->editor->is_edit_mode()){
187 $this->data['is_edit_mode']= true;
188 $this->data['user_avatar_url'] = wdk_placeholder_image_src();
189 } else {
190 /* return false if no content */
191 if(empty($this->data['user_avatar_url']))
192 return false;
193 }
194
195 echo $this->view('wdk-listing-agent-avatar', $this->data);
196 }
197
198
199 private function generate_controls_conf() {
200 $this->start_controls_section(
201 'tab_conf_main_section',
202 [
203 'label' => esc_html__('Main', 'wpdirectorykit'),
204 'tab' => '1',
205 ]
206 );
207
208 $this->add_control(
209 'index_user',
210 [
211 'label' => __( 'Agent Index', 'wpdirectorykit' ),
212 'description' => __( 'Agent id, where 0 is user edit, then 1,2,3,4 ... is alternative agent by index', 'wpdirectorykit' ),
213 'type' => \Elementor\Controls_Manager::NUMBER,
214 'default' => 0,
215 'min' => 0,
216 'max' => 100,
217 'step' => 1,
218 ]
219 );
220
221 $this->add_responsive_control (
222 'avatar_max_heigth',
223 [
224 'label' => esc_html__('Max Height', 'wpdirectorykit'),
225 'type' => Controls_Manager::SLIDER,
226 'range' => [
227 'px' => [
228 'min' => 10,
229 'max' => 1500,
230 ],
231 'vw' => [
232 'min' => 0,
233 'max' => 100,
234 ],
235 '%' => [
236 'min' => 0,
237 'max' => 100,
238 ],
239 ],
240 'size_units' => [ 'px', 'vw','%' ],
241 'selectors' => [
242 '{{WRAPPER}} .wdk-listing-agent-avatar .wdk-avatar' => 'max-height: {{SIZE}}{{UNIT}}',
243 ],
244
245 ]
246 );
247
248 $this->add_responsive_control (
249 'avatar_max_width',
250 [
251 'label' => esc_html__('Max Width', 'wpdirectorykit'),
252 'type' => Controls_Manager::SLIDER,
253 'range' => [
254 'px' => [
255 'min' => 10,
256 'max' => 1500,
257 ],
258 'vw' => [
259 'min' => 0,
260 'max' => 100,
261 ],
262 '%' => [
263 'min' => 0,
264 'max' => 100,
265 ],
266 ],
267 'size_units' => [ 'px', 'vw','%' ],
268 'default' => [
269 'size' => 100,
270 'unit' => '%',
271 ],
272 'selectors' => [
273 '{{WRAPPER}} .wdk-listing-agent-avatar .wdk-avatar' => 'max-width: {{SIZE}}{{UNIT}}',
274 ],
275
276 ]
277 );
278
279 $this->add_responsive_control (
280 'avatar_heigth',
281 [
282 'label' => esc_html__('Height', 'wpdirectorykit'),
283 'type' => Controls_Manager::SLIDER,
284 'range' => [
285 'px' => [
286 'min' => 10,
287 'max' => 1500,
288 ],
289 'vw' => [
290 'min' => 0,
291 'max' => 100,
292 ],
293 '%' => [
294 'min' => 0,
295 'max' => 100,
296 ],
297 ],
298 'size_units' => [ 'px', 'vw','%' ],
299 'selectors' => [
300 '{{WRAPPER}} .wdk-listing-agent-avatar .wdk-avatar' => 'height: {{SIZE}}{{UNIT}}',
301 ],
302
303 ]
304 );
305
306 $this->add_responsive_control (
307 'avatar_width',
308 [
309 'label' => esc_html__('Width', 'wpdirectorykit'),
310 'type' => Controls_Manager::SLIDER,
311 'range' => [
312 'px' => [
313 'min' => 10,
314 'max' => 1500,
315 ],
316 'vw' => [
317 'min' => 0,
318 'max' => 100,
319 ],
320 '%' => [
321 'min' => 0,
322 'max' => 100,
323 ],
324 ],
325 'size_units' => [ 'px', 'vw','%' ],
326 'selectors' => [
327 '{{WRAPPER}} .wdk-listing-agent-avatar .wdk-avatar' => 'width: {{SIZE}}{{UNIT}}',
328 ],
329
330 ]
331 );
332 $this->end_controls_section();
333
334 }
335
336 private function generate_controls_layout() {
337 }
338
339
340 private function generate_controls_styles() {
341 $items = [
342 [
343 'key'=>'field_value',
344 'label'=> esc_html__('Field Label', 'wpdirectorykit'),
345 'selector'=>'.wdk-listing-agent-avatar',
346 'options'=>'full',
347 ]
348 ];
349
350 foreach ($items as $item) {
351 $this->start_controls_section(
352 $item['key'].'_section',
353 [
354 'label' => $item['label'],
355 'tab' => 'tab_layout'
356 ]
357 );
358
359 $selectors = array(
360 'normal' => '{{WRAPPER}} '.$item['selector'],
361 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
362 );
363 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
364
365 $this->end_controls_section();
366 /* END special for some elements */
367 }
368 }
369
370 private function generate_controls_content() {
371
372 }
373
374 public function enqueue_styles_scripts() {
375
376 }
377 }
378