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.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 / classes / Post_types.php
tutor / classes Last commit date
Addons.php 4 years ago Admin.php 4 years ago Ajax.php 4 years ago Assets.php 4 years ago Course.php 4 years ago Course_Filter.php 4 years ago Course_Settings_Tabs.php 5 years ago Course_Widget.php 5 years ago Custom_Validation.php 5 years ago Dashboard.php 5 years ago Email.php 5 years ago FormHandler.php 5 years ago Frontend.php 5 years ago Gutenberg.php 4 years ago Instructor.php 4 years ago Instructors_List.php 4 years ago Lesson.php 4 years ago Options.php 4 years ago Post_types.php 4 years ago Private_Course_Access.php 5 years ago Q_and_A.php 5 years ago Question_Answers_List.php 4 years ago Quiz.php 4 years ago Quiz_Attempts_List.php 4 years ago RestAPI.php 5 years ago Rewrite_Rules.php 5 years ago Shortcode.php 4 years ago Student.php 5 years ago Students_List.php 4 years ago Taxonomies.php 5 years ago Template.php 4 years ago Theme_Compatibility.php 5 years ago Tools.php 5 years ago Tutor.php 4 years ago TutorEDD.php 5 years ago Tutor_Base.php 5 years ago Tutor_List_Table.php 4 years ago Tutor_Setup.php 4 years ago Upgrader.php 5 years ago User.php 4 years ago Utils.php 4 years ago Video_Stream.php 5 years ago Withdraw.php 5 years ago Withdraw_Requests_List.php 4 years ago WooCommerce.php 4 years ago
Post_types.php
403 lines
1 <?php
2 namespace TUTOR;
3 if ( ! defined( 'ABSPATH' ) )
4 exit;
5
6 class Post_types{
7
8 public $course_post_type;
9 public $lesson_post_type;
10
11 public function __construct() {
12 $this->course_post_type = tutor()->course_post_type;
13 $this->lesson_post_type = tutor()->lesson_post_type;
14
15 add_action( 'init', array($this, 'register_course_post_types') );
16 add_action( 'init', array($this, 'register_lesson_post_types') );
17 add_action( 'init', array($this, 'register_quiz_post_types') );
18 add_action( 'init', array($this, 'register_topic_post_types') );
19 add_action( 'init', array($this, 'register_assignments_post_types') );
20
21 add_filter( 'gutenberg_can_edit_post_type', array( $this, 'gutenberg_can_edit_post_type' ), 10, 2 );
22 add_filter( 'use_block_editor_for_post_type', array( $this, 'gutenberg_can_edit_post_type' ), 10, 2 );
23
24 /**
25 * Customize the message of course
26 */
27 add_filter( 'post_updated_messages', array($this, 'course_updated_messages') );
28
29 /**
30 * Since 1.4.0
31 */
32 add_action( 'init', array($this, 'register_tutor_enrolled_post_types') );
33 }
34
35 public function register_course_post_types() {
36 $course_post_type = $this->course_post_type;
37 $courses_base_slug = apply_filters('tutor_courses_base_slug', $course_post_type);
38
39 $labels = array(
40 'name' => _x( 'Courses', 'post type general name', 'tutor' ),
41 'singular_name' => _x( 'Course', 'post type singular name', 'tutor' ),
42 'menu_name' => _x( 'Courses', 'admin menu', 'tutor' ),
43 'name_admin_bar' => _x( 'Course', 'add new on admin bar', 'tutor' ),
44 'add_new' => _x( 'Add New', 'tutor course add', 'tutor' ),
45 'add_new_item' => __( 'Add New Course', 'tutor' ),
46 'new_item' => __( 'New Course', 'tutor' ),
47 'edit_item' => __( 'Edit Course', 'tutor' ),
48 'view_item' => __( 'View Course', 'tutor' ),
49 'all_items' => __( 'Courses', 'tutor' ),
50 'search_items' => __( 'Search Courses', 'tutor' ),
51 'parent_item_colon' => __( 'Parent Courses:', 'tutor' ),
52 'not_found' => __( 'No courses found.', 'tutor' ),
53 'not_found_in_trash' => __( 'No courses found in Trash.', 'tutor' )
54 );
55
56 $args = array(
57 'labels' => $labels,
58 'description' => __( 'Description.', 'tutor' ),
59 'public' => true,
60 'publicly_queryable' => true,
61 'show_ui' => true,
62 'show_in_menu' => 'tutor',
63 'query_var' => true,
64 'rewrite' => array( 'slug' => $courses_base_slug, 'with_front' => false ),
65 'menu_icon' => 'dashicons-book-alt',
66 'capability_type' => 'post',
67 'has_archive' => true,
68 'hierarchical' => false,
69 'menu_position' => null,
70 'taxonomies' => array( 'course-category', 'course-tag' ),
71 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'author'),
72 'show_in_rest' => true,
73
74 'capabilities' => array(
75 'edit_post' => 'edit_tutor_course',
76 'read_post' => 'read_tutor_course',
77 'delete_post' => 'delete_tutor_course',
78 'delete_posts' => 'delete_tutor_courses',
79 'edit_posts' => 'edit_tutor_courses',
80 'edit_others_posts' => 'edit_others_tutor_courses',
81 'publish_posts' => 'publish_tutor_courses',
82 'read_private_posts' => 'read_private_tutor_courses',
83 'create_posts' => 'edit_tutor_courses',
84 ),
85
86 );
87
88 register_post_type($course_post_type, $args);
89
90 /**
91 * Taxonomy
92 */
93 $labels = array(
94 'name' => _x( 'Course Categories', 'taxonomy general name', 'tutor' ),
95 'singular_name' => _x( 'Category', 'taxonomy singular name', 'tutor' ),
96 'search_items' => __( 'Search Categories', 'tutor' ),
97 'popular_items' => __( 'Popular Categories', 'tutor' ),
98 'all_items' => __( 'All Categories', 'tutor' ),
99 'parent_item' => null,
100 'parent_item_colon' => null,
101 'edit_item' => __( 'Edit Category', 'tutor' ),
102 'update_item' => __( 'Update Category', 'tutor' ),
103 'add_new_item' => __( 'Add New Category', 'tutor' ),
104 'new_item_name' => __( 'New Category Name', 'tutor' ),
105 'separate_items_with_commas' => __( 'Separate categories with commas', 'tutor' ),
106 'add_or_remove_items' => __( 'Add or remove categories', 'tutor' ),
107 'choose_from_most_used' => __( 'Choose from the most used categories', 'tutor' ),
108 'not_found' => __( 'No categories found.', 'tutor' ),
109 'menu_name' => __( 'Course Categories', 'tutor' ),
110 );
111
112 $args = array(
113 'hierarchical' => true,
114 'labels' => $labels,
115 'show_ui' => true,
116 'show_admin_column' => true,
117 'update_count_callback' => '_update_post_term_count',
118 'query_var' => true,
119 'show_in_rest' => true,
120 'rewrite' => array( 'slug' => 'course-category' ),
121 );
122
123 register_taxonomy( 'course-category', $this->course_post_type, $args );
124
125 $labels = array(
126 'name' => _x( 'Tags', 'taxonomy general name', 'tutor' ),
127 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'tutor' ),
128 'search_items' => __( 'Search Tags', 'tutor' ),
129 'popular_items' => __( 'Popular Tags', 'tutor' ),
130 'all_items' => __( 'All Tags', 'tutor' ),
131 'parent_item' => null,
132 'parent_item_colon' => null,
133 'edit_item' => __( 'Edit Tag', 'tutor' ),
134 'update_item' => __( 'Update Tag', 'tutor' ),
135 'add_new_item' => __( 'Add New Tag', 'tutor' ),
136 'new_item_name' => __( 'New Tag Name', 'tutor' ),
137 'separate_items_with_commas' => __( 'Separate Tags with commas', 'tutor' ),
138 'add_or_remove_items' => __( 'Add or remove Tags', 'tutor' ),
139 'choose_from_most_used' => __( 'Choose from the most used Tags', 'tutor' ),
140 'not_found' => __( 'No Tags found.', 'tutor' ),
141 'menu_name' => __( 'Tags', 'tutor' ),
142 );
143
144 $args = array(
145 'hierarchical' => false,
146 'labels' => $labels,
147 'show_ui' => true,
148 'show_admin_column' => true,
149 'update_count_callback' => '_update_post_term_count',
150 'query_var' => true,
151 'show_in_rest' => true,
152 'rewrite' => array( 'slug' => 'course-tag' ),
153 );
154
155 register_taxonomy( 'course-tag', $this->course_post_type, $args );
156 }
157
158 public function register_lesson_post_types() {
159 $lesson_post_type = $this->lesson_post_type;
160 $lesson_base_slug = apply_filters('tutor_lesson_base_slug', $lesson_post_type);
161
162 $labels = array(
163 'name' => _x( 'Lessons', 'post type general name', 'tutor' ),
164 'singular_name' => _x( 'Lesson', 'post type singular name', 'tutor' ),
165 'menu_name' => _x( 'Lessons', 'admin menu', 'tutor' ),
166 'name_admin_bar' => _x( 'Lesson', 'add new on admin bar', 'tutor' ),
167 'add_new' => _x( 'Add New', "tutor lesson add", 'tutor' ),
168 'add_new_item' => __( 'Add New Lesson', 'tutor' ),
169 'new_item' => __( 'New Lesson', 'tutor' ),
170 'edit_item' => __( 'Edit Lesson', 'tutor' ),
171 'view_item' => __( 'View Lesson', 'tutor' ),
172 'all_items' => __( 'Lessons', 'tutor' ),
173 'search_items' => __( 'Search Lessons', 'tutor' ),
174 'parent_item_colon' => __( 'Parent Lessons:', 'tutor' ),
175 'not_found' => __( 'No lessons found.', 'tutor' ),
176 'not_found_in_trash' => __( 'No lessons found in Trash.', 'tutor' )
177 );
178
179 $args = array(
180 'labels' => $labels,
181 'description' => __( 'Description.', 'tutor' ),
182 'public' => true,
183 'publicly_queryable' => true,
184 'show_ui' => true,
185 'show_in_menu' => false,
186 'query_var' => true,
187 'rewrite' => array( 'slug' => $lesson_base_slug ),
188 'menu_icon' => 'dashicons-list-view',
189 'capability_type' => 'post',
190 'has_archive' => true,
191 'hierarchical' => false,
192 'menu_position' => null,
193 'supports' => array( 'title', 'editor'),
194 'exclude_from_search' => apply_filters('tutor_lesson_exclude_from_search', true),
195 'capabilities' => array(
196 'edit_post' => 'edit_tutor_lesson',
197 'read_post' => 'read_tutor_lesson',
198 'delete_post' => 'delete_tutor_lesson',
199 'delete_posts' => 'delete_tutor_lessons',
200 'edit_posts' => 'edit_tutor_lessons',
201 'edit_others_posts' => 'edit_others_tutor_lessons',
202 'publish_posts' => 'publish_tutor_lessons',
203 'read_private_posts' => 'read_private_tutor_lessons',
204 'create_posts' => 'edit_tutor_lessons',
205 ),
206 );
207
208 register_post_type($lesson_post_type, $args );
209 }
210
211 public function register_quiz_post_types() {
212 $labels = array(
213 'name' => _x( 'Quizzes', 'post type general name', 'tutor' ),
214 'singular_name' => _x( 'Quiz', 'post type singular name', 'tutor' ),
215 'menu_name' => _x( 'Quizzes', 'admin menu', 'tutor' ),
216 'name_admin_bar' => _x( 'Quiz', 'add new on admin bar', 'tutor' ),
217 'add_new' => _x( 'Add New', "tutor quiz add", 'tutor' ),
218 'add_new_item' => __( 'Add New Quiz', 'tutor' ),
219 'new_item' => __( 'New Quiz', 'tutor' ),
220 'edit_item' => __( 'Edit Quiz', 'tutor' ),
221 'view_item' => __( 'View Quiz', 'tutor' ),
222 'all_items' => __( 'Quizzes', 'tutor' ),
223 'search_items' => __( 'Search Quizzes', 'tutor' ),
224 'parent_item_colon' => __( 'Parent Quizzes:', 'tutor' ),
225 'not_found' => __( 'No quizzes found.', 'tutor' ),
226 'not_found_in_trash' => __( 'No quizzes found in Trash.', 'tutor' )
227 );
228
229 $args = array(
230 'labels' => $labels,
231 'description' => __( 'Description.', 'tutor' ),
232 'public' => true,
233 'publicly_queryable' => true,
234 'show_ui' => false,
235 'show_in_menu' => 'tutor',
236 'query_var' => true,
237 'rewrite' => array( 'slug' => $this->lesson_post_type ),
238 'menu_icon' => 'dashicons-editor-help',
239 'capability_type' => 'post',
240 'has_archive' => true,
241 'hierarchical' => false,
242 'menu_position' => null,
243 'supports' => array( 'title', 'editor'),
244 'exclude_from_search' => apply_filters('tutor_quiz_exclude_from_search', true),
245 'capabilities' => array(
246 'edit_post' => 'edit_tutor_quiz',
247 'read_post' => 'read_tutor_quiz',
248 'delete_post' => 'delete_tutor_quiz',
249 'delete_posts' => 'delete_tutor_quizzes',
250 'edit_posts' => 'edit_tutor_quizzes',
251 'edit_others_posts' => 'edit_others_tutor_quizzes',
252 'publish_posts' => 'publish_tutor_quizzes',
253 'read_private_posts' => 'read_private_tutor_quizzes',
254 'create_posts' => 'edit_tutor_quizzes',
255 ),
256 );
257
258 register_post_type( 'tutor_quiz', $args );
259 }
260
261 public function register_topic_post_types(){
262 $args = array(
263 'label' => 'Topics',
264 'description' => __( 'Description.', 'tutor' ),
265 'public' => false,
266 'publicly_queryable' => false,
267 'show_ui' => false,
268 'query_var' => false,
269 'has_archive' => false,
270 'hierarchical' => false,
271 'menu_position' => null,
272 );
273 register_post_type( 'topics', $args );
274 }
275
276 public function register_assignments_post_types() {
277 $labels = array(
278 'name' => _x( 'Assignments', 'post type general name', 'tutor' ),
279 'singular_name' => _x( 'Assignment', 'post type singular name', 'tutor' ),
280 'menu_name' => _x( 'Assignments', 'admin menu', 'tutor' ),
281 'name_admin_bar' => _x( 'Assignment', 'add new on admin bar', 'tutor' ),
282 'add_new' => _x( 'Add New', "tutor assignment add", 'tutor' ),
283 'add_new_item' => __( 'Add New Assignment', 'tutor' ),
284 'new_item' => __( 'New Assignment', 'tutor' ),
285 'edit_item' => __( 'Edit Assignment', 'tutor' ),
286 'view_item' => __( 'View Assignment', 'tutor' ),
287 'all_items' => __( 'Assignments', 'tutor' ),
288 'search_items' => __( 'Search Assignments', 'tutor' ),
289 'parent_item_colon' => __( 'Parent Assignments:', 'tutor' ),
290 'not_found' => __( 'No Assignments found.', 'tutor' ),
291 'not_found_in_trash' => __( 'No Assignments found in Trash.', 'tutor' )
292 );
293
294 $args = array(
295 'labels' => $labels,
296 'description' => __( 'Description.', 'tutor' ),
297 'public' => true,
298 'publicly_queryable' => true,
299 'show_ui' => false,
300 'show_in_menu' => 'tutor',
301 'query_var' => true,
302 'rewrite' => array( 'slug' => $this->lesson_post_type ),
303 'menu_icon' => 'dashicons-editor-help',
304 'capability_type' => 'post',
305 'has_archive' => true,
306 'hierarchical' => false,
307 'menu_position' => null,
308 'supports' => array( 'title', 'editor'),
309 'exclude_from_search' => apply_filters('tutor_assignment_exclude_from_search', true),
310 'capabilities' => array(
311 'edit_post' => 'edit_tutor_assignment',
312 'read_post' => 'read_tutor_assignment',
313 'delete_post' => 'delete_tutor_assignment',
314 'delete_posts' => 'delete_tutor_assignments',
315 'edit_posts' => 'edit_tutor_assignments',
316 'edit_others_posts' => 'edit_others_tutor_assignments',
317 'publish_posts' => 'publish_tutor_assignments',
318 'read_private_posts' => 'read_private_tutor_assignments',
319 'create_posts' => 'edit_tutor_assignments',
320 ),
321 );
322
323 register_post_type( 'tutor_assignments', $args );
324 }
325
326 function course_updated_messages( $messages ) {
327 $post = get_post();
328 $post_type = get_post_type( $post );
329 $post_type_object = get_post_type_object( $post_type );
330
331 $course_post_type = tutor()->course_post_type;
332
333 $messages[$course_post_type] = array(
334 0 => '', // Unused. Messages start at index 1.
335 1 => __( 'Course updated.', 'tutor' ),
336 2 => __( 'Custom field updated.', 'tutor' ),
337 3 => __( 'Custom field deleted.', 'tutor' ),
338 4 => __( 'Course updated.', 'tutor' ),
339 /* translators: %s: date and time of the revision */
340 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Course restored to revision from %s', 'tutor' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
341 6 => __( 'Course published.', 'tutor' ),
342 7 => __( 'Course saved.', 'tutor' ),
343 8 => __( 'Course submitted.', 'tutor' ),
344 9 => sprintf(
345 __( 'Course scheduled for: <strong>%1$s</strong>.', 'tutor' ),
346 // translators: Publish box date format, see http://php.net/date
347 date_i18n( __( 'M j, Y @ G:i', 'tutor' ), strtotime( $post->post_date ) )
348 ),
349 10 => __( 'Course draft updated.', 'tutor' )
350 );
351
352 if ( $post_type_object->publicly_queryable && $course_post_type === $post_type ) {
353 $permalink = get_permalink( $post->ID );
354
355 $view_link = sprintf( ' <a href="%s">%s</a>', esc_url( $permalink ), __( 'View course', 'tutor' ) );
356 $messages[ $post_type ][1] .= $view_link;
357 $messages[ $post_type ][6] .= $view_link;
358 $messages[ $post_type ][9] .= $view_link;
359
360 $preview_permalink = add_query_arg( 'preview', 'true', $permalink );
361 $preview_link = sprintf( ' <a target="_blank" href="%s">%s</a>', esc_url( $preview_permalink ), __( 'Preview course', 'tutor' ) );
362 $messages[ $post_type ][8] .= $preview_link;
363 $messages[ $post_type ][10] .= $preview_link;
364 }
365
366 return $messages;
367 }
368
369 /**
370 * @param $can_edit
371 * @param $post_type
372 *
373 * @return bool
374 *
375 * Enable / Disable Gutenberg Editor
376 * @since v.1.3.4
377 */
378 public function gutenberg_can_edit_post_type( $can_edit, $post_type ) {
379 $enable_gutenberg = (bool) tutor_utils()->get_option('enable_gutenberg_course_edit');
380 return $this->course_post_type === $post_type ? $enable_gutenberg : $can_edit;
381 }
382
383 /**
384 * Register tutor_enrolled post type
385 * @since v.1.4.0
386 */
387 public function register_tutor_enrolled_post_types(){
388 $args = array(
389 'label' => 'Tutor Enrolled',
390 'description' => __( 'Description.', 'tutor' ),
391 'public' => false,
392 'publicly_queryable' => false,
393 'show_ui' => false,
394 'query_var' => false,
395 'has_archive' => false,
396 'hierarchical' => false,
397 'menu_position' => null,
398 );
399 register_post_type( 'tutor_enrolled', $args );
400 }
401
402 }
403