PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 3.8.2
Tutor LMS – eLearning and online course solution v3.8.2
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 / droip / backend / VisibilityCondition.php
tutor / includes / droip / backend Last commit date
ElementGenerator 9 months ago Ajax.php 10 months ago Backend.php 1 year ago Editor.php 1 year ago Frontend.php 1 year ago Helper.php 9 months ago Hooks.php 9 months ago Iframe.php 1 year ago Pages.php 9 months ago VisibilityCondition.php 9 months ago
VisibilityCondition.php
801 lines
1 <?php
2
3 /**
4 * Preview script for html markup generator
5 *
6 * @package tutor-droip-elements
7 */
8
9 namespace TutorLMSDroip;
10
11 use TUTOR\Course;
12 use Tutor\Models\CartModel;
13 use TutorLMSDroip\ElementGenerator\CourseMetaGenerator;
14
15 if (! defined('ABSPATH')) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Class Helper
21 * This class is used to define all helper functions.
22 */
23 class VisibilityCondition
24 {
25
26 use CourseMetaGenerator;
27
28 public static function visibility_condition_fields($conditions, $collection_data)
29 {
30 $type = $collection_data['type'];
31 $collectionType = $collection_data['collectionType'];
32 if ($collectionType === 'posts') {
33 switch ($type) {
34 case 'courses': {
35 $conditions = self::get_course_type_conditions($conditions);
36 }
37 }
38 } elseif ($collectionType === 'user') {
39 switch ($type) {
40 case 'courses': {
41 $conditions['user'] = array(
42 'title' => 'Instructor',
43 'fields' => array_merge(
44 $conditions['user']['fields'],
45 array(
46 array(
47 'source' => TDE_APP_PREFIX,
48 'value' => 'instructor_course_count',
49 'title' => 'Course Count',
50 'operator_type' => 'numeric_operators',
51 'operand_type' => array_merge(
52 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
53 array(
54 'placeholder' => 'Course Count',
55 )
56 ),
57 ),
58 array(
59 'source' => TDE_APP_PREFIX,
60 'value' => 'instructor_student_count',
61 'title' => 'Student Count',
62 'operator_type' => 'numeric_operators',
63 'operand_type' => array_merge(
64 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
65 array(
66 'placeholder' => 'Student Count',
67 )
68 ),
69 ),
70 array(
71 'source' => TDE_APP_PREFIX,
72 'value' => 'instructor_rating',
73 'title' => 'Rating',
74 'operator_type' => 'numeric_operators',
75 'operand_type' => array_merge(
76 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
77 array(
78 'placeholder' => 'Rating',
79 )
80 ),
81 ),
82 array(
83 'source' => TDE_APP_PREFIX,
84 'value' => 'instructor_rating_count',
85 'title' => 'Rating Count',
86 'operator_type' => 'numeric_operators',
87 'operand_type' => array_merge(
88 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
89 array(
90 'placeholder' => 'Rating Count',
91 )
92 ),
93 ),
94 )
95 ),
96 );
97 }
98 }
99 } else {
100 switch ($type) {
101 case 'TUTOR_LMS-tutor_course_rating': {
102 $conditions = self::get_course_type_conditions($conditions);
103 break;
104 }
105
106 case 'TUTOR_LMS-subscriptions': {
107 $conditions = self::get_subscription_type_conditions($conditions);
108 break;
109 }
110
111 case 'TUTOR_LMS-membership-plans': {
112 $conditions = self::get_membership_type_conditions($conditions);
113 break;
114 }
115
116 case 'TUTOR_LMS-membership-features': {
117 $conditions = self::get_membership_features_type_conditions($conditions);
118 break;
119 }
120 }
121 }
122
123 return $conditions;
124 }
125
126 private static function get_subscription_type_conditions($conditions)
127 {
128 if (!isset($conditions['post']['fields'])) {
129 $conditions['post']['fields'] = array();
130 }
131 $conditions['post'] = array(
132 'title' => 'Subscription',
133 'fields' => array_merge(
134 $conditions['post']['fields'],
135 array(
136
137 // recurring_interval
138 array(
139 'source' => TDE_APP_PREFIX,
140 'value' => 'recurring_interval',
141 'title' => 'Recurring Interval',
142 'operator_type' => 'dropdown_operators',
143 'operand_type' => array_merge(
144 DROIP_PLUGIN_SETTINGS['SELECT'],
145 array(
146 'options' => array(
147 array(
148 'value' => 'day',
149 'title' => 'Day',
150 ),
151 array(
152 'value' => 'week',
153 'title' => 'Week',
154 ),
155 array(
156 'value' => 'month',
157 'title' => 'Month',
158 ),
159 array(
160 'value' => 'year',
161 'title' => 'Year',
162 ),
163 ),
164 ),
165 ),
166 ),
167
168 // enrollment_fee
169 array(
170 'source' => TDE_APP_PREFIX,
171 'value' => 'enrollment_fee',
172 'title' => 'Enrollment Fee',
173 'operator_type' => 'numeric_operators',
174 'operand_type' => array_merge(
175 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
176 array(
177 'placeholder' => 'Enrollment Fee',
178 ),
179 ),
180 ),
181
182 // provide_certificate DEFAULT 1, -- 0 or 1
183 array(
184 'source' => TDE_APP_PREFIX,
185 'value' => 'provide_certificate',
186 'title' => 'Provide Certificate',
187 'operator_type' => 'dropdown_operators',
188 'operand_type' => array_merge(
189 DROIP_PLUGIN_SETTINGS['SELECT'],
190 array(
191 'options' => array(
192 array(
193 'value' => '1',
194 'title' => 'Yes',
195 ),
196 array(
197 'value' => '0',
198 'title' => 'No',
199 ),
200 ),
201 )
202 ),
203 ),
204
205 // is_featured
206 array(
207 'source' => TDE_APP_PREFIX,
208 'value' => 'is_featured',
209 'title' => 'Is Featured',
210 'operator_type' => 'dropdown_operators',
211 'operand_type' => array_merge(
212 DROIP_PLUGIN_SETTINGS['SELECT'],
213 array(
214 'options' => array(
215 array(
216 'value' => '1',
217 'title' => 'Yes',
218 ),
219 array(
220 'value' => '0',
221 'title' => 'No',
222 ),
223 ),
224 ),
225 ),
226 ),
227
228 // sale_price
229 array(
230 'source' => TDE_APP_PREFIX,
231 'value' => 'sale_price',
232 'title' => 'Sale Price',
233 'operator_type' => 'boolean_operators',
234 ),
235 ),
236 ),
237 );
238
239 return $conditions;
240 }
241
242 private static function get_membership_type_conditions($conditions)
243 {
244 if (!isset($conditions['post']['fields'])) {
245 $conditions['post']['fields'] = array();
246 }
247 $conditions['post'] = array(
248 'title' => 'Membership',
249 'fields' => array_merge(
250 $conditions['post']['fields'],
251 array(
252 array(
253 'source' => TDE_APP_PREFIX,
254 'value' => 'recurring_interval',
255 'title' => 'Recurring Interval',
256 'operator_type' => 'dropdown_operators',
257 'operand_type' => array_merge(
258 DROIP_PLUGIN_SETTINGS['SELECT'],
259 array(
260 'options' => array(
261 array(
262 'value' => 'day',
263 'title' => 'Day',
264 ),
265 array(
266 'value' => 'week',
267 'title' => 'Week',
268 ),
269 array(
270 'value' => 'month',
271 'title' => 'Month',
272 ),
273 array(
274 'value' => 'year',
275 'title' => 'Year',
276 ),
277 ),
278 ),
279 ),
280 ),
281
282 // recurring_value
283 array(
284 'source' => TDE_APP_PREFIX,
285 'value' => 'recurring_value',
286 'title' => 'Recurring Value',
287 'operator_type' => 'numeric_operators',
288 'operand_type' => array_merge(
289 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
290 array(
291 'placeholder' => 'Recurring Value',
292 )
293 ),
294 ),
295
296 // enrollment_fee
297 array(
298 'source' => TDE_APP_PREFIX,
299 'value' => 'enrollment_fee',
300 'title' => 'Has enrollment fee',
301 'operator_type' => 'boolean_operators',
302 ),
303
304 // provide_certificate DEFAULT 1, -- 0 or 1
305 array(
306 'source' => TDE_APP_PREFIX,
307 'value' => 'provide_certificate',
308 'title' => 'Provide Certificate',
309 'operator_type' => 'boolean_operators',
310 ),
311
312 // is_featured
313 array(
314 'source' => TDE_APP_PREFIX,
315 'value' => 'is_featured',
316 'title' => 'Is Featured',
317 'operator_type' => 'boolean_operators',
318 ),
319
320 // sale_price
321 array(
322 'source' => TDE_APP_PREFIX,
323 'value' => 'sale_price',
324 'title' => 'Offer sale Price',
325 'operator_type' => 'boolean_operators',
326 ),
327 ),
328 ),
329 );
330
331 return $conditions;
332 }
333
334 private static function get_membership_features_type_conditions($conditions)
335 {
336 if (!isset($conditions['post']['fields'])) {
337 $conditions['post']['fields'] = array();
338 }
339 $conditions['post'] = array(
340 'title' => 'Feature',
341 'fields' => array_merge(
342 $conditions['post']['fields'],
343 array(
344 array(
345 'source' => TDE_APP_PREFIX,
346 'value' => 'icon_type',
347 'title' => 'Icon',
348 'operator_type' => 'dropdown_operators',
349 'operand_type' => array_merge(
350 DROIP_PLUGIN_SETTINGS['SELECT'],
351 array(
352 'options' => array(
353 array(
354 'value' => 'yes',
355 'title' => 'Check',
356 ),
357 array(
358 'value' => 'no',
359 'title' => 'Times',
360 ),
361 ),
362 ),
363 ),
364 ),
365 ),
366 ),
367 );
368
369 return $conditions;
370 }
371
372 private static function get_course_type_conditions($conditions)
373 {
374 if (!isset($conditions['post']['fields'])) {
375 $conditions['post']['fields'] = array();
376 }
377 $conditions['post'] = array(
378 'title' => 'Course',
379 'fields' => array_merge(
380 $conditions['post']['fields'],
381 array(
382 array(
383 'source' => TDE_APP_PREFIX,
384 'value' => 'is_paid',
385 'title' => 'Paid',
386 'operator_type' => 'boolean_operators',
387 ),
388 array(
389 'source' => TDE_APP_PREFIX,
390 'value' => 'on_sale',
391 'title' => 'On Sale',
392 'operator_type' => 'boolean_operators',
393 ),
394 array(
395 'source' => TDE_APP_PREFIX,
396 'value' => 'purchase_options',
397 'title' => 'Purchase Options',
398 'operator_type' => 'dropdown_operators',
399 'operand_type' => array_merge(
400 DROIP_PLUGIN_SETTINGS['SELECT'],
401 array(
402 'options' => array(
403 array(
404 'value' => Course::SELLING_OPTION_ONE_TIME,
405 'title' => 'One Time',
406 ),
407 array(
408 'value' => Course::SELLING_OPTION_SUBSCRIPTION,
409 'title' => 'Subscription',
410 ),
411
412 array(
413 'value' => Course::SELLING_OPTION_BOTH,
414 'title' => 'Subscription & One-Time',
415 ),
416
417 array(
418 'value' => Course::SELLING_OPTION_MEMBERSHIP,
419 'title' => 'Membership',
420 ),
421 array(
422 'value' => Course::SELLING_OPTION_ALL,
423 'title' => 'All',
424 ),
425 ),
426 )
427 ),
428 ),
429 array(
430 'source' => TDE_APP_PREFIX,
431 'value' => 'average_rating',
432 'title' => 'Rating (Avg.)',
433 'operator_type' => 'numeric_operators',
434 'operand_type' => array_merge(
435 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
436 array(
437 'placeholder' => 'Rating',
438 )
439 ),
440 ),
441 array(
442 'source' => TDE_APP_PREFIX,
443 'value' => 'total_ratings',
444 'title' => 'Total Ratings',
445 'operator_type' => 'numeric_operators',
446 'operand_type' => array_merge(
447 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
448 array(
449 'placeholder' => 'Rating count',
450 )
451 ),
452 ),
453 array(
454 'source' => TDE_APP_PREFIX,
455 'value' => 'enroll_count',
456 'title' => 'Enrollment Count',
457 'operator_type' => 'numeric_operators',
458 'operand_type' => array_merge(
459 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
460 array(
461 'placeholder' => 'Enroll Count',
462 )
463 ),
464 ),
465 array(
466 'source' => TDE_APP_PREFIX,
467 'value' => 'student_state',
468 'title' => 'Student status',
469 'operator_type' => array(
470 array(
471 'title' => '= Equals',
472 'value' => 'user_state-is_equal',
473 ),
474 array(
475 'title' => '≠ Does not equal',
476 'value' => 'user_state-not_equal',
477 ),
478 ),
479 'operand_type' => array_merge(
480 DROIP_PLUGIN_SETTINGS['SELECT'],
481 array(
482 'options' => array(
483 array(
484 'value' => 'logged_in',
485 'title' => 'Logged in',
486 ),
487 array(
488 'value' => 'wishlisted',
489 'title' => 'Wishlisted',
490 ),
491 array(
492 'value' => 'added_in_cart',
493 'title' => 'Added in Cart',
494 ),
495 array(
496 'value' => 'enrolled',
497 'title' => 'Enrolled',
498 ),
499 array(
500 'value' => 'learner',
501 'title' => 'Learner',
502 ),
503 array(
504 'value' => 'can_retake',
505 'title' => 'Can Retake',
506 ),
507 array(
508 'value' => 'completed',
509 'title' => 'Completed',
510 ),
511 ),
512 )
513 ),
514 ),
515 // [
516 // 'source' => TDE_APP_PREFIX,
517 // 'value' => 'user_authored',
518 // 'title' => 'User authored',
519 // 'operator_type' => 'dropdown_operators',
520 // 'operand_type' => array_merge(
521 // DROIP_PLUGIN_SETTINGS['SELECT'],
522 // [
523 // 'options' => [
524 // ['value' => 'no_review', 'title' => 'No Review'],
525 // ['value' => 'current_review', 'title' => 'Current Review'],
526 // ['value' => 'no_question', 'title' => 'No Question'],
527 // ['value' => 'current_question', 'title' => 'Current Question'],
528 // ],
529 // ]
530 // ),
531 // ],
532 array(
533 'source' => TDE_APP_PREFIX,
534 'value' => 'resource_count',
535 'title' => 'Resources',
536 'operator_type' => 'numeric_operators',
537 'operand_type' => array_merge(
538 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
539 array(
540 'placeholder' => 'Resource Count',
541 )
542 ),
543 ),
544 array(
545 'source' => TDE_APP_PREFIX,
546 'value' => 'lesson_count',
547 'title' => 'Lessons',
548 'operator_type' => 'numeric_operators',
549 'operand_type' => array_merge(
550 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
551 array(
552 'placeholder' => 'Lesson Count',
553 )
554 ),
555 ),
556 array(
557 'source' => TDE_APP_PREFIX,
558 'value' => 'quiz_count',
559 'title' => 'Quizzes',
560 'operator_type' => 'numeric_operators',
561 'operand_type' => array_merge(
562 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
563 array(
564 'placeholder' => 'Quiz Count',
565 )
566 ),
567 ),
568 array(
569 'source' => TDE_APP_PREFIX,
570 'value' => 'assignments_count',
571 'title' => 'Assignments',
572 'operator_type' => 'numeric_operators',
573 'operand_type' => array_merge(
574 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
575 array(
576 'placeholder' => 'Assignment Count',
577 )
578 ),
579 ),
580 array(
581 'source' => TDE_APP_PREFIX,
582 'value' => 'is_review_enabled',
583 'title' => 'Review Enabled',
584 'operator_type' => 'boolean_operators',
585 ),
586 array(
587 'source' => TDE_APP_PREFIX,
588 'value' => 'is_qna_enabled',
589 'title' => 'QnA Enabled',
590 'operator_type' => 'boolean_operators',
591 ),
592 array(
593 'source' => TDE_APP_PREFIX,
594 'value' => 'is_certificate_enabled',
595 'title' => 'Certificate Enabled',
596 'operator_type' => 'boolean_operators',
597 ),
598 )
599 ),
600 );
601 return $conditions;
602 }
603
604 public static function element_visibility_condition_check($default_value, $condition, $options)
605 {
606 $source = $condition['source'];
607 $field = $condition['field']['value'];
608 $operator = $condition['operator']['value'];
609 $operand = $condition['operand']['value'];
610
611 if (isset($options['TUTOR_LMS-subscriptions'])) {
612 $subscription = (array) $options['TUTOR_LMS-subscriptions'];
613 $fieldValue = self::get_subscription_field_value($subscription, $field, $options);
614 } else if (isset($options['membership-plan'], $options['itemType']) && $options['itemType'] === 'membership-plan') {
615 $membership_plan = (array) $options['membership-plan'];
616 $fieldValue = self::get_membership_plan_field_value($membership_plan, $field);
617 } else if (isset($options['membership-feature'], $options['itemType']) && $options['itemType'] === 'membership-feature') {
618 $membership_feature = (array) $options['membership-feature'];
619 $fieldValue = self::get_membership_feature_field_value($membership_feature, $field);
620 } else {
621 $fieldValue = self::get_course_field_value($field, $options);
622 }
623
624 if ($source === TDE_APP_PREFIX) {
625 switch ($operator) {
626 case 'true': {
627 return (bool) $fieldValue;
628 }
629 case 'false': {
630 return ! $fieldValue;
631 }
632 case 'is_equal': {
633 return $fieldValue == $operand;
634 }
635 case 'not_equal': {
636 return $fieldValue != $operand;
637 }
638 case 'less_than': {
639 return $fieldValue < $operand;
640 }
641 case 'greater_than': {
642 return $fieldValue > $operand;
643 }
644 case 'less_than_or_equal': {
645 return $fieldValue <= $operand;
646 }
647 case 'greater_than_or_equal': {
648 return $fieldValue >= $operand;
649 }
650 case 'user_state-is_equal': {
651 return in_array($operand, $fieldValue);
652 }
653 case 'user_state-not_equal': {
654 return in_array($operand, $fieldValue);
655 }
656 }
657 }
658
659 return $default_value;
660 }
661
662 private static function get_membership_feature_field_value($membership_feature, $field)
663 {
664 $yes_icon_types = array(
665 'tick',
666 'tick_circle',
667 'tick_circle_fill',
668 'plus_square',
669 'plus_circle',
670 'plus_circle_fill',
671 'plus_square_fill',
672 );
673
674 $no_icon_types = array(
675 'cross',
676 'cross_circle',
677 'cross_circle_fill',
678 'minus_square',
679 'minus_circle',
680 'minus_circle_fill',
681 'minus_square_fill',
682 );
683
684 switch ($field) {
685 case 'icon_type': {
686 if (in_array($membership_feature['icon'], $yes_icon_types)) {
687 return 'yes';
688 } elseif (in_array($membership_feature['icon'], $no_icon_types)) {
689 return 'no';
690 }
691
692 return null;
693 }
694 }
695
696 return isset($membership_feature[$field]) ? $membership_feature[$field] : null;
697 }
698
699 private static function get_subscription_field_value($subscription, $field, $options)
700 {
701 switch ($field) {
702 case 'sale_price': {
703 return $subscription['sale_price'] !== '0.00';
704 }
705 }
706 return isset($subscription[$field]) ? $subscription[$field] : null;
707 }
708
709 private static function get_membership_plan_field_value($membership_plan, $field)
710 {
711 switch ($field) {
712 case 'enrollment_fee':
713 case 'sale_price': {
714 return $membership_plan[$field] !== '0.00';
715 }
716
717 case 'is_featured':
718 case 'provide_certificate': {
719 return $membership_plan[$field] == '1';
720 }
721
722 default:
723 return isset($membership_plan[$field]) ? $membership_plan[$field] : null;
724 }
725 }
726
727 private static function get_course_field_value($field, $options)
728 {
729 $course_id = isset($options['post']) ? $options['post']->ID : get_the_ID();
730 switch ($field) {
731 case 'is_paid': {
732 $is_paid_course = tutor_utils()->is_course_purchasable($course_id);
733 return $is_paid_course;
734 }
735 case 'on_sale': {
736 $course_price = tutor_utils()->get_raw_course_price($course_id);
737 return $course_price->sale_price != 0;
738 }
739 case 'purchase_options': {
740 $selling_option = Course::get_selling_option($course_id);
741 return $selling_option;
742 }
743 case 'average_rating': {
744 $average_rating = self::get_course_meta($field, $course_id, $options);
745 $average_rating = floatval(str_replace(',', '', $average_rating));
746 return $average_rating;
747 }
748 case 'total_ratings':
749 case 'enroll_count':
750 case 'resource_count':
751 case 'lesson_count':
752 case 'quiz_count':
753 case 'assignments_count': {
754 $value = self::get_course_meta($field, $course_id, $options);
755 return $value;
756 }
757 case 'student_state': {
758 $state = array();
759 $entry_box_logic = tutor_entry_box_buttons($course_id);
760 if (is_user_logged_in()) {
761 $state[] = 'logged_in';
762 if (tutor_utils()->is_wishlisted($course_id)) {
763 $state[] = 'wishlisted';
764 }
765
766 if ($entry_box_logic->show_view_cart_btn) {
767 $state[] = 'added_in_cart';
768 } elseif (tutor_utils()->is_enrolled($course_id)) {
769 $state[] = 'enrolled';
770 }
771
772 if ($entry_box_logic->show_continue_learning_btn) {
773 $state[] = 'learner';
774 } elseif (tutor_utils()->is_completed_course($course_id)) {
775 $state[] = 'completed';
776 }
777
778 if ($entry_box_logic->show_retake_course_btn) {
779 $state[] = 'can_retake';
780 }
781 }
782 return $state;
783 }
784 case 'is_review_enabled': {
785 $review_enabled = (bool) get_tutor_option('enable_course_review');
786 return $review_enabled;
787 }
788 case 'is_qna_enabled': {
789 $enable_q_and_a_on_course = (bool) get_tutor_option('enable_q_and_a_on_course');
790 $disable_qa_for_this_course = get_post_meta($course_id, '_tutor_enable_qa', true) != 'yes' ?? false;
791 return ! (! $enable_q_and_a_on_course || $disable_qa_for_this_course);
792 }
793 case 'is_certificate_enabled': {
794 $addon_config = tutor_utils()->get_addon_config('tutor-pro/addons/tutor-certificate/tutor-certificate.php');
795 $is_enabled = (bool) tutor_utils()->avalue_dot('is_enable', $addon_config);
796 return $is_enabled;
797 }
798 }
799 }
800 }
801