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