PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 3.9.13
Tutor LMS – eLearning and online course solution v3.9.13
4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / includes / kirki / backend / VisibilityCondition.php
tutor / includes / kirki / backend Last commit date
ElementGenerator 2 months ago Ajax.php 2 weeks ago Backend.php 2 months ago Editor.php 2 months ago Frontend.php 2 months ago Helper.php 2 months ago Hooks.php 2 months ago Iframe.php 2 months ago Pages.php 2 months ago VisibilityCondition.php 1 month ago
VisibilityCondition.php
1103 lines
1 <?php
2
3 /**
4 * Preview script for html markup generator
5 *
6 * @package tutor-kirki-elements
7 */
8
9 namespace TutorLMSKirki;
10
11 use TUTOR\Course;
12 use Tutor\Models\CartModel;
13 use TUTOR_CERT\Certificate;
14 use TutorLMSKirki\ElementGenerator\CourseMetaGenerator;
15
16 if (! defined('ABSPATH')) {
17 exit; // Exit if accessed directly.
18 }
19
20 /**
21 * Class Helper
22 * This class is used to define all helper functions.
23 */
24 class VisibilityCondition
25 {
26
27 use CourseMetaGenerator;
28
29 public static function visibility_condition_fields($conditions, $collection_data)
30 {
31 $type = $collection_data['type'];
32 $collectionType = $collection_data['collectionType'];
33 if ($collectionType === 'posts') {
34 switch ($type) {
35 case 'courses': {
36 $conditions = self::get_course_type_conditions($conditions);
37 $conditions = self::get_lms_setting_type_conditions($conditions);
38 break;
39 }
40 }
41
42 } elseif ($collectionType === 'user') {
43 switch ($type) {
44 case 'courses': {
45 $conditions['user'] = array(
46 'title' => 'Instructor',
47 'fields' => array_merge(
48 $conditions['user']['fields'],
49 array(
50 array(
51 'source' => TDE_APP_PREFIX,
52 'value' => 'instructor_course_count',
53 'title' => 'Course Count',
54 'operator_type' => 'numeric_operators',
55 'operand_type' => array_merge(
56 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
57 array(
58 'placeholder' => 'Course Count',
59 )
60 ),
61 ),
62 array(
63 'source' => TDE_APP_PREFIX,
64 'value' => 'instructor_student_count',
65 'title' => 'Student Count',
66 'operator_type' => 'numeric_operators',
67 'operand_type' => array_merge(
68 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
69 array(
70 'placeholder' => 'Student Count',
71 )
72 ),
73 ),
74 array(
75 'source' => TDE_APP_PREFIX,
76 'value' => 'instructor_rating',
77 'title' => 'Rating',
78 'operator_type' => 'numeric_operators',
79 'operand_type' => array_merge(
80 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
81 array(
82 'placeholder' => 'Rating',
83 )
84 ),
85 ),
86 array(
87 'source' => TDE_APP_PREFIX,
88 'value' => 'instructor_rating_count',
89 'title' => 'Rating Count',
90 'operator_type' => 'numeric_operators',
91 'operand_type' => array_merge(
92 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
93 array(
94 'placeholder' => 'Rating Count',
95 )
96 ),
97 ),
98 )
99 ),
100 );
101 }
102 }
103 } else {
104 switch ($type) {
105 case 'TUTOR_LMS-tutor_course_rating': {
106 $conditions = self::get_course_type_conditions($conditions);
107 break;
108 }
109
110 case 'TUTOR_LMS-subscriptions': {
111 $conditions = self::get_subscription_type_conditions($conditions);
112 break;
113 }
114
115 case 'TUTOR_LMS-membership-plans': {
116 $conditions = self::get_membership_type_conditions($conditions);
117 break;
118 }
119
120 case 'TUTOR_LMS-membership-features': {
121 $conditions = self::get_membership_features_type_conditions($conditions);
122 break;
123 }
124 }
125 }
126
127 return $conditions;
128 }
129
130 private static function get_subscription_type_conditions($conditions)
131 {
132 if (!isset($conditions['post']['fields'])) {
133 $conditions['post']['fields'] = array();
134 }
135 $conditions['post'] = array(
136 'title' => 'Subscription',
137 'fields' => array_merge(
138 $conditions['post']['fields'],
139 array(
140
141 // recurring_interval
142 array(
143 'source' => TDE_APP_PREFIX,
144 'value' => 'recurring_interval',
145 'title' => 'Recurring Interval',
146 'operator_type' => 'dropdown_operators',
147 'operand_type' => array_merge(
148 KIRKI_PLUGIN_SETTINGS['SELECT'],
149 array(
150 'options' => array(
151 array(
152 'value' => 'day',
153 'title' => 'Day',
154 ),
155 array(
156 'value' => 'week',
157 'title' => 'Week',
158 ),
159 array(
160 'value' => 'month',
161 'title' => 'Month',
162 ),
163 array(
164 'value' => 'year',
165 'title' => 'Year',
166 ),
167 ),
168 ),
169 ),
170 ),
171
172 // enrollment_fee
173 array(
174 'source' => TDE_APP_PREFIX,
175 'value' => 'enrollment_fee',
176 'title' => 'Enrollment Fee',
177 'operator_type' => 'numeric_operators',
178 'operand_type' => array_merge(
179 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
180 array(
181 'placeholder' => 'Enrollment Fee',
182 ),
183 ),
184 ),
185
186 // provide_certificate DEFAULT 1, -- 0 or 1
187 array(
188 'source' => TDE_APP_PREFIX,
189 'value' => 'provide_certificate',
190 'title' => 'Provide Certificate',
191 'operator_type' => 'dropdown_operators',
192 'operand_type' => array_merge(
193 KIRKI_PLUGIN_SETTINGS['SELECT'],
194 array(
195 'options' => array(
196 array(
197 'value' => '1',
198 'title' => 'Yes',
199 ),
200 array(
201 'value' => '0',
202 'title' => 'No',
203 ),
204 ),
205 )
206 ),
207 ),
208
209 // is_featured
210 array(
211 'source' => TDE_APP_PREFIX,
212 'value' => 'is_featured',
213 'title' => 'Is Featured',
214 'operator_type' => 'dropdown_operators',
215 'operand_type' => array_merge(
216 KIRKI_PLUGIN_SETTINGS['SELECT'],
217 array(
218 'options' => array(
219 array(
220 'value' => '1',
221 'title' => 'Yes',
222 ),
223 array(
224 'value' => '0',
225 'title' => 'No',
226 ),
227 ),
228 ),
229 ),
230 ),
231
232 // sale_price
233 array(
234 'source' => TDE_APP_PREFIX,
235 'value' => 'sale_price',
236 'title' => 'Sale Price',
237 'operator_type' => 'boolean_operators',
238 ),
239 ),
240 ),
241 );
242
243 return $conditions;
244 }
245
246 private static function get_membership_type_conditions($conditions)
247 {
248 if (!isset($conditions['post']['fields'])) {
249 $conditions['post']['fields'] = array();
250 }
251 $conditions['post'] = array(
252 'title' => 'Membership',
253 'fields' => array_merge(
254 $conditions['post']['fields'],
255 array(
256 array(
257 'source' => TDE_APP_PREFIX,
258 'value' => 'recurring_interval',
259 'title' => 'Recurring Interval',
260 'operator_type' => 'dropdown_operators',
261 'operand_type' => array_merge(
262 KIRKI_PLUGIN_SETTINGS['SELECT'],
263 array(
264 'options' => array(
265 array(
266 'value' => 'day',
267 'title' => 'Day',
268 ),
269 array(
270 'value' => 'week',
271 'title' => 'Week',
272 ),
273 array(
274 'value' => 'month',
275 'title' => 'Month',
276 ),
277 array(
278 'value' => 'year',
279 'title' => 'Year',
280 ),
281 ),
282 ),
283 ),
284 ),
285
286 // recurring_value
287 array(
288 'source' => TDE_APP_PREFIX,
289 'value' => 'recurring_value',
290 'title' => 'Recurring Value',
291 'operator_type' => 'numeric_operators',
292 'operand_type' => array_merge(
293 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
294 array(
295 'placeholder' => 'Recurring Value',
296 )
297 ),
298 ),
299
300 // enrollment_fee
301 array(
302 'source' => TDE_APP_PREFIX,
303 'value' => 'enrollment_fee',
304 'title' => 'Has enrollment fee',
305 'operator_type' => 'boolean_operators',
306 ),
307
308 // provide_certificate DEFAULT 1, -- 0 or 1
309 array(
310 'source' => TDE_APP_PREFIX,
311 'value' => 'provide_certificate',
312 'title' => 'Provide Certificate',
313 'operator_type' => 'boolean_operators',
314 ),
315
316 // is_featured
317 array(
318 'source' => TDE_APP_PREFIX,
319 'value' => 'is_featured',
320 'title' => 'Is Featured',
321 'operator_type' => 'boolean_operators',
322 ),
323
324 // sale_price
325 array(
326 'source' => TDE_APP_PREFIX,
327 'value' => 'sale_price',
328 'title' => 'Offer sale Price',
329 'operator_type' => 'boolean_operators',
330 ),
331
332 // start: trial
333 array(
334 'source' => TDE_APP_PREFIX,
335 'value' => 'trial_value',
336 'title' => 'Length of Trial',
337 'operator_type' => 'numeric_operators',
338 'operand_type' => array_merge(
339 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
340 array(
341 'placeholder' => 'Trial Value',
342 )
343 ),
344 ),
345
346 array(
347 'source' => TDE_APP_PREFIX,
348 'value' => 'trial_interval',
349 'title' => 'Trial Interval',
350 'operator_type' => 'dropdown_operators',
351 'operand_type' => array_merge(
352 KIRKI_PLUGIN_SETTINGS['SELECT'],
353 array(
354 'options' => array(
355 array(
356 'value' => 'day',
357 'title' => 'Day',
358 ),
359 ),
360 ),
361 ),
362 ),
363
364 array(
365 'source' => TDE_APP_PREFIX,
366 'value' => 'trial_fee',
367 'title' => 'Trial Fee',
368 'operator_type' => 'numeric_operators',
369 'operand_type' => array_merge(
370 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
371 array(
372 'placeholder' => 'Trial Fee',
373 )
374 ),
375 ),
376 // end: trial
377 ),
378 ),
379 );
380
381 return $conditions;
382 }
383
384 private static function get_membership_features_type_conditions($conditions)
385 {
386 if (!isset($conditions['post']['fields'])) {
387 $conditions['post']['fields'] = array();
388 }
389 $conditions['post'] = array(
390 'title' => 'Feature',
391 'fields' => array_merge(
392 $conditions['post']['fields'],
393 array(
394 array(
395 'source' => TDE_APP_PREFIX,
396 'value' => 'icon_type',
397 'title' => 'Icon',
398 'operator_type' => 'dropdown_operators',
399 'operand_type' => array_merge(
400 KIRKI_PLUGIN_SETTINGS['SELECT'],
401 array(
402 'options' => array(
403 array(
404 'value' => 'yes',
405 'title' => 'Check',
406 ),
407 array(
408 'value' => 'no',
409 'title' => 'Times',
410 ),
411 ),
412 ),
413 ),
414 ),
415 ),
416 ),
417 );
418
419 return $conditions;
420 }
421
422 private static function get_course_type_conditions($conditions)
423 {
424 if (!isset($conditions['post']['fields'])) {
425 $conditions['post']['fields'] = array();
426 }
427 $conditions['post'] = array(
428 'title' => 'Course',
429 'fields' => array_merge(
430 $conditions['post']['fields'],
431 array(
432 array(
433 'source' => TDE_APP_PREFIX,
434 'value' => 'is_monetization_enabled',
435 'title' => 'Monetization Enabled',
436 'operator_type' => 'boolean_operators',
437 ),
438 array(
439 'source' => TDE_APP_PREFIX,
440 'value' => 'is_subscription_enabled',
441 'title' => 'Subscription Enabled',
442 'operator_type' => 'boolean_operators',
443 ),
444 array(
445 'source' => TDE_APP_PREFIX,
446 'value' => 'is_paid',
447 'title' => 'Paid',
448 'operator_type' => 'boolean_operators',
449 ),
450 array(
451 'source' => TDE_APP_PREFIX,
452 'value' => 'on_sale',
453 'title' => 'On Sale',
454 'operator_type' => 'boolean_operators',
455 ),
456 array(
457 'source' => TDE_APP_PREFIX,
458 'value' => 'purchase_options',
459 'title' => 'Purchase Options',
460 'operator_type' => 'dropdown_operators',
461 'operand_type' => array_merge(
462 KIRKI_PLUGIN_SETTINGS['SELECT'],
463 array(
464 'options' => array(
465 array(
466 'value' => Course::SELLING_OPTION_ONE_TIME,
467 'title' => 'One Time',
468 ),
469 array(
470 'value' => Course::SELLING_OPTION_SUBSCRIPTION,
471 'title' => 'Subscription',
472 ),
473
474 array(
475 'value' => Course::SELLING_OPTION_BOTH,
476 'title' => 'Subscription & One-Time',
477 ),
478
479 array(
480 'value' => Course::SELLING_OPTION_MEMBERSHIP,
481 'title' => 'Membership',
482 ),
483 array(
484 'value' => Course::SELLING_OPTION_ALL,
485 'title' => 'All',
486 ),
487 ),
488 )
489 ),
490 ),
491 array(
492 'source' => TDE_APP_PREFIX,
493 'value' => 'average_rating',
494 'title' => 'Rating (Avg.)',
495 'operator_type' => 'numeric_operators',
496 'operand_type' => array_merge(
497 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
498 array(
499 'placeholder' => 'Rating',
500 )
501 ),
502 ),
503 array(
504 'source' => TDE_APP_PREFIX,
505 'value' => 'total_ratings',
506 'title' => 'Total Ratings',
507 'operator_type' => 'numeric_operators',
508 'operand_type' => array_merge(
509 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
510 array(
511 'placeholder' => 'Rating count',
512 )
513 ),
514 ),
515 array(
516 'source' => TDE_APP_PREFIX,
517 'value' => 'enroll_count',
518 'title' => 'Enrollment Count',
519 'operator_type' => 'numeric_operators',
520 'operand_type' => array_merge(
521 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
522 array(
523 'placeholder' => 'Enroll Count',
524 )
525 ),
526 ),
527 array(
528 'source' => TDE_APP_PREFIX,
529 'value' => 'student_state',
530 'title' => 'Student status',
531 'operator_type' => array(
532 array(
533 'title' => '= Equals',
534 'value' => 'user_state-is_equal',
535 ),
536 array(
537 'title' => '≠ Does not equal',
538 'value' => 'user_state-not_equal',
539 ),
540 ),
541 'operand_type' => array_merge(
542 KIRKI_PLUGIN_SETTINGS['SELECT'],
543 array(
544 'options' => array(
545 array(
546 'value' => 'logged_in',
547 'title' => 'Logged in',
548 ),
549 array(
550 'value' => 'wishlisted',
551 'title' => 'Wishlisted',
552 ),
553 array(
554 'value' => 'added_in_cart',
555 'title' => 'Added in Cart',
556 ),
557 array(
558 'value' => 'enrolled',
559 'title' => 'Enrolled',
560 ),
561 array(
562 'value' => 'learner',
563 'title' => 'Learner',
564 ),
565 array(
566 'value' => 'can_retake',
567 'title' => 'Can Retake',
568 ),
569 array(
570 'value' => 'completed',
571 'title' => 'Completed',
572 ),
573 ),
574 )
575 ),
576 ),
577 // [
578 // 'source' => TDE_APP_PREFIX,
579 // 'value' => 'user_authored',
580 // 'title' => 'User authored',
581 // 'operator_type' => 'dropdown_operators',
582 // 'operand_type' => array_merge(
583 // KIRKI_PLUGIN_SETTINGS['SELECT'],
584 // [
585 // 'options' => [
586 // ['value' => 'no_review', 'title' => 'No Review'],
587 // ['value' => 'current_review', 'title' => 'Current Review'],
588 // ['value' => 'no_question', 'title' => 'No Question'],
589 // ['value' => 'current_question', 'title' => 'Current Question'],
590 // ],
591 // ]
592 // ),
593 // ],
594 array(
595 'source' => TDE_APP_PREFIX,
596 'value' => 'resource_count',
597 'title' => 'Resources',
598 'operator_type' => 'numeric_operators',
599 'operand_type' => array_merge(
600 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
601 array(
602 'placeholder' => 'Resource Count',
603 )
604 ),
605 ),
606 array(
607 'source' => TDE_APP_PREFIX,
608 'value' => 'lesson_count',
609 'title' => 'Lessons',
610 'operator_type' => 'numeric_operators',
611 'operand_type' => array_merge(
612 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
613 array(
614 'placeholder' => 'Lesson Count',
615 )
616 ),
617 ),
618 array(
619 'source' => TDE_APP_PREFIX,
620 'value' => 'quiz_count',
621 'title' => 'Quizzes',
622 'operator_type' => 'numeric_operators',
623 'operand_type' => array_merge(
624 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
625 array(
626 'placeholder' => 'Quiz Count',
627 )
628 ),
629 ),
630 array(
631 'source' => TDE_APP_PREFIX,
632 'value' => 'assignments_count',
633 'title' => 'Assignments',
634 'operator_type' => 'numeric_operators',
635 'operand_type' => array_merge(
636 KIRKI_PLUGIN_SETTINGS['INPUT_NUMBER'],
637 array(
638 'placeholder' => 'Assignment Count',
639 )
640 ),
641 ),
642 array(
643 'source' => TDE_APP_PREFIX,
644 'value' => 'is_review_enabled',
645 'title' => 'Review Enabled',
646 'operator_type' => 'boolean_operators',
647 ),
648 array(
649 'source' => TDE_APP_PREFIX,
650 'value' => 'is_qna_enabled',
651 'title' => 'QnA Enabled',
652 'operator_type' => 'boolean_operators',
653 ),
654 array(
655 'source' => TDE_APP_PREFIX,
656 'value' => 'is_certificate_enabled',
657 'title' => 'Certificate Enabled',
658 'operator_type' => 'boolean_operators',
659 ),
660 array(
661 'source' => TDE_APP_PREFIX,
662 'value' => 'difficulty_level',
663 'title' => 'Difficulty Level',
664 'operator_type' => 'dropdown_operators',
665 'operand_type' => array_merge(
666 KIRKI_PLUGIN_SETTINGS['SELECT'],
667 array(
668 'options' => array(
669 array(
670 'value' => 'all_levels',
671 'title' => 'All Levels',
672 ),
673 array(
674 'value' => 'beginner',
675 'title' => 'Beginner',
676 ),
677 array(
678 'value' => 'intermediate',
679 'title' => 'Intermediate',
680 ),
681 array(
682 'value' => 'expert',
683 'title' => 'Expert',
684 ),
685 ),
686 )
687 ),
688 ),
689 )
690 ),
691 );
692 return $conditions;
693 }
694
695 private static function get_lms_setting_type_conditions($conditions)
696 {
697 if (!isset($conditions['lms-settings']['fields'])) {
698 $conditions['lms-settings']['fields'] = array();
699 }
700
701 $conditions['lms-settings'] = array(
702 'title' => 'LMS Settings',
703 'fields' => array_merge(
704 $conditions['lms-settings']['fields'],
705 array(
706 array(
707 'source' => TDE_APP_PREFIX,
708 'value' => 'is_membership_only_mode_enabled',
709 'title' => 'Membership-Only Mode',
710 'operator_type' => 'boolean_operators',
711 ),
712 array(
713 'source' => TDE_APP_PREFIX,
714 'value' => 'enable_spotlight_mode',
715 'title' => 'Spotlight Mode Enabled',
716 'operator_type' => 'boolean_operators',
717 ),
718
719 array(
720 'source' => TDE_APP_PREFIX,
721 'value' => 'display_course_instructors',
722 'title' => 'Instructor Info Enabled',
723 'operator_type' => 'boolean_operators',
724 ),
725 array(
726 'source' => TDE_APP_PREFIX,
727 'value' => 'enable_wishlist',
728 'title' => 'Wishlist Enabled',
729 'operator_type' => 'boolean_operators',
730 ),
731 array(
732 'source' => TDE_APP_PREFIX,
733 'value' => 'enable_q_and_a_on_course',
734 'title' => 'Q&A Enabled',
735 'operator_type' => 'boolean_operators',
736 ),
737 array(
738 'source' => TDE_APP_PREFIX,
739 'value' => 'enable_course_author',
740 'title' => 'Author Enabled',
741 'operator_type' => 'boolean_operators',
742 ),
743 array(
744 'source' => TDE_APP_PREFIX,
745 'value' => 'enable_course_level',
746 'title' => 'Level Enabled',
747 'operator_type' => 'boolean_operators',
748 ),
749 array(
750 'source' => TDE_APP_PREFIX,
751 'value' => 'enable_course_share',
752 'title' => 'Social Share Enabled',
753 'operator_type' => 'boolean_operators',
754 ),
755 array(
756 'source' => TDE_APP_PREFIX,
757 'value' => 'enable_course_duration',
758 'title' => 'Duration Enabled',
759 'operator_type' => 'boolean_operators',
760 ),
761 array(
762 'source' => TDE_APP_PREFIX,
763 'value' => 'enable_course_total_enrolled',
764 'title' => 'Total Enrolled Enabled',
765 'operator_type' => 'boolean_operators',
766 ),
767 array(
768 'source' => TDE_APP_PREFIX,
769 'value' => 'enable_course_update_date',
770 'title' => 'Update Date Enabled',
771 'operator_type' => 'boolean_operators',
772 ),
773 array(
774 'source' => TDE_APP_PREFIX,
775 'value' => 'enable_course_progress_bar',
776 'title' => 'Progress Bar Enabled',
777 'operator_type' => 'boolean_operators',
778 ),
779 array(
780 'source' => TDE_APP_PREFIX,
781 'value' => 'enable_course_material',
782 'title' => 'Show Material Enabled',
783 'operator_type' => 'boolean_operators',
784 ),
785 array(
786 'source' => TDE_APP_PREFIX,
787 'value' => 'enable_course_about',
788 'title' => 'About Enabled',
789 'operator_type' => 'boolean_operators',
790 ),
791 array(
792 'source' => TDE_APP_PREFIX,
793 'value' => 'enable_course_description',
794 'title' => 'Description Enabled',
795 'operator_type' => 'boolean_operators',
796 ),
797 array(
798 'source' => TDE_APP_PREFIX,
799 'value' => 'enable_course_benefits',
800 'title' => 'Course Benefits Enabled',
801 'operator_type' => 'boolean_operators',
802 ),
803 array(
804 'source' => TDE_APP_PREFIX,
805 'value' => 'enable_course_requirements',
806 'title' => 'Requirements Enabled',
807 'operator_type' => 'boolean_operators',
808 ),
809 array(
810 'source' => TDE_APP_PREFIX,
811 'value' => 'enable_course_target_audience',
812 'title' => 'Target Audience Enabled',
813 'operator_type' => 'boolean_operators',
814 ),
815 array(
816 'source' => TDE_APP_PREFIX,
817 'value' => 'enable_course_announcements',
818 'title' => 'Announcements Enabled',
819 'operator_type' => 'boolean_operators',
820 ),
821 array(
822 'source' => TDE_APP_PREFIX,
823 'value' => 'enable_course_review',
824 'title' => 'Review Enabled',
825 'operator_type' => 'boolean_operators',
826 )
827
828 )
829 ),
830 );
831
832 return $conditions;
833 }
834
835 public static function element_visibility_condition_check($default_value, $condition, $options)
836 {
837 $source = $condition['source'];
838 $field = $condition['field']['value'];
839 $operator = $condition['operator']['value'];
840 $operand = $condition['operand']['value'];
841 $field_group = isset($condition['field']['group']) ? $condition['field']['group'] : '';
842
843 if (isset($options['TUTOR_LMS-subscriptions'])) {
844 $subscription = (array) $options['TUTOR_LMS-subscriptions'];
845 $fieldValue = self::get_subscription_field_value($subscription, $field, $options);
846 } else if (isset($options['membership-plan'], $options['itemType']) && $options['itemType'] === 'membership-plan') {
847 $membership_plan = (array) $options['membership-plan'];
848 $fieldValue = self::get_membership_plan_field_value($membership_plan, $field);
849 } else if (isset($options['membership-feature'], $options['itemType']) && $options['itemType'] === 'membership-feature') {
850 $membership_feature = (array) $options['membership-feature'];
851 $fieldValue = self::get_membership_feature_field_value($membership_feature, $field);
852 } else {
853 if ($field_group === 'lms-settings') {
854 $fieldValue = self::get_lms_settings_field_value($field);
855 } else {
856 $fieldValue = self::get_course_field_value($field, $options);
857 }
858 }
859
860 if ($source === TDE_APP_PREFIX) {
861 switch ($operator) {
862 case 'true': {
863 return (bool) $fieldValue;
864 }
865 case 'false': {
866 return ! $fieldValue;
867 }
868 case 'is_equal': {
869 return $fieldValue == $operand;
870 }
871 case 'not_equal': {
872 return $fieldValue != $operand;
873 }
874 case 'less_than': {
875 return $fieldValue < $operand;
876 }
877 case 'greater_than': {
878 return $fieldValue > $operand;
879 }
880 case 'less_than_or_equal': {
881 return $fieldValue <= $operand;
882 }
883 case 'greater_than_or_equal': {
884 return $fieldValue >= $operand;
885 }
886 case 'user_state-is_equal': {
887 return in_array($operand, $fieldValue);
888 }
889 case 'user_state-not_equal': {
890 return !in_array($operand, $fieldValue);
891 }
892 }
893 }
894
895 return $default_value;
896 }
897
898 private static function get_membership_feature_field_value($membership_feature, $field)
899 {
900 $yes_icon_types = array(
901 'tick',
902 'tick_circle',
903 'tick_circle_fill',
904 'plus_square',
905 'plus_circle',
906 'plus_circle_fill',
907 'plus_square_fill',
908 );
909
910 $no_icon_types = array(
911 'cross',
912 'cross_circle',
913 'cross_circle_fill',
914 'minus_square',
915 'minus_circle',
916 'minus_circle_fill',
917 'minus_square_fill',
918 );
919
920 switch ($field) {
921 case 'icon_type': {
922 if (in_array($membership_feature['icon'], $yes_icon_types)) {
923 return 'yes';
924 } elseif (in_array($membership_feature['icon'], $no_icon_types)) {
925 return 'no';
926 }
927
928 return null;
929 }
930 }
931
932 return isset($membership_feature[$field]) ? $membership_feature[$field] : null;
933 }
934
935 private static function get_subscription_field_value($subscription, $field, $options)
936 {
937 switch ($field) {
938 case 'sale_price': {
939 return $subscription['sale_price'] !== '0.00';
940 }
941 }
942 return isset($subscription[$field]) ? $subscription[$field] : null;
943 }
944
945 private static function get_membership_plan_field_value($membership_plan, $field)
946 {
947 switch ($field) {
948 case 'enrollment_fee':
949 case 'sale_price': {
950 return $membership_plan[$field] !== '0.00';
951 }
952
953 case 'is_featured':
954 case 'provide_certificate': {
955 return $membership_plan[$field] == '1';
956 }
957
958 case 'trial_value':
959 case 'trial_fee': {
960 if (isset($membership_plan[$field])) {
961 return floatval($membership_plan[$field]);
962 }
963
964 return false;
965 }
966
967 case 'trial_interval': {
968 return $membership_plan['trial_interval'] ?? false;
969 }
970
971 default:
972 return isset($membership_plan[$field]) ? $membership_plan[$field] : null;
973 }
974 }
975
976 private static function get_course_field_value($field, $options)
977 {
978 $course_id = isset($options['post']) ? $options['post']->ID : get_the_ID();
979 switch ($field) {
980 case 'is_paid': {
981 $is_paid_course = tutor_utils()->is_course_purchasable($course_id);
982 return $is_paid_course;
983 }
984 case 'on_sale': {
985 $course_price = tutor_utils()->get_raw_course_price($course_id);
986 return $course_price->sale_price != 0;
987 }
988 case 'is_monetization_enabled': {
989 $monetization = tutor_utils()->get_option('monetize_by', false);
990 return ('free' === $monetization || empty($monetization)) ? false : true;
991 }
992 case 'is_subscription_enabled': {
993 $is_subscription_enabled = tutor_utils()->is_addon_enabled('subscription');
994 return $is_subscription_enabled;
995 }
996 case 'purchase_options': {
997 $selling_option = Course::get_selling_option($course_id);
998 return $selling_option;
999 }
1000
1001 case 'average_rating': {
1002 $average_rating = self::get_course_meta($field, $course_id, $options);
1003 $average_rating = floatval(str_replace(',', '', $average_rating));
1004 return $average_rating;
1005 }
1006 case 'total_ratings':
1007 case 'enroll_count':
1008 case 'resource_count':
1009 case 'lesson_count':
1010 case 'quiz_count':
1011 case 'assignments_count': {
1012 $value = self::get_course_meta($field, $course_id, $options);
1013 return $value;
1014 }
1015 case 'student_state': {
1016 $state = array();
1017 $entry_box_logic = tutor_entry_box_buttons($course_id);
1018 if (is_user_logged_in()) {
1019 $state[] = 'logged_in';
1020 if (tutor_utils()->is_wishlisted($course_id)) {
1021 $state[] = 'wishlisted';
1022 }
1023
1024 if ($entry_box_logic->show_view_cart_btn) {
1025 $state[] = 'added_in_cart';
1026 } elseif (tutor_utils()->is_enrolled($course_id)) {
1027 $state[] = 'enrolled';
1028 }
1029
1030 if ($entry_box_logic->show_continue_learning_btn) {
1031 $state[] = 'learner';
1032 } elseif (tutor_utils()->is_completed_course($course_id)) {
1033 $state[] = 'completed';
1034 }
1035
1036 if ($entry_box_logic->show_retake_course_btn) {
1037 $state[] = 'can_retake';
1038 }
1039 }
1040 return $state;
1041 }
1042 case 'is_review_enabled': {
1043 $review_enabled = (bool) get_tutor_option('enable_course_review');
1044 return $review_enabled;
1045 }
1046 case 'is_qna_enabled': {
1047 $enable_q_and_a_on_course = (bool) get_tutor_option('enable_q_and_a_on_course');
1048 $disable_qa_for_this_course = get_post_meta($course_id, '_tutor_enable_qa', true) != 'yes' ?? false;
1049 return ! (! $enable_q_and_a_on_course || $disable_qa_for_this_course);
1050 }
1051 case 'is_certificate_enabled': {
1052 $addon_config = tutor_utils()->get_addon_config('tutor-pro/addons/tutor-certificate/tutor-certificate.php');
1053 $is_enabled = (bool) tutor_utils()->avalue_dot('is_enable', $addon_config);
1054 if ($is_enabled) {
1055 $has_course_certificate_template = (new Certificate(true))->has_course_certificate_template($course_id);
1056 return $has_course_certificate_template;
1057 }
1058 return false;
1059 }
1060
1061 case 'difficulty_level': {
1062 return get_post_meta($course_id, '_tutor_course_level', true);
1063 }
1064 }
1065 }
1066
1067 private static function get_lms_settings_field_value($field)
1068 {
1069 switch ($field) {
1070 case 'is_membership_only_mode_enabled': {
1071 $is_membership_only_mode_enabled = apply_filters('tutor_membership_only_mode', false);
1072 return $is_membership_only_mode_enabled;
1073 }
1074
1075 case 'enable_spotlight_mode':
1076 case 'display_course_instructors':
1077 case 'enable_wishlist':
1078 case 'enable_q_and_a_on_course':
1079 case 'enable_course_author':
1080 case 'enable_course_level':
1081 case 'enable_course_share':
1082 case 'enable_course_duration':
1083 case 'enable_course_total_enrolled':
1084 case 'enable_course_update_date':
1085 case 'enable_course_progress_bar':
1086 case 'enable_course_material':
1087 case 'enable_course_about':
1088 case 'enable_course_description':
1089 case 'enable_course_benefits':
1090 case 'enable_course_requirements':
1091 case 'enable_course_target_audience':
1092 case 'enable_course_announcements':
1093 case 'enable_course_review': {
1094 $is_enabled = tutor_utils()->get_option($field, false);
1095 return $is_enabled;
1096 }
1097
1098 default: {
1099 return false;
1100 }
1101 }
1102 }
1103 }