| @@ -10,10 +10,8 @@ | ||
| 10 | 10 | |
| 11 | 11 | namespace TUTOR; |
| 12 | 12 | |
| 13 | 13 | use Tutor\Cache\TutorCache; |
| 14 | -use Tutor\Models\CourseModel; | |
| 15 | -use Tutor\Models\EnrollmentModel; | |
| 16 | 14 | |
| 17 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | 16 | exit; |
| 19 | 17 | } |
| @@ -22,9 +20,9 @@ | ||
| 22 | 20 | * Register Tutor's post types |
| 23 | 21 | * |
| 24 | 22 | * @since 1.0.0 |
| 25 | 23 | */ |
| 26 | -class Private_Course_Access extends Tutor_Base { | |
| 24 | +class Private_Course_Access { | |
| 27 | 25 | |
| 28 | 26 | /** |
| 29 | 27 | * Allow empty |
| 30 | 28 | * |
| @@ -37,12 +35,9 @@ | ||
| 37 | 35 | * |
| 38 | 36 | * @since 1.0.0 |
| 39 | 37 | */ |
| 40 | 38 | public function __construct() { |
| 41 | - parent::__construct(); | |
| 42 | - | |
| 43 | 39 | add_action( 'pre_get_posts', array( $this, 'enable_private_access' ) ); |
| 44 | - add_filter( 'post_type_link', array( $this, 'permalink_for_private_course' ), 10, 2 ); | |
| 45 | 40 | } |
| 46 | 41 | |
| 47 | 42 | /** |
| 48 | 43 | * Enable private course access |
| @@ -89,29 +84,11 @@ | ||
| 89 | 84 | } |
| 90 | 85 | |
| 91 | 86 | $private_course_id = ( is_array( $result ) && isset( $result[0] ) ) ? $result[0]->ID : 0; |
| 92 | 87 | |
| 93 | - if ( $private_course_id > 0 && EnrollmentModel::is_enrolled( $private_course_id ) ) { | |
| 88 | + if ( $private_course_id > 0 && tutor_utils()->is_enrolled( $private_course_id ) ) { | |
| 94 | 89 | $this->allow_empty = true; |
| 95 | 90 | $query->set( 'post_status', array( 'private', 'publish' ) ); |
| 96 | 91 | } |
| 97 | 92 | } |
| 98 | - } | |
| 99 | - | |
| 100 | - /** | |
| 101 | - * Make permalink for private course. | |
| 102 | - * | |
| 103 | - * @since 3.0.0 | |
| 104 | - * | |
| 105 | - * @param string $url permalink. | |
| 106 | - * @param WP_Post $post post object. | |
| 107 | - * | |
| 108 | - * @return string | |
| 109 | - */ | |
| 110 | - public function permalink_for_private_course( $url, $post ) { | |
| 111 | - if ( CourseModel::STATUS_PRIVATE === $post->post_status && $this->course_post_type === $post->post_type ) { | |
| 112 | - $url = home_url( $this->course_base_permalink . '/' . $post->post_name ); | |
| 113 | - } | |
| 114 | - | |
| 115 | - return $url; | |
| 116 | 93 | } |
| 117 | 94 | } |