complete-course.php
1 year ago
complete-lesson.php
1 year ago
purchase-course.php
1 year ago
quiz-submitted.php
5 months ago
user-achieves-percentage.php
2 years ago
user-enrolled-course.php
1 year ago
user-fails-quiz.php
2 years ago
user-passes-quiz.php
2 years ago
user-posts-question-course.php
2 years ago
user-posts-question-course.php
97 lines
| 1 | <?php |
| 2 | /** |
| 3 | * UserPostsQuestionCourse. |
| 4 | * php version 5.6 |
| 5 | * |
| 6 | * @category UserPostsQuestionCourse |
| 7 | * @package SureTriggers |
| 8 | * @author BSF <username@example.com> |
| 9 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 |
| 10 | * @link https://www.brainstormforce.com/ |
| 11 | * @since 1.0.0 |
| 12 | */ |
| 13 | |
| 14 | namespace SureTriggers\Integrations\TutorLMS\Triggers; |
| 15 | |
| 16 | use SureTriggers\Controllers\AutomationController; |
| 17 | use SureTriggers\Integrations\WordPress\WordPress; |
| 18 | use SureTriggers\Traits\SingletonLoader; |
| 19 | |
| 20 | /** |
| 21 | * UserPostsQuestionCourse |
| 22 | * |
| 23 | * @category UserPostsQuestionCourse |
| 24 | * @package SureTriggers |
| 25 | * @author BSF <username@example.com> |
| 26 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 |
| 27 | * @link https://www.brainstormforce.com/ |
| 28 | * @since 1.0.0 |
| 29 | */ |
| 30 | class UserPostsQuestionCourse { |
| 31 | |
| 32 | /** |
| 33 | * Integration type. |
| 34 | * |
| 35 | * @var string |
| 36 | */ |
| 37 | public $integration = 'TutorLMS'; |
| 38 | |
| 39 | /** |
| 40 | * Trigger name. |
| 41 | * |
| 42 | * @var string |
| 43 | */ |
| 44 | public $trigger = 'tutor_after_asked_question'; |
| 45 | |
| 46 | use SingletonLoader; |
| 47 | |
| 48 | /** |
| 49 | * Constructor |
| 50 | * |
| 51 | * @since 1.0.0 |
| 52 | */ |
| 53 | public function __construct() { |
| 54 | add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Register action. |
| 59 | * |
| 60 | * @param array $triggers trigger data. |
| 61 | * |
| 62 | * @return array |
| 63 | */ |
| 64 | public function register( $triggers ) { |
| 65 | $triggers[ $this->integration ][ $this->trigger ] = [ |
| 66 | 'label' => __( 'User Posts Question in Course', 'suretriggers' ), |
| 67 | 'action' => $this->trigger, |
| 68 | 'function' => [ $this, 'trigger_listener' ], |
| 69 | 'priority' => 10, |
| 70 | 'accepted_args' => 1, |
| 71 | ]; |
| 72 | |
| 73 | return $triggers; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Trigger listener. |
| 78 | * |
| 79 | * @param array $data Data. |
| 80 | * |
| 81 | * @return void |
| 82 | */ |
| 83 | public function trigger_listener( $data ) { |
| 84 | |
| 85 | $context['tutor_course'] = $data['comment_post_ID']; |
| 86 | $context['data'] = $data; |
| 87 | AutomationController::sure_trigger_handle_trigger( |
| 88 | [ |
| 89 | 'trigger' => $this->trigger, |
| 90 | 'context' => $context, |
| 91 | ] |
| 92 | ); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | UserPostsQuestionCourse::get_instance(); |
| 97 |