PluginProbe
Tutor LMS – eLearning and online course solution / 1.0.7
Tutor LMS – eLearning and online course solution v1.0.7
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
tutor / classes / Post_types.php

Post_types.php in Tutor LMS – eLearning and online course solution 1.0.7, at classes/Post_types.php

234 lines 9.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 public function register_course_post_types() {
21 $labels = array(
22 'name' => _x( 'Courses', 'post type general name', 'tutor' ),
23 'singular_name' => _x( 'Course', 'post type singular name', 'tutor' ),
24 'menu_name' => _x( 'Courses', 'admin menu', 'tutor' ),
25 'name_admin_bar' => _x( 'Course', 'add new on admin bar', 'tutor' ),
26 'add_new' => _x( 'Add New', $this->course_post_type, 'tutor' ),
27 'add_new_item' => __( 'Add New Course', 'tutor' ),
28 'new_item' => __( 'New Course', 'tutor' ),
29 'edit_item' => __( 'Edit Course', 'tutor' ),
30 'view_item' => __( 'View Course', 'tutor' ),
31 'all_items' => __( 'Courses', 'tutor' ),
32 'search_items' => __( 'Search Courses', 'tutor' ),
33 'parent_item_colon' => __( 'Parent Courses:', 'tutor' ),
34 'not_found' => __( 'No courses found.', 'tutor' ),
35 'not_found_in_trash' => __( 'No courses found in Trash.', 'tutor' )
36 );
37
38 $args = array(
39 'labels' => $labels,
40 'description' => __( 'Description.', 'tutor' ),
41 'public' => true,
42 'publicly_queryable' => true,
43 'show_ui' => true,
44 'show_in_menu' => 'tutor',
45 'query_var' => true,
46 'rewrite' => array( 'slug' => $this->course_post_type ),
47 'menu_icon' => 'dashicons-book-alt',
48 'capability_type' => 'post',
49 'has_archive' => true,
50 'hierarchical' => false,
51 'menu_position' => null,
52 'taxonomies' => array( 'course-category', 'course-tag' ),
53 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt'),
54
55 'capabilities' => array(
56 'edit_post' => 'edit_tutor_course',
57 'read_post' => 'read_tutor_course',
58 'delete_post' => 'delete_tutor_course',
59 'delete_posts' => 'delete_tutor_courses',
60 'edit_posts' => 'edit_tutor_courses',
61 'edit_others_posts' => 'edit_others_tutor_courses',
62 'publish_posts' => 'publish_tutor_courses',
63 'read_private_posts' => 'read_private_tutor_courses',
64 'create_posts' => 'edit_tutor_courses',
65 ),
66 );
67
68 register_post_type($this->course_post_type, $args);
69
70 /**
71 * Taxonomy
72 */
73 $labels = array(
74 'name' => _x( 'Categories', 'taxonomy general name', 'tutor' ),
75 'singular_name' => _x( 'Category', 'taxonomy singular name', 'tutor' ),
76 'search_items' => __( 'Search Categories', 'tutor' ),
77 'popular_items' => __( 'Popular Categories', 'tutor' ),
78 'all_items' => __( 'All Categories', 'tutor' ),
79 'parent_item' => null,
80 'parent_item_colon' => null,
81 'edit_item' => __( 'Edit Category', 'tutor' ),
82 'update_item' => __( 'Update Category', 'tutor' ),
83 'add_new_item' => __( 'Add New Category', 'tutor' ),
84 'new_item_name' => __( 'New Category Name', 'tutor' ),
85 'separate_items_with_commas' => __( 'Separate categories with commas', 'tutor' ),
86 'add_or_remove_items' => __( 'Add or remove categories', 'tutor' ),
87 'choose_from_most_used' => __( 'Choose from the most used categories', 'tutor' ),
88 'not_found' => __( 'No categories found.', 'tutor' ),
89 'menu_name' => __( 'Categories', 'tutor' ),
90 );
91
92 $args = array(
93 'hierarchical' => true,
94 'labels' => $labels,
95 'show_ui' => true,
96 'show_admin_column' => true,
97 'update_count_callback' => '_update_post_term_count',
98 'query_var' => true,
99 'rewrite' => array( 'slug' => 'course-category' ),
100 );
101
102 register_taxonomy( 'course-category', $this->course_post_type, $args );
103
104 $labels = array(
105 'name' => _x( 'Skills', 'taxonomy general name', 'tutor' ),
106 'singular_name' => _x( 'Skill', 'taxonomy singular name', 'tutor' ),
107 'search_items' => __( 'Search Skills', 'tutor' ),
108 'popular_items' => __( 'Popular Skills', 'tutor' ),
109 'all_items' => __( 'All Skills', 'tutor' ),
110 'parent_item' => null,
111 'parent_item_colon' => null,
112 'edit_item' => __( 'Edit Skill', 'tutor' ),
113 'update_item' => __( 'Update Skill', 'tutor' ),
114 'add_new_item' => __( 'Add New Skill', 'tutor' ),
115 'new_item_name' => __( 'New Skill Name', 'tutor' ),
116 'separate_items_with_commas' => __( 'Separate skills with commas', 'tutor' ),
117 'add_or_remove_items' => __( 'Add or remove skills', 'tutor' ),
118 'choose_from_most_used' => __( 'Choose from the most used skills', 'tutor' ),
119 'not_found' => __( 'No skills found.', 'tutor' ),
120 'menu_name' => __( 'Skills', 'tutor' ),
121 );
122
123 $args = array(
124 'hierarchical' => false,
125 'labels' => $labels,
126 'show_ui' => true,
127 'show_admin_column' => true,
128 'update_count_callback' => '_update_post_term_count',
129 'query_var' => true,
130 'rewrite' => array( 'slug' => 'course-tag' ),
131 );
132
133 register_taxonomy( 'course-tag', $this->course_post_type, $args );
134 }
135
136 public function register_lesson_post_types() {
137 $labels = array(
138 'name' => _x( 'Lessons', 'post type general name', 'tutor' ),
139 'singular_name' => _x( 'Lesson', 'post type singular name', 'tutor' ),
140 'menu_name' => _x( 'Lessons', 'admin menu', 'tutor' ),
141 'name_admin_bar' => _x( 'Lesson', 'add new on admin bar', 'tutor' ),
142 'add_new' => _x( 'Add New', $this->lesson_post_type, 'tutor' ),
143 'add_new_item' => __( 'Add New Lesson', 'tutor' ),
144 'new_item' => __( 'New Lesson', 'tutor' ),
145 'edit_item' => __( 'Edit Lesson', 'tutor' ),
146 'view_item' => __( 'View Lesson', 'tutor' ),
147 'all_items' => __( 'Lessons', 'tutor' ),
148 'search_items' => __( 'Search Lessons', 'tutor' ),
149 'parent_item_colon' => __( 'Parent Lessons:', 'tutor' ),
150 'not_found' => __( 'No lessons found.', 'tutor' ),
151 'not_found_in_trash' => __( 'No lessons found in Trash.', 'tutor' )
152 );
153
154 $args = array(
155 'labels' => $labels,
156 'description' => __( 'Description.', 'tutor' ),
157 'public' => true,
158 'publicly_queryable' => true,
159 'show_ui' => false,
160 'show_in_menu' => 'tutor',
161 'query_var' => true,
162 'rewrite' => array( 'slug' => $this->lesson_post_type ),
163 'menu_icon' => 'dashicons-list-view',
164 'capability_type' => 'post',
165 'has_archive' => true,
166 'hierarchical' => false,
167 'menu_position' => null,
168 'supports' => array( 'title', 'editor', 'thumbnail'),
169 'capabilities' => array(
170 'edit_post' => 'edit_tutor_lesson',
171 'read_post' => 'read_tutor_lesson',
172 'delete_post' => 'delete_tutor_lesson',
173 'delete_posts' => 'delete_tutor_lessons',
174 'edit_posts' => 'edit_tutor_lessons',
175 'edit_others_posts' => 'edit_others_tutor_lessons',
176 'publish_posts' => 'publish_tutor_lessons',
177 'read_private_posts' => 'read_private_tutor_lessons',
178 'create_posts' => 'edit_tutor_lessons',
179 ),
180 );
181
182 register_post_type( $this->lesson_post_type, $args );
183 }
184
185 public function register_quiz_post_types() {
186 $labels = array(
187 'name' => _x( 'Quizzes', 'post type general name', 'tutor' ),
188 'singular_name' => _x( 'Quiz', 'post type singular name', 'tutor' ),
189 'menu_name' => _x( 'Quizzes', 'admin menu', 'tutor' ),
190 'name_admin_bar' => _x( 'Quiz', 'add new on admin bar', 'tutor' ),
191 'add_new' => _x( 'Add New', $this->lesson_post_type, 'tutor' ),
192 'add_new_item' => __( 'Add New Quiz', 'tutor' ),
193 'new_item' => __( 'New Quiz', 'tutor' ),
194 'edit_item' => __( 'Edit Quiz', 'tutor' ),
195 'view_item' => __( 'View Quiz', 'tutor' ),
196 'all_items' => __( 'Quizzes', 'tutor' ),
197 'search_items' => __( 'Search Quizzes', 'tutor' ),
198 'parent_item_colon' => __( 'Parent Quizzes:', 'tutor' ),
199 'not_found' => __( 'No quizzes found.', 'tutor' ),
200 'not_found_in_trash' => __( 'No quizzes found in Trash.', 'tutor' )
201 );
202
203 $args = array(
204 'labels' => $labels,
205 'description' => __( 'Description.', 'tutor' ),
206 'public' => true,
207 'publicly_queryable' => true,
208 'show_ui' => false,
209 'show_in_menu' => 'tutor',
210 'query_var' => true,
211 'rewrite' => array( 'slug' => $this->lesson_post_type ),
212 'menu_icon' => 'dashicons-editor-help',
213 'capability_type' => 'post',
214 'has_archive' => true,
215 'hierarchical' => false,
216 'menu_position' => null,
217 'supports' => array( 'title', 'editor'),
218 'capabilities' => array(
219 'edit_post' => 'edit_tutor_quiz',
220 'read_post' => 'read_tutor_quiz',
221 'delete_post' => 'delete_tutor_quiz',
222 'delete_posts' => 'delete_tutor_quizzes',
223 'edit_posts' => 'edit_tutor_quizzes',
224 'edit_others_posts' => 'edit_others_tutor_quizzes',
225 'publish_posts' => 'publish_tutor_quizzes',
226 'read_private_posts' => 'read_private_tutor_quizzes',
227 'create_posts' => 'edit_tutor_quizzes',
228 ),
229 );
230
231 register_post_type( 'tutor_quiz', $args );
232 }
233
234 }