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