PluginProbe
WP Directory Kit / 1.3.4
WP Directory Kit v1.3.4
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-extensions / class-hider.php

class-hider.php in WP Directory Kit 1.3.4, at elementor-extensions/class-hider.php

741 lines 28.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH'))
4 exit; // Exit if accessed directly
5
6 use Elementor\Plugin;
7 use Elementor\Controls_Manager;
8 use Elementor\Modules\DynamicTags\Module;
9
10 add_action( 'elementor/init', function() {
11
12 $listing_page_id = get_option('wdk_listing_page');
13
14 if(!empty($listing_page_id))
15 {
16 new WDK_Extension_Hider();
17
18 /*
19 if(isset($_GET['post']) && $_GET['post'] == $listing_page_id)
20 {
21 new WDK_Extension_Hider();
22 }
23 elseif(!Plugin::$instance->editor->is_edit_mode())
24 {
25 new WDK_Extension_Hider();
26 }*/
27 }
28 });
29
30 /**
31 * WDK_Extension_Hider
32 *
33 * Class to extend Elementor controls functionality, adding hide feature based on specific wdk field
34 *
35 */
36
37 class WDK_Extension_Hider {
38
39 public $name = 'WDK Hider';
40
41 private $is_common = true;
42
43 private $depended_scripts = [];
44
45 private $depended_styles = [];
46
47 private $has_controls = TRUE;
48
49 public $common_sections_actions = array(
50 array(
51 'element' => 'common',
52 'action' => '_section_style',
53 ),
54 array(
55 'element' => 'container',
56 'action' => 'section_layout',
57 ),
58 array(
59 'element' => 'section',
60 'action' => 'section_advanced',
61 ),
62 array(
63 'element' => 'column',
64 'action' => 'section_advanced',
65 ),
66 );
67
68 private $supported_elements = array(
69 'heading'
70 );
71
72 public function __construct() {
73
74 /*
75 Controls_Manager::add_tab(
76 'wdk_hider',
77 __( 'Hider', 'wpdirectorykit' )
78 );*/
79
80 $this->init();
81 }
82
83 public function init( $param = null ) {
84 // Enqueue scripts
85 add_action( 'elementor/frontend/after_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
86
87 // Enqueue styles
88 add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'enqueue_styles' ] );
89
90 // Elementor hooks
91
92 if ( $this->is_common ) {
93 // Add the advanced section required to display controls
94 $this->add_common_sections_actions();
95 }
96
97 $this->add_actions();
98 }
99
100 public static function is_enabled() {
101 return true;
102 }
103
104 public function add_script_depends( $handler ) {
105 $this->depended_scripts[] = $handler;
106 }
107
108 public function add_style_depends( $handler ) {
109 $this->depended_styles[] = $handler;
110 }
111
112 public function get_script_depends() {
113 return $this->depended_scripts;
114 }
115
116 public function enqueue_scripts() {
117 foreach ( $this->get_script_depends() as $script ) {
118 wp_enqueue_script( $script );
119 }
120 }
121
122 public function get_style_depends() {
123 return $this->depended_styles;
124 }
125
126 public static function get_description() {
127 return '';
128 }
129
130 public function enqueue_styles() {
131 foreach ( $this->get_style_depends() as $style ) {
132 wp_enqueue_style( $style );
133 }
134 }
135
136 public function _enqueue_scripts() {
137 $scripts = $this->get_script_depends();
138 if ( ! empty( $scripts ) ) {
139 foreach ( $scripts as $script ) {
140 wp_enqueue_script( $script );
141 }
142 }
143 }
144
145 public function _enqueue_styles() {
146 $styles = $this->get_style_depends();
147 if ( ! empty( $styles ) ) {
148 foreach ( $styles as $style ) {
149 wp_enqueue_style( $style );
150 }
151 }
152 }
153
154 public function enqueue_all() {
155 $this->_enqueue_styles();
156 $this->_enqueue_scripts();
157 }
158
159 public function get_low_name() {
160 return 'hider';
161 }
162
163 final public function add_common_sections( $element, $args ) {
164 $low_name = $this->get_low_name();
165 $section_name = 'wdk_section_' . $low_name . '_advanced';
166
167 if ( ! $this->has_controls ) {
168 // no need settings
169 return false;
170 }
171
172 // Check if this section exists
173 $section_exists = \Elementor\Plugin::instance()->controls_manager->get_control_from_stack( $element->get_unique_name(), $section_name );
174
175 if ( ! is_wp_error( $section_exists ) ) {
176 // We can't and should try to add this section to the stack
177 return false;
178 }
179
180 $this->get_control_section( $section_name, $element );
181 }
182
183 public function add_common_sections_actions() {
184 foreach ( $this->common_sections_actions as $action ) {
185 // Activate action for elements
186 add_action('elementor/element/' . $action['element'] . '/' . $action['action'] . '/after_section_end', function ( $element, $args ) {
187 $this->add_common_sections( $element, $args );
188 }, 10, 2);
189 }
190 }
191
192 protected function add_actions() {
193
194 // WIDGET
195 add_action( 'elementor/frontend/widget/before_render', [ $this, '_start_element' ], 10, 1 );
196 add_action( 'elementor/frontend/widget/after_render', [ $this, '_end_element' ], 10, 1 );
197
198 // SECTION
199 add_action( 'elementor/frontend/section/before_render', [ $this, '_start_element' ], 10, 1 );
200 add_action( 'elementor/frontend/section/after_render', [ $this, '_end_element' ], 10, 1 );
201
202 // CONTAINER
203 add_action( 'elementor/frontend/container/before_render', [ $this, '_start_element' ], 10, 1 );
204 add_action( 'elementor/frontend/container/after_render', [ $this, '_end_element' ], 10, 1 );
205
206 // COLUMN
207 add_action( 'elementor/frontend/column/before_render', [ $this, '_start_element' ], 10, 1 );
208 add_action( 'elementor/frontend/column/after_render', [ $this, '_end_element' ], 10, 1 );
209
210
211 }
212
213 protected function remove_controls( $element, $controls = null ) {
214 if ( empty( $controls ) ) {
215 return;
216 }
217
218 if ( is_array( $controls ) ) {
219 $control_id = $controls;
220
221 foreach ( $controls as $control_id ) {
222 $element->remove_control( $control_id );
223 }
224 } else {
225 $element->remove_control( $controls );
226 }
227 }
228
229 public function get_control_section( $section_name, $element ) {
230 $low_name = $this->get_low_name();
231
232 $element->start_controls_section(
233 $section_name,
234 [
235 'label' => '<span class="color-wdk icon icon-dyn-logo-wdk pull-right ml-1"></span> ' . $this->name,
236 'tab' => 'advanced',
237 ]
238 );
239
240 $fields_data = wdk_cached_field_get();
241 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
242 $order_i = 0;
243 $fields_allow_for_get = array();
244 $fields_allow_for_compare = array();
245 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
246
247 $fields_list [(++$order_i).'__hide_on_get'] = esc_html__('Hide if GET is', 'wpdirectorykit');
248 $fields_allow_for_get[] = $order_i.'__hide_on_get';
249 $fields_list [(++$order_i).'__show_on_get'] = esc_html__('Show if GET is', 'wpdirectorykit');
250 $fields_allow_for_get[] = $order_i.'__show_on_get';
251
252 $fields_list [(++$order_i).'__profile_have_agency'] = esc_html__('Profile page is agency', 'wpdirectorykit');
253 $fields_list [(++$order_i).'__have_agency'] = esc_html__('Listing have agency', 'wpdirectorykit');
254 $fields_list [(++$order_i).'__have_sublistings'] = esc_html__('Listing have sublistings', 'wpdirectorykit');
255 $fields_list [(++$order_i).'__have_calendar'] = esc_html__('Listing have calendar', 'wpdirectorykit');
256 $fields_list [(++$order_i).'__havent_calendar'] = esc_html__('Listing not have calendar', 'wpdirectorykit');
257 $fields_list [(++$order_i).'__havent_images'] = esc_html__('Listing not have images', 'wpdirectorykit');
258 $fields_list [(++$order_i).'__have_images'] = esc_html__('Listing have images', 'wpdirectorykit');
259 $fields_list [(++$order_i).'__havent_plan_images'] = esc_html__('Listing not have plan images', 'wpdirectorykit');
260 $fields_list [(++$order_i).'__have_plan_images'] = esc_html__('Listing have plan images', 'wpdirectorykit');
261 $fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit');
262 $fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit');
263 $fields_allow_for_compare[] = ($order_i).'__post_id';
264 $fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit');
265 $fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit');
266 $fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit');
267 $fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit');
268 $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
269 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
270 $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
271 $fields_allow_for_compare[] = ($order_i).'__category_id';
272 $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
273 $fields_allow_for_compare[] = ($order_i).'__location_id';
274 foreach($fields_data as $field)
275 {
276 if(wmvc_show_data('field_type', $field) == 'SECTION') {
277 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
278 } else {
279 $fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
280 $fields_allow_for_compare[] = ($order_i).'__'.wmvc_show_data('idfield', $field);
281 }
282 }
283
284 $element->add_control(
285 'class_hider_important_note',
286 [
287 'label' => '',
288 'type' => \Elementor\Controls_Manager::RAW_HTML,
289 'raw' => esc_html__('Element will be hidden if related field is empty or condition is met.', 'wpdirectorykit'),
290 'content_classes' => 'wdk_elementor_hint',
291 'separator' => 'after',
292 ]
293 );
294
295 $element->add_control(
296 'wdk_related_field',
297 [
298 'label' => esc_html__('WDK Related FIeld', 'wpdirectorykit'),
299 'type' => Controls_Manager::SELECT,
300 'options' => $fields_list,
301 'default' => '',
302 'return_value' => 'section',
303 'frontend_available' => true,
304 'render_type' => 'none',
305 ]
306 );
307
308 $element->add_control(
309 'wdk_related_show_on_get_key',
310 [
311 'label' => __( 'Key', 'wpdirectorykit' ),
312 'type' => \Elementor\Controls_Manager::TEXT,
313 'default' => '',
314 'condition' => [
315 'wdk_related_field' => $fields_allow_for_get,
316 ],
317 ]
318 );
319
320 $element->add_control(
321 'wdk_related_show_on_get_value',
322 [
323 'label' => __( 'Value', 'wpdirectorykit' ),
324 'type' => \Elementor\Controls_Manager::TEXT,
325 'default' => '',
326 'condition' => [
327 'wdk_related_field' => $fields_allow_for_get,
328 ],
329 ]
330 );
331
332 $element->add_control(
333 'wdk_related_compare_type',
334 [
335 'label' => __( 'Compare Type', 'wpdirectorykit' ),
336 'type' => \Elementor\Controls_Manager::SELECT,
337 'default' => '',
338 'options' => [
339 '' => esc_html__('Default (if not empty)', 'wpdirectorykit'),
340 '==' => esc_html__('==', 'wpdirectorykit'),
341 '!=' => esc_html__('!=', 'wpdirectorykit'),
342 '>' => esc_html__('>', 'wpdirectorykit'),
343 '<' => esc_html__('<', 'wpdirectorykit'),
344 ],
345 'condition' => [
346 'wdk_related_field' => $fields_allow_for_compare,
347 ],
348 ]
349 );
350
351 $element->add_control(
352 'wdk_related_compare_value',
353 [
354 'label' => __( 'Value', 'wpdirectorykit' ),
355 'type' => \Elementor\Controls_Manager::TEXT,
356 'default' => '',
357 'condition' => [
358 'wdk_related_field' => $fields_allow_for_compare,
359 ],
360 ]
361 );
362
363 $element->end_controls_section();
364
365 }
366
367 public function _start_element( $element ) {
368 global $wdk_listing_id;
369 $wdkmembership_user_id = wdk_get_profile_page_id();
370
371 //if(Plugin::$instance->editor->is_edit_mode())return;
372 if(Plugin::$instance->editor->is_edit_mode() || (empty($wdk_listing_id) && empty($wdkmembership_user_id)))return;
373 //if(!in_array($element->get_name(), $this->supported_elements))return;
374
375 $WMVC = &wdk_get_instance();
376 $WMVC->model('field_m');
377 $WMVC->load_helper('listing');
378 $settings = $element->get_settings_for_display();
379
380 if(isset($settings['wdk_related_field']) && !empty($settings['wdk_related_field']))
381 {
382
383 $field_id = NULL;
384 $field_value = NULL;
385 $field_empty = FALSE;
386 if(strpos($settings['wdk_related_field'], '__') !== FALSE){
387 $field_id = substr($settings['wdk_related_field'], strpos($settings['wdk_related_field'],'__')+2);
388 }
389
390 if(is_null($field_id))return;
391 if($field_id == 'show_on_get' || $field_id == 'hide_on_get') {
392 if(!empty($settings['wdk_related_show_on_get_key']) && !empty($settings['wdk_related_show_on_get_value'])) {
393 $get_val = null;
394 if(isset($_GET[$settings['wdk_related_show_on_get_key']])){
395 $get_val = sanitize_text_field($_GET[$settings['wdk_related_show_on_get_key']]);
396 }
397
398 if($field_id == 'hide_on_get') {
399 if($get_val == $settings['wdk_related_show_on_get_value']){
400 $field_empty = true;
401 }
402 } else if($field_id == 'show_on_get') {
403 if($get_val !== $settings['wdk_related_show_on_get_value']){
404 $field_empty = true;
405 }
406 }
407 }
408 }elseif($field_id == 'havent_calendar' || $field_id == 'have_calendar') {
409 if(function_exists('run_wdk_bookings')) {
410 global $Winter_MVC_wdk_bookings;
411 $Winter_MVC_wdk_bookings->model('calendar_m');
412 $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id' => $wdk_listing_id, 'is_activated' => 1));
413 if($field_id == 'havent_calendar') {
414 if($calendar){
415 $field_empty = true;
416 }
417 } else if($field_id == 'have_calendar') {
418 if(!$calendar){
419 $field_empty = true;
420 }
421 }
422 }
423 } elseif($field_id == 'profile_have_agency') {
424 $wdkmembership_user_id = wdk_get_profile_page_id();
425 $field_empty = true;
426
427
428 if($wdkmembership_user_id) {
429 $user = wdk_get_user_data($wdkmembership_user_id);
430 if($user && wmvc_is_user_in_role($user['userdata'], 'wdk_agency')) {
431 $field_empty = false;
432 }
433
434 }
435 } elseif($field_id == 'have_agency') {
436 $field_empty = true;
437 if(function_exists('run_wdk_membership') && file_exists(WDK_MEMBERSHIP_PATH.'application/models/Agency_agent_m.php')) {
438 if(wdk_field_value ('user_id_editor', $wdk_listing_id)) {
439 $agent_id = wdk_field_value ('user_id_editor', $wdk_listing_id);
440 global $Winter_MVC_wdk_membership;
441 $Winter_MVC_wdk_membership->model('agency_agent_m');
442 $agent_agency = $Winter_MVC_wdk_membership->agency_agent_m->get_by(array('agent_id' => $agent_id, 'status' => 'CONFIRMED'), TRUE);
443 if($agent_agency) {
444 $user = wdk_get_user_data( wmvc_show_data('agency_id', $agent_agency, 0));
445 if($user){
446 $field_empty = false;
447 }
448 }
449 }
450 }
451 } elseif($field_id == 'have_sublistings') {
452
453 $field_empty = true;
454 if(!empty(wdk_field_value('listing_related_ids', $wdk_listing_id))){
455 foreach (explode(',',wdk_field_value('listing_related_ids', $wdk_listing_id)) as $key => $child_idlisting) {
456 if(!wdk_field_value('is_activated', $child_idlisting) || !wdk_field_value('is_approved', $child_idlisting)) continue;
457
458 $field_empty = false;
459 break;
460 }
461 }
462 } elseif($field_id == 'havent_images' || $field_id == 'have_images') {
463 $images = wdk_field_value('listing_images', $wdk_listing_id);
464 if($field_id == 'havent_images') {
465 if($images){
466 $field_empty = true;
467 }
468 } else if($field_id == 'have_images') {
469 if(!$images){
470 $field_empty = true;
471 }
472 }
473 } elseif($field_id == 'havent_plan_images' || $field_id == 'have_plan_images') {
474 $images = wdk_field_value('listing_plans_documents', $wdk_listing_id);
475 if($field_id == 'havent_plan_images') {
476 if($images){
477 $field_empty = true;
478 }
479 } else if($field_id == 'have_plan_images') {
480 if(!$images){
481 $field_empty = true;
482 }
483 }
484 } elseif(wdk_field_option($field_id, 'field_type') == "SECTION") {
485
486 // get all section fields
487 $sections_data = $WMVC->field_m->get_fields_section();
488
489 if(!isset($sections_data[$field_id]) || !isset($sections_data[$field_id]['fields']))return;
490
491 // check if all subfields are empty
492 $field_empty = true;
493 foreach($sections_data[$field_id]['fields'] as $field) {
494 if(!empty(wdk_field_value(wmvc_show_data('idfield', $field), $wdk_listing_id))){
495 $field_empty = false;
496 break;
497 }
498 }
499 }
500 else
501 {
502 $field_value = wdk_field_value($field_id, $wdk_listing_id);
503 if(!empty($settings['wdk_related_compare_type'])) {
504 switch ($settings['wdk_related_compare_type']) {
505 case '==':
506 if($field_value == $settings['wdk_related_compare_value']) {
507 } else {
508 $field_empty = TRUE;
509 }
510 break;
511 case '!=':
512 if($field_value != $settings['wdk_related_compare_value']) {
513 } else {
514 $field_empty = TRUE;
515 }
516 break;
517 case '>':
518 if($field_value > $settings['wdk_related_compare_value']) {
519 } else {
520 $field_empty = TRUE;
521 }
522 break;
523 case '<':
524 if($field_value < $settings['wdk_related_compare_value']) {
525 } else {
526 $field_empty = TRUE;
527 }
528 break;
529 default:
530 # code...
531 break;
532 }
533 } else {
534 if(empty($field_value))$field_empty = TRUE;
535 }
536 }
537
538 if($field_empty)
539 {
540 /*
541 echo '<pre>';
542 var_dump($settings['wdk_related_field']);
543 echo '</pre>';
544 */
545
546 ob_start();
547 }
548
549 }
550 }
551
552 public function _end_element( $element ) {
553 global $wdk_listing_id;
554
555 $wdkmembership_user_id = wdk_get_profile_page_id();
556
557 //if(Plugin::$instance->editor->is_edit_mode())return;
558 if(Plugin::$instance->editor->is_edit_mode() || (empty($wdk_listing_id) && empty($wdkmembership_user_id)))return;
559 //if(!in_array($element->get_name(), $this->supported_elements))return;
560
561 $WMVC = &wdk_get_instance();
562 $WMVC->model('field_m');
563 $WMVC->load_helper('listing');
564 $settings = $element->get_settings_for_display();
565
566 if(isset($settings['wdk_related_field']) && !empty($settings['wdk_related_field']))
567 {
568 $field_id = NULL;
569 $field_value = NULL;
570 $field_empty = FALSE;
571 if(strpos($settings['wdk_related_field'], '__') !== FALSE){
572 $field_id = substr($settings['wdk_related_field'], strpos($settings['wdk_related_field'],'__')+2);
573 }
574
575 if(is_null($field_id))return;
576 if($field_id == 'show_on_get' || $field_id == 'hide_on_get') {
577 if(!empty($settings['wdk_related_show_on_get_key']) && !empty($settings['wdk_related_show_on_get_value'])) {
578 $get_val = null;
579 if(isset($_GET[$settings['wdk_related_show_on_get_key']])){
580 $get_val = sanitize_text_field($_GET[$settings['wdk_related_show_on_get_key']]);
581 }
582 if($field_id == 'hide_on_get') {
583 if($get_val == $settings['wdk_related_show_on_get_value']){
584 $field_empty = true;
585 }
586 } else if($field_id == 'show_on_get') {
587 if($get_val !== $settings['wdk_related_show_on_get_value']){
588 $field_empty = true;
589 }
590 }
591 }
592 }elseif($field_id == 'havent_calendar' || $field_id == 'have_calendar') {
593 if(function_exists('run_wdk_bookings')) {
594 global $Winter_MVC_wdk_bookings;
595 $Winter_MVC_wdk_bookings->model('calendar_m');
596 $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id' => $wdk_listing_id, 'is_activated' => 1));
597 if($field_id == 'havent_calendar') {
598 if($calendar){
599 $field_empty = true;
600 }
601 } else if($field_id == 'have_calendar') {
602 if(!$calendar){
603 $field_empty = true;
604 }
605 }
606 }
607 } elseif($field_id == 'have_sublistings') {
608
609 $field_empty = true;
610 if(!empty(wdk_field_value('listing_related_ids', $wdk_listing_id))){
611 foreach (explode(',',wdk_field_value('listing_related_ids', $wdk_listing_id)) as $key => $child_idlisting) {
612 if(!wdk_field_value('is_activated', $child_idlisting) || !wdk_field_value('is_approved', $child_idlisting)) continue;
613
614 $field_empty = false;
615 break;
616 }
617 }
618 } elseif($field_id == 'have_agency') {
619 $field_empty = true;
620 if(function_exists('run_wdk_membership') && file_exists(WDK_MEMBERSHIP_PATH.'application/models/Agency_agent_m.php')) {
621 if(wdk_field_value ('user_id_editor', $wdk_listing_id)) {
622 $agent_id = wdk_field_value ('user_id_editor', $wdk_listing_id);
623 global $Winter_MVC_wdk_membership;
624 $Winter_MVC_wdk_membership->model('agency_agent_m');
625 $agent_agency = $Winter_MVC_wdk_membership->agency_agent_m->get_by(array('agent_id' => $agent_id, 'status' => 'CONFIRMED'), TRUE);
626 if($agent_agency) {
627 $user = wdk_get_user_data( wmvc_show_data('agency_id', $agent_agency, 0));
628 if($user){
629 $field_empty = false;
630 }
631 }
632 }
633 }
634 } elseif($field_id == 'profile_have_agency') {
635 $wdkmembership_user_id = wdk_get_profile_page_id();
636 $field_empty = true;
637 if($wdkmembership_user_id) {
638 $user = wdk_get_user_data($wdkmembership_user_id);
639 if($user && wmvc_is_user_in_role($user['userdata'], 'wdk_agency')) {
640 $field_empty = false;
641 }
642
643 }
644 } elseif($field_id == 'havent_images' || $field_id == 'have_images') {
645 $images = wdk_field_value('listing_images', $wdk_listing_id);
646 if($field_id == 'havent_images') {
647 if($images){
648 $field_empty = true;
649 }
650 } else if($field_id == 'have_images') {
651 if(!$images){
652 $field_empty = true;
653 }
654 }
655 } elseif($field_id == 'havent_plan_images' || $field_id == 'have_plan_images') {
656 $images = wdk_field_value('listing_plans_documents', $wdk_listing_id);
657 if($field_id == 'havent_plan_images') {
658 if($images){
659 $field_empty = true;
660 }
661 } else if($field_id == 'have_plan_images') {
662 if(!$images){
663 $field_empty = true;
664 }
665 }
666 } elseif(wdk_field_option($field_id, 'field_type') == "SECTION") {
667
668 // get all section fields
669 $sections_data = $WMVC->field_m->get_fields_section();
670
671 if(!isset($sections_data[$field_id]) || !isset($sections_data[$field_id]['fields']))return;
672
673 // check if all subfields are empty
674 $field_empty = true;
675 foreach($sections_data[$field_id]['fields'] as $field) {
676 if(!empty(wdk_field_value(wmvc_show_data('idfield', $field), $wdk_listing_id))){
677 $field_empty = false;
678 break;
679 }
680 }
681 }
682 else
683 {
684 $field_value = wdk_field_value($field_id, $wdk_listing_id);
685 if(!empty($settings['wdk_related_compare_type'])) {
686 switch ($settings['wdk_related_compare_type']) {
687 case '==':
688 if($field_value == $settings['wdk_related_compare_value']) {
689 } else {
690 $field_empty = TRUE;
691 }
692 break;
693 case '!=':
694 if($field_value != $settings['wdk_related_compare_value']) {
695 } else {
696 $field_empty = TRUE;
697 }
698 break;
699 case '>':
700 if($field_value > $settings['wdk_related_compare_value']) {
701 } else {
702 $field_empty = TRUE;
703 }
704 break;
705 case '<':
706 if($field_value < $settings['wdk_related_compare_value']) {
707 } else {
708 $field_empty = TRUE;
709 }
710 break;
711 default:
712 # code...
713 break;
714 }
715 } else {
716 if(empty($field_value))$field_empty = TRUE;
717 }
718 }
719
720 if($field_empty)
721 {
722 /*
723 echo '<pre>';
724 var_dump($settings['wdk_related_field']);
725 echo '</pre>';
726 */
727
728 $content = ob_get_clean();
729 }
730
731 }
732 }
733
734 }
735
736
737
738
739
740
741