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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 7 years ago Admin.php 7 years ago Ajax.php 7 years ago Assets.php 7 years ago Course.php 7 years ago Course_Widget.php 7 years ago Gutenberg.php 7 years ago Instructor.php 7 years ago Instructors_List.php 7 years ago Lesson.php 7 years ago Options.php 7 years ago Post_types.php 7 years ago Q_and_A.php 7 years ago Question.php 7 years ago Question_Answers_List.php 7 years ago Quiz.php 7 years ago Quiz_Attempts_List.php 7 years ago Rewrite_Rules.php 7 years ago Shortcode.php 7 years ago Student.php 7 years ago Students_List.php 7 years ago Taxonomies.php 7 years ago Template.php 7 years ago Theme_Compatibility.php 7 years ago Tools.php 7 years ago Tutor.php 7 years ago TutorEDD.php 7 years ago Tutor_Base.php 7 years ago Tutor_List_Table.php 7 years ago Upgrader.php 7 years ago User.php 7 years ago Utils.php 7 years ago Video_Stream.php 7 years ago Withdraw.php 7 years ago Withdraw_Requests_List.php 7 years ago WooCommerce.php 7 years ago
Post_types.php
302 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
20
21 /**
22 * Customize the message of course
23 */
24 add_filter( 'post_updated_messages', array($this, 'course_updated_messages') );
25 }
26
27 public function register_course_post_types() {
28 $enable_gutenberg = (bool) tutor_utils()->get_option('enable_gutenberg_course_edit');
29
30 $labels = array(
31 'name' => _x( 'Courses', 'post type general name', 'tutor' ),
32 'singular_name' => _x( 'Course', 'post type singular name', 'tutor' ),
33 'menu_name' => _x( 'Courses', 'admin menu', 'tutor' ),
34 'name_admin_bar' => _x( 'Course', 'add new on admin bar', 'tutor' ),
35 'add_new' => _x( 'Add New', $this->course_post_type, 'tutor' ),
36 'add_new_item' => __( 'Add New Course', 'tutor' ),
37 'new_item' => __( 'New Course', 'tutor' ),
38 'edit_item' => __( 'Edit Course', 'tutor' ),
39 'view_item' => __( 'View Course', 'tutor' ),
40 'all_items' => __( 'Courses', 'tutor' ),
41 'search_items' => __( 'Search Courses', 'tutor' ),
42 'parent_item_colon' => __( 'Parent Courses:', 'tutor' ),
43 'not_found' => __( 'No courses found.', 'tutor' ),
44 'not_found_in_trash' => __( 'No courses found in Trash.', 'tutor' )
45 );
46
47 $args = array(
48 'labels' => $labels,
49 'description' => __( 'Description.', 'tutor' ),
50 'public' => true,
51 'publicly_queryable' => true,
52 'show_ui' => true,
53 'show_in_menu' => 'tutor',
54 'query_var' => true,
55 'rewrite' => array( 'slug' => $this->course_post_type ),
56 'menu_icon' => 'dashicons-book-alt',
57 'capability_type' => 'post',
58 'has_archive' => true,
59 'hierarchical' => false,
60 'menu_position' => null,
61 'taxonomies' => array( 'course-category', 'course-tag' ),
62 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt'),
63 'show_in_rest' => $enable_gutenberg,
64
65 'capabilities' => array(
66 'edit_post' => 'edit_tutor_course',
67 'read_post' => 'read_tutor_course',
68 'delete_post' => 'delete_tutor_course',
69 'delete_posts' => 'delete_tutor_courses',
70 'edit_posts' => 'edit_tutor_courses',
71 'edit_others_posts' => 'edit_others_tutor_courses',
72 'publish_posts' => 'publish_tutor_courses',
73 'read_private_posts' => 'read_private_tutor_courses',
74 'create_posts' => 'edit_tutor_courses',
75 ),
76 );
77
78 register_post_type($this->course_post_type, $args);
79
80 /**
81 * Taxonomy
82 */
83 $labels = array(
84 'name' => _x( 'Categories', 'taxonomy general name', 'tutor' ),
85 'singular_name' => _x( 'Category', 'taxonomy singular name', 'tutor' ),
86 'search_items' => __( 'Search Categories', 'tutor' ),
87 'popular_items' => __( 'Popular Categories', 'tutor' ),
88 'all_items' => __( 'All Categories', 'tutor' ),
89 'parent_item' => null,
90 'parent_item_colon' => null,
91 'edit_item' => __( 'Edit Category', 'tutor' ),
92 'update_item' => __( 'Update Category', 'tutor' ),
93 'add_new_item' => __( 'Add New Category', 'tutor' ),
94 'new_item_name' => __( 'New Category Name', 'tutor' ),
95 'separate_items_with_commas' => __( 'Separate categories with commas', 'tutor' ),
96 'add_or_remove_items' => __( 'Add or remove categories', 'tutor' ),
97 'choose_from_most_used' => __( 'Choose from the most used categories', 'tutor' ),
98 'not_found' => __( 'No categories found.', 'tutor' ),
99 'menu_name' => __( 'Categories', 'tutor' ),
100 );
101
102 $args = array(
103 'hierarchical' => true,
104 'labels' => $labels,
105 'show_ui' => true,
106 'show_admin_column' => true,
107 'update_count_callback' => '_update_post_term_count',
108 'query_var' => true,
109 'rewrite' => array( 'slug' => 'course-category' ),
110 );
111
112 register_taxonomy( 'course-category', $this->course_post_type, $args );
113
114 $labels = array(
115 'name' => _x( 'Tags', 'taxonomy general name', 'tutor' ),
116 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'tutor' ),
117 'search_items' => __( 'Search Tags', 'tutor' ),
118 'popular_items' => __( 'Popular Tags', 'tutor' ),
119 'all_items' => __( 'All Tags', 'tutor' ),
120 'parent_item' => null,
121 'parent_item_colon' => null,
122 'edit_item' => __( 'Edit Tag', 'tutor' ),
123 'update_item' => __( 'Update Tag', 'tutor' ),
124 'add_new_item' => __( 'Add New Tag', 'tutor' ),
125 'new_item_name' => __( 'New Tag Name', 'tutor' ),
126 'separate_items_with_commas' => __( 'Separate Tags with commas', 'tutor' ),
127 'add_or_remove_items' => __( 'Add or remove Tags', 'tutor' ),
128 'choose_from_most_used' => __( 'Choose from the most used Tags', 'tutor' ),
129 'not_found' => __( 'No Tags found.', 'tutor' ),
130 'menu_name' => __( 'Tags', 'tutor' ),
131 );
132
133 $args = array(
134 'hierarchical' => false,
135 'labels' => $labels,
136 'show_ui' => true,
137 'show_admin_column' => true,
138 'update_count_callback' => '_update_post_term_count',
139 'query_var' => true,
140 'rewrite' => array( 'slug' => 'course-tag' ),
141 );
142
143 register_taxonomy( 'course-tag', $this->course_post_type, $args );
144 }
145
146 public function register_lesson_post_types() {
147 $labels = array(
148 'name' => _x( 'Lessons', 'post type general name', 'tutor' ),
149 'singular_name' => _x( 'Lesson', 'post type singular name', 'tutor' ),
150 'menu_name' => _x( 'Lessons', 'admin menu', 'tutor' ),
151 'name_admin_bar' => _x( 'Lesson', 'add new on admin bar', 'tutor' ),
152 'add_new' => _x( 'Add New', $this->lesson_post_type, 'tutor' ),
153 'add_new_item' => __( 'Add New Lesson', 'tutor' ),
154 'new_item' => __( 'New Lesson', 'tutor' ),
155 'edit_item' => __( 'Edit Lesson', 'tutor' ),
156 'view_item' => __( 'View Lesson', 'tutor' ),
157 'all_items' => __( 'Lessons', 'tutor' ),
158 'search_items' => __( 'Search Lessons', 'tutor' ),
159 'parent_item_colon' => __( 'Parent Lessons:', 'tutor' ),
160 'not_found' => __( 'No lessons found.', 'tutor' ),
161 'not_found_in_trash' => __( 'No lessons found in Trash.', 'tutor' )
162 );
163
164 $args = array(
165 'labels' => $labels,
166 'description' => __( 'Description.', 'tutor' ),
167 'public' => true,
168 'publicly_queryable' => true,
169 'show_ui' => false,
170 'show_in_menu' => 'tutor',
171 'query_var' => true,
172 'rewrite' => array( 'slug' => $this->lesson_post_type ),
173 'menu_icon' => 'dashicons-list-view',
174 'capability_type' => 'post',
175 'has_archive' => true,
176 'hierarchical' => false,
177 'menu_position' => null,
178 'supports' => array( 'title', 'editor', 'thumbnail'),
179 'capabilities' => array(
180 'edit_post' => 'edit_tutor_lesson',
181 'read_post' => 'read_tutor_lesson',
182 'delete_post' => 'delete_tutor_lesson',
183 'delete_posts' => 'delete_tutor_lessons',
184 'edit_posts' => 'edit_tutor_lessons',
185 'edit_others_posts' => 'edit_others_tutor_lessons',
186 'publish_posts' => 'publish_tutor_lessons',
187 'read_private_posts' => 'read_private_tutor_lessons',
188 'create_posts' => 'edit_tutor_lessons',
189 ),
190 );
191
192 register_post_type( $this->lesson_post_type, $args );
193 }
194
195 public function register_quiz_post_types() {
196 $labels = array(
197 'name' => _x( 'Quizzes', 'post type general name', 'tutor' ),
198 'singular_name' => _x( 'Quiz', 'post type singular name', 'tutor' ),
199 'menu_name' => _x( 'Quizzes', 'admin menu', 'tutor' ),
200 'name_admin_bar' => _x( 'Quiz', 'add new on admin bar', 'tutor' ),
201 'add_new' => _x( 'Add New', $this->lesson_post_type, 'tutor' ),
202 'add_new_item' => __( 'Add New Quiz', 'tutor' ),
203 'new_item' => __( 'New Quiz', 'tutor' ),
204 'edit_item' => __( 'Edit Quiz', 'tutor' ),
205 'view_item' => __( 'View Quiz', 'tutor' ),
206 'all_items' => __( 'Quizzes', 'tutor' ),
207 'search_items' => __( 'Search Quizzes', 'tutor' ),
208 'parent_item_colon' => __( 'Parent Quizzes:', 'tutor' ),
209 'not_found' => __( 'No quizzes found.', 'tutor' ),
210 'not_found_in_trash' => __( 'No quizzes found in Trash.', 'tutor' )
211 );
212
213 $args = array(
214 'labels' => $labels,
215 'description' => __( 'Description.', 'tutor' ),
216 'public' => true,
217 'publicly_queryable' => true,
218 'show_ui' => false,
219 'show_in_menu' => 'tutor',
220 'query_var' => true,
221 'rewrite' => array( 'slug' => $this->lesson_post_type ),
222 'menu_icon' => 'dashicons-editor-help',
223 'capability_type' => 'post',
224 'has_archive' => true,
225 'hierarchical' => false,
226 'menu_position' => null,
227 'supports' => array( 'title', 'editor'),
228 'capabilities' => array(
229 'edit_post' => 'edit_tutor_quiz',
230 'read_post' => 'read_tutor_quiz',
231 'delete_post' => 'delete_tutor_quiz',
232 'delete_posts' => 'delete_tutor_quizzes',
233 'edit_posts' => 'edit_tutor_quizzes',
234 'edit_others_posts' => 'edit_others_tutor_quizzes',
235 'publish_posts' => 'publish_tutor_quizzes',
236 'read_private_posts' => 'read_private_tutor_quizzes',
237 'create_posts' => 'edit_tutor_quizzes',
238 ),
239 );
240
241 register_post_type( 'tutor_quiz', $args );
242 }
243
244 public function register_topic_post_types(){
245 $args = array(
246 'label' => 'Topics',
247 'description' => __( 'Description.', 'tutor' ),
248 'public' => false,
249 'publicly_queryable' => false,
250 'show_ui' => false,
251 'query_var' => false,
252 'has_archive' => false,
253 'hierarchical' => false,
254 'menu_position' => null,
255 );
256 register_post_type( 'topics', $args );
257 }
258
259 function course_updated_messages( $messages ) {
260 $post = get_post();
261 $post_type = get_post_type( $post );
262 $post_type_object = get_post_type_object( $post_type );
263
264 $course_post_type = tutor()->course_post_type;
265
266 $messages[$course_post_type] = array(
267 0 => '', // Unused. Messages start at index 1.
268 1 => __( 'Course updated.', 'tutor' ),
269 2 => __( 'Custom field updated.', 'tutor' ),
270 3 => __( 'Custom field deleted.', 'tutor' ),
271 4 => __( 'Course updated.', 'tutor' ),
272 /* translators: %s: date and time of the revision */
273 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Course restored to revision from %s', 'tutor' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
274 6 => __( 'Course published.', 'tutor' ),
275 7 => __( 'Course saved.', 'tutor' ),
276 8 => __( 'Course submitted.', 'tutor' ),
277 9 => sprintf(
278 __( 'Course scheduled for: <strong>%1$s</strong>.', 'tutor' ),
279 // translators: Publish box date format, see http://php.net/date
280 date_i18n( __( 'M j, Y @ G:i', 'tutor' ), strtotime( $post->post_date ) )
281 ),
282 10 => __( 'Course draft updated.', 'tutor' )
283 );
284
285 if ( $post_type_object->publicly_queryable && $course_post_type === $post_type ) {
286 $permalink = get_permalink( $post->ID );
287
288 $view_link = sprintf( ' <a href="%s">%s</a>', esc_url( $permalink ), __( 'View course', 'tutor' ) );
289 $messages[ $post_type ][1] .= $view_link;
290 $messages[ $post_type ][6] .= $view_link;
291 $messages[ $post_type ][9] .= $view_link;
292
293 $preview_permalink = add_query_arg( 'preview', 'true', $permalink );
294 $preview_link = sprintf( ' <a target="_blank" href="%s">%s</a>', esc_url( $preview_permalink ), __( 'Preview course', 'tutor' ) );
295 $messages[ $post_type ][8] .= $preview_link;
296 $messages[ $post_type ][10] .= $preview_link;
297 }
298
299 return $messages;
300 }
301
302 }