JezK
Edit File: Tutor.php
<?php /** * Tutor Extension * * @package NotificationX\Extensions */ namespace NotificationXPro\Extensions\Tutor; use NotificationX\Core\Rules; use NotificationX\Extensions\Tutor\Tutor as TutorFree; use NotificationX\Extensions\GlobalFields; use NotificationXPro\Core\Helper; /** * Tutor Extension * @todo frontend filtering. */ class Tutor extends TutorFree { public $post_type = 'courses'; /** * Initially Invoked when initialized. */ public function __construct() { parent::__construct(); } public function init_fields() { parent::init_fields(); add_filter('nx_elearning_course_list', [$this, 'courses']); } public function public_actions(){ parent::public_actions(); add_filter("nx_can_entry_{$this->id}", array($this->get_type(), 'show_purchase_of'), 10, 3); } public function courses($course_list){ $forms = Helper::get_post_titles_by_search($this->post_type); $result = GlobalFields::get_instance()->normalize_fields($forms, 'source', $this->id, $course_list); $result = array_values($result); return $result; } /** * Lists available tags in the selected form. * * @param array $args An array of arguments, including inputValue. * @return array An indexed array of form IDs and titles. */ public function restResponse($args) { // Check if inputValue is provided if (empty($args['inputValue'])) { return []; } // Get the forms that match the inputValue $forms = Helper::get_post_titles_by_search($this->post_type, $args['inputValue']); // Normalize the fields and return as an indexed array return array_values(GlobalFields::get_instance()->normalize_fields($forms, 'source', $this->id)); } }