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