PluginProbe
Tutor LMS – eLearning and online course solution / 2.5.0
Tutor LMS – eLearning and online course solution v2.5.0
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 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 All 191 releases
← All changes | classes/Rewrite_Rules.php +12 -10 2.4.02.5.0 View file →
@@ -64,23 +64,25 @@
64 64 /**
65 65 * Tutor rewrite rules
66 66 *
67 67 * @since 1.0.0
68 + * @since 2.5.0 Param typecast added.
69 + * Dynamic course permalink support added.
68 70 *
69 - * @param string $wp_rewrite get the rewrite rule.
71 + * @param \WP_Rewrite $wp_rewrite get the rewrite rule.
70 72 *
71 73 * @return void
72 74 */
73 - public function add_rewrite_rules( $wp_rewrite ) {
75 + public function add_rewrite_rules( \WP_Rewrite $wp_rewrite ) {
74 76 $new_rules = array(
75 77 // Lesson Permalink.
76 - $this->course_post_type . "/(.+?)/{$this->lesson_base_permalink}/(.+?)/?$" => "index.php?post_type={$this->lesson_post_type}&name=" . $wp_rewrite->preg_index( 2 ),
78 + $this->course_base_permalink . "/(.+?)/{$this->lesson_base_permalink}/(.+?)/?$" => "index.php?post_type={$this->lesson_post_type}&name=" . $wp_rewrite->preg_index( 2 ),
77 79 // Quiz Permalink.
78 - $this->course_post_type . '/(.+?)/tutor_quiz/(.+?)/?$' => 'index.php?post_type=tutor_quiz&name=' . $wp_rewrite->preg_index( 2 ),
80 + $this->course_base_permalink . '/(.+?)/tutor_quiz/(.+?)/?$' => 'index.php?post_type=tutor_quiz&name=' . $wp_rewrite->preg_index( 2 ),
79 81 // Assignments URL.
80 - $this->course_post_type . '/(.+?)/assignments/(.+?)/?$' => 'index.php?post_type=tutor_assignments&name=' . $wp_rewrite->preg_index( 2 ),
82 + $this->course_base_permalink . '/(.+?)/assignments/(.+?)/?$' => 'index.php?post_type=tutor_assignments&name=' . $wp_rewrite->preg_index( 2 ),
81 83 // Zoom Meeting.
82 - $this->course_post_type . '/(.+?)/zoom-meeting/(.+?)/?$' => 'index.php?post_type=tutor_zoom_meeting&name=' . $wp_rewrite->preg_index( 2 ),
84 + $this->course_base_permalink . '/(.+?)/zoom-meeting/(.+?)/?$' => 'index.php?post_type=tutor_zoom_meeting&name=' . $wp_rewrite->preg_index( 2 ),
83 85
84 86 // Private Video URL.
85 87 'video-url/(.+?)/?$' => "index.php?post_type={$this->lesson_post_type}&lesson_video=true&name=" . $wp_rewrite->preg_index( 1 ),
86 88 // Student Public Profile URL.
@@ -123,11 +125,11 @@
123 125 $course = get_post( $course_id );
124 126 if ( $course ) {
125 127 $course_base_slug = $course->post_name;
126 128 }
127 - return home_url( "/{$this->course_post_type}/{$course_base_slug}/{$this->lesson_base_permalink}/" . $post->post_name . '/' );
129 + return home_url( "/{$this->course_base_permalink}/{$course_base_slug}/{$this->lesson_base_permalink}/" . $post->post_name . '/' );
128 130 } else {
129 - return home_url( "/{$this->course_post_type}/sample-course/{$this->lesson_base_permalink}/" . $post->post_name . '/' );
131 + return home_url( "/{$this->course_base_permalink}/sample-course/{$this->lesson_base_permalink}/" . $post->post_name . '/' );
130 132 }
131 133 } elseif ( is_object( $post ) && 'tutor_quiz' === $post->post_type ) {
132 134 // Quiz Permalink.
133 135 $course = get_post( $post->post_parent );
@@ -141,11 +143,11 @@
141 143 $course = get_post( $course->post_parent );
142 144 }
143 145
144 146 $course_post_name = isset( $course->post_name ) ? $course->post_name : 'sample-course';
145 - return home_url( "/{$this->course_post_type}/{$course_post_name}/tutor_quiz/{$post->post_name}/" );
147 + return home_url( "/{$this->course_base_permalink}/{$course_post_name}/tutor_quiz/{$post->post_name}/" );
146 148 } else {
147 - return home_url( "/{$this->course_post_type}/sample-course/tutor_quiz/{$post->post_name}/" );
149 + return home_url( "/{$this->course_base_permalink}/sample-course/tutor_quiz/{$post->post_name}/" );
148 150 }
149 151 }
150 152 return $post_link;
151 153 }