1: <?php
2: if ( ! defined( 'ABSPATH' ) ) exit;
3:
4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14: class Sensei_PostTypes {
15: public $token;
16: public $slider_labels;
17: public $role_caps;
18:
19: 20: 21:
22: public $course;
23:
24: 25: 26:
27: public $lesson;
28:
29: 30: 31:
32: public $question;
33:
34: 35: 36:
37: public $quiz;
38:
39: 40: 41: 42:
43: public function __construct () {
44:
45:
46: $this->labels = array();
47: $this->token = 'woothemes-sensei-posttypes';
48:
49: $this->setup_post_type_labels_base();
50: add_action( 'init', array( $this, 'setup_course_post_type' ), 100 );
51: add_action( 'init', array( $this, 'setup_lesson_post_type' ), 100 );
52: add_action( 'init', array( $this, 'setup_quiz_post_type' ), 100 );
53: add_action( 'init', array( $this, 'setup_question_post_type' ), 100 );
54: add_action( 'init', array( $this, 'setup_multiple_question_post_type' ), 100 );
55: add_action( 'init', array( $this, 'setup_sensei_message_post_type' ), 100 );
56:
57:
58: add_action( 'init', array( $this, 'setup_course_category_taxonomy' ), 100 );
59: add_action( 'init', array( $this, 'setup_quiz_type_taxonomy' ), 100 );
60: add_action( 'init', array( $this, 'setup_question_type_taxonomy' ), 100 );
61: add_action( 'init', array( $this, 'setup_question_category_taxonomy' ), 100 );
62: add_action( 'init', array( $this, 'setup_lesson_tag_taxonomy' ), 100 );
63:
64:
65: $default_post_types = array( 'course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages' ) ;
66: $this->load_posttype_objects( $default_post_types );
67:
68:
69: if ( is_admin() ) {
70: $this->set_role_cap_defaults( $default_post_types );
71: global $pagenow;
72: if ( ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) ) {
73: add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 10 );
74: add_filter( 'post_updated_messages', array( $this, 'setup_post_type_messages' ) );
75: }
76: }
77:
78:
79: add_action( 'admin_bar_menu', array( $this, 'quiz_admin_bar_menu' ), 81 );
80:
81: }
82:
83: 84: 85: 86: 87: 88: 89:
90: public function load_posttype_objects( $posttypes = array() ) {
91:
92: foreach ( $posttypes as $posttype_token => $posttype_name ) {
93:
94:
95: $class_name = 'WooThemes_Sensei_' . $posttype_name;
96: $this->$posttype_token = new $class_name();
97: $this->$posttype_token->token = $posttype_token;
98:
99: }
100:
101: }
102:
103: 104: 105: 106: 107: 108:
109: public function setup_course_post_type () {
110:
111: $args = array(
112: 'labels' => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ),
113: 'public' => true,
114: 'publicly_queryable' => true,
115: 'show_ui' => true,
116: 'show_in_menu' => true,
117: 'show_in_admin_bar' => true,
118: 'query_var' => true,
119: 'rewrite' => array(
120: 'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) ,
121: 'with_front' => true,
122: 'feeds' => true,
123: 'pages' => true
124: ),
125: 'map_meta_cap' => true,
126: 'capability_type' => 'course',
127: 'has_archive' => $this->get_course_post_type_archive_slug(),
128: 'hierarchical' => false,
129: 'menu_position' => 51,
130: 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' )
131: );
132:
133: 134: 135: 136: 137: 138:
139: register_post_type( 'course', apply_filters( 'sensei_register_post_type_course', $args ) );
140:
141: }
142:
143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157:
158: public function get_course_post_type_archive_slug(){
159:
160: $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) );
161:
162:
163:
164: if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){
165:
166: return get_page_uri( $settings_course_page->ID );
167:
168: }else{
169:
170: return 'courses';
171:
172: }
173:
174: }
175:
176: 177: 178: 179: 180: 181: 182: 183: 184: 185:
186: public function has_old_shortcodes( $content ){
187:
188: return ( has_shortcode( $content, 'newcourses')
189: || has_shortcode( $content, 'featuredcourses')
190: || has_shortcode( $content, 'freecourses')
191: || has_shortcode( $content, 'paidcourses') );
192:
193: }
194:
195:
196: 197: 198: 199: 200: 201:
202: public function setup_lesson_post_type () {
203:
204: $supports_array = array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' );
205: $allow_comments = false;
206: if ( isset( Sensei()->settings->settings[ 'lesson_comments' ] ) ) {
207: $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
208: }
209: if ( $allow_comments ) {
210: array_push( $supports_array, 'comments' );
211: }
212:
213: $args = array(
214: 'labels' => $this->create_post_type_labels( $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ),
215: 'public' => true,
216: 'publicly_queryable' => true,
217: 'show_ui' => true,
218: 'show_in_menu' => true,
219: 'query_var' => true,
220: 'rewrite' => array(
221: 'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) ,
222: 'with_front' => true,
223: 'feeds' => true,
224: 'pages' => true
225: ),
226: 'map_meta_cap' => true,
227: 'capability_type' => 'lesson',
228: 'has_archive' => true,
229: 'hierarchical' => false,
230: 'menu_position' => 52,
231: 'supports' => $supports_array
232: );
233:
234: 235: 236: 237: 238: 239:
240: register_post_type( 'lesson', apply_filters( 'sensei_register_post_type_lesson', $args ) );
241:
242: }
243:
244: 245: 246: 247: 248: 249:
250: public function setup_quiz_post_type () {
251:
252: $args = array(
253: 'labels' => $this->create_post_type_labels(
254: $this->labels['quiz']['singular'],
255: $this->labels['quiz']['plural'],
256: $this->labels['quiz']['menu']
257: ),
258: 'public' => true,
259: 'publicly_queryable' => true,
260: 'show_ui' => true,
261: 'show_in_menu' => false,
262: 'show_in_nav_menus' => false,
263: 'query_var' => true,
264: 'exclude_from_search' => true,
265: 'rewrite' => array(
266: 'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) ,
267: 'with_front' => true,
268: 'feeds' => true,
269: 'pages' => true
270: ),
271: 'map_meta_cap' => true,
272: 'capability_type' => 'quiz',
273: 'has_archive' => false,
274: 'hierarchical' => false,
275: 'menu_position' => 20,
276: 'supports' => array( '' )
277: );
278:
279: 280: 281: 282: 283: 284:
285: register_post_type( 'quiz', apply_filters( 'sensei_register_post_type_quiz', $args ) );
286:
287: }
288:
289:
290: 291: 292: 293: 294:
295: public function setup_question_post_type () {
296:
297: $args = array(
298: 'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ),
299: 'public' => false,
300: 'publicly_queryable' => true,
301: 'show_ui' => true,
302: 'show_in_menu' => true,
303: 'show_in_nav_menus' => false,
304: 'query_var' => true,
305: 'exclude_from_search' => true,
306: 'rewrite' => array(
307: 'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
308: 'with_front' => true,
309: 'feeds' => true,
310: 'pages' => true
311: ),
312: 'map_meta_cap' => true,
313: 'capability_type' => 'question',
314: 'has_archive' => true,
315: 'hierarchical' => false,
316: 'menu_position' => 51,
317: 'supports' => array( 'title' )
318: );
319:
320: 321: 322: 323: 324: 325:
326: register_post_type( 'question', apply_filters('sensei_register_post_type_question', $args ) );
327:
328: }
329:
330: 331: 332: 333: 334:
335: public function setup_multiple_question_post_type () {
336:
337: $args = array(
338: 'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ),
339: 'public' => false,
340: 'publicly_queryable' => false,
341: 'show_ui' => false,
342: 'show_in_menu' => false,
343: 'show_in_nav_menus' => false,
344: 'query_var' => false,
345: 'exclude_from_search' => true,
346: 'rewrite' => array(
347: 'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
348: 'with_front' => false,
349: 'feeds' => false,
350: 'pages' => false
351: ),
352: 'map_meta_cap' => true,
353: 'capability_type' => 'question',
354: 'has_archive' => false,
355: 'hierarchical' => false,
356: 'menu_position' => 51,
357: 'supports' => array( 'title', 'custom-fields' )
358: );
359:
360: register_post_type( 'multiple_question', $args );
361: }
362:
363: 364: 365: 366: 367:
368: public function setup_sensei_message_post_type () {
369:
370: if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) {
371:
372: $args = array(
373: 'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ),
374: 'public' => true,
375: 'publicly_queryable' => true,
376: 'show_ui' => true,
377: 'show_in_menu' => 'admin.php?page=sensei',
378: 'show_in_nav_menus' => true,
379: 'query_var' => true,
380: 'exclude_from_search' => true,
381: 'rewrite' => array(
382: 'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) ,
383: 'with_front' => false,
384: 'feeds' => false,
385: 'pages' => true
386: ),
387: 'map_meta_cap' => true,
388: 'capability_type' => 'question',
389: 'has_archive' => true,
390: 'hierarchical' => false,
391: 'menu_position' => 50,
392: 'supports' => array( 'title', 'editor', 'comments' ),
393: );
394:
395: 396: 397: 398: 399: 400:
401: register_post_type( 'sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args ) );
402: }
403: }
404:
405: 406: 407: 408: 409:
410: public function setup_course_category_taxonomy () {
411:
412: $labels = array(
413: 'name' => _x( 'Course Categories', 'taxonomy general name', 'woothemes-sensei' ),
414: 'singular_name' => _x( 'Course Category', 'taxonomy singular name', 'woothemes-sensei' ),
415: 'search_items' => __( 'Search Course Categories', 'woothemes-sensei' ),
416: 'all_items' => __( 'All Course Categories', 'woothemes-sensei' ),
417: 'parent_item' => __( 'Parent Course Category', 'woothemes-sensei' ),
418: 'parent_item_colon' => __( 'Parent Course Category:', 'woothemes-sensei' ),
419: 'edit_item' => __( 'Edit Course Category', 'woothemes-sensei' ),
420: 'update_item' => __( 'Update Course Category', 'woothemes-sensei' ),
421: 'add_new_item' => __( 'Add New Course Category', 'woothemes-sensei' ),
422: 'new_item_name' => __( 'New Course Category Name', 'woothemes-sensei' ),
423: 'menu_name' => __( 'Course Categories', 'woothemes-sensei' ),
424: 'popular_items' => null
425: );
426:
427: $args = array(
428: 'hierarchical' => true,
429: 'labels' => $labels,
430: 'show_ui' => true,
431: 'query_var' => true,
432: 'show_in_nav_menus' => true,
433: 'capabilities' => array(
434: 'manage_terms' => 'manage_categories',
435: 'edit_terms' => 'edit_courses',
436: 'delete_terms' => 'manage_categories',
437: 'assign_terms' => 'edit_courses',),
438: 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_course_category_slug', _x( 'course-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
439: );
440:
441: register_taxonomy( 'course-category', array( 'course' ), $args );
442:
443: }
444:
445: 446: 447: 448: 449:
450: public function setup_quiz_type_taxonomy () {
451:
452:
453: $labels = array(
454: 'name' => _x( 'Quiz Types', 'taxonomy general name', 'woothemes-sensei' ),
455: 'singular_name' => _x( 'Quiz Type', 'taxonomy singular name', 'woothemes-sensei' ),
456: 'search_items' => __( 'Search Quiz Types', 'woothemes-sensei' ),
457: 'all_items' => __( 'All Quiz Types', 'woothemes-sensei' ),
458: 'parent_item' => __( 'Parent Quiz Type', 'woothemes-sensei' ),
459: 'parent_item_colon' => __( 'Parent Quiz Type:', 'woothemes-sensei' ),
460: 'edit_item' => __( 'Edit Quiz Type', 'woothemes-sensei' ),
461: 'update_item' => __( 'Update Quiz Type', 'woothemes-sensei' ),
462: 'add_new_item' => __( 'Add New Quiz Type', 'woothemes-sensei' ),
463: 'new_item_name' => __( 'New Quiz Type Name', 'woothemes-sensei' ),
464: 'menu_name' => __( 'Quiz Types', 'woothemes-sensei' ),
465: 'popular_items' => null
466: );
467:
468: $args = array(
469: 'hierarchical' => false,
470: 'labels' => $labels,
471: 'show_ui' => true,
472: 'query_var' => true,
473: 'show_in_nav_menus' => false,
474: 'public' => false,
475: 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_quiz_type_slug', _x( 'quiz-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
476: );
477:
478: register_taxonomy( 'quiz-type', array( 'quiz' ), $args );
479: }
480:
481: 482: 483: 484: 485:
486: public function setup_question_type_taxonomy () {
487:
488:
489: $labels = array(
490: 'name' => _x( 'Question Types', 'taxonomy general name', 'woothemes-sensei' ),
491: 'singular_name' => _x( 'Question Type', 'taxonomy singular name', 'woothemes-sensei' ),
492: 'search_items' => __( 'Search Question Types', 'woothemes-sensei' ),
493: 'all_items' => __( 'All Question Types', 'woothemes-sensei' ),
494: 'parent_item' => __( 'Parent Question Type', 'woothemes-sensei' ),
495: 'parent_item_colon' => __( 'Parent Question Type:', 'woothemes-sensei' ),
496: 'edit_item' => __( 'Edit Question Type', 'woothemes-sensei' ),
497: 'update_item' => __( 'Update Question Type', 'woothemes-sensei' ),
498: 'add_new_item' => __( 'Add New Question Type', 'woothemes-sensei' ),
499: 'new_item_name' => __( 'New Question Type Name', 'woothemes-sensei' ),
500: 'menu_name' => __( 'Question Types', 'woothemes-sensei' ),
501: 'popular_items' => null
502: );
503:
504: $args = array(
505: 'hierarchical' => false,
506: 'labels' => $labels,
507: 'show_ui' => false,
508: 'public' => false,
509: 'query_var' => false,
510: 'show_in_nav_menus' => false,
511: 'show_admin_column' => true,
512: 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_type_slug', _x( 'question-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
513: );
514:
515: register_taxonomy( 'question-type', array( 'question' ), $args );
516: }
517:
518: 519: 520: 521: 522:
523: public function setup_question_category_taxonomy () {
524:
525: $labels = array(
526: 'name' => _x( 'Question Categories', 'taxonomy general name', 'woothemes-sensei' ),
527: 'singular_name' => _x( 'Question Category', 'taxonomy singular name', 'woothemes-sensei' ),
528: 'search_items' => __( 'Search Question Categories', 'woothemes-sensei' ),
529: 'all_items' => __( 'All Question Categories', 'woothemes-sensei' ),
530: 'parent_item' => __( 'Parent Question Category', 'woothemes-sensei' ),
531: 'parent_item_colon' => __( 'Parent Question Category:', 'woothemes-sensei' ),
532: 'edit_item' => __( 'Edit Question Category', 'woothemes-sensei' ),
533: 'update_item' => __( 'Update Question Category', 'woothemes-sensei' ),
534: 'add_new_item' => __( 'Add New Question Category', 'woothemes-sensei' ),
535: 'new_item_name' => __( 'New Question Category Name', 'woothemes-sensei' ),
536: 'menu_name' => __( 'Categories', 'woothemes-sensei' ),
537: );
538:
539: $args = array(
540: 'hierarchical' => true,
541: 'labels' => $labels,
542: 'show_ui' => true,
543: 'public' => false,
544: 'query_var' => false,
545: 'show_in_nav_menus' => false,
546: 'show_admin_column' => true,
547: 'capabilities' => array(
548: 'manage_terms' => 'manage_categories',
549: 'edit_terms' => 'edit_questions',
550: 'delete_terms' => 'manage_categories',
551: 'assign_terms' => 'edit_questions',),
552: 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_category_slug', _x( 'question-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
553: );
554:
555: register_taxonomy( 'question-category', array( 'question' ), $args );
556: }
557:
558: 559: 560: 561: 562:
563: public function setup_lesson_tag_taxonomy () {
564:
565: $labels = array(
566: 'name' => _x( 'Lesson Tags', 'taxonomy general name', 'woothemes-sensei' ),
567: 'singular_name' => _x( 'Lesson Tag', 'taxonomy singular name', 'woothemes-sensei' ),
568: 'search_items' => __( 'Search Lesson Tags', 'woothemes-sensei' ),
569: 'all_items' => __( 'All Lesson Tags', 'woothemes-sensei' ),
570: 'parent_item' => __( 'Parent Tag', 'woothemes-sensei' ),
571: 'parent_item_colon' => __( 'Parent Tag:', 'woothemes-sensei' ),
572: 'edit_item' => __( 'Edit Lesson Tag', 'woothemes-sensei' ),
573: 'update_item' => __( 'Update Lesson Tag', 'woothemes-sensei' ),
574: 'add_new_item' => __( 'Add New Lesson Tag', 'woothemes-sensei' ),
575: 'new_item_name' => __( 'New Tag Name', 'woothemes-sensei' ),
576: 'menu_name' => __( 'Lesson Tags', 'woothemes-sensei' )
577: );
578:
579: $args = array(
580: 'hierarchical' => false,
581: 'labels' => $labels,
582: 'show_ui' => true,
583: 'query_var' => true,
584: 'show_in_nav_menus' => true,
585: 'capabilities' => array(
586: 'manage_terms' => 'manage_categories',
587: 'edit_terms' => 'edit_lessons',
588: 'delete_terms' => 'manage_categories',
589: 'assign_terms' => 'edit_lessons',),
590: 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_lesson_tag_slug', _x( 'lesson-tag', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
591: );
592:
593: register_taxonomy( 'lesson-tag', array( 'lesson' ), $args );
594: }
595:
596: 597: 598: 599: 600:
601: private function setup_post_type_labels_base () {
602: $this->labels = array( 'course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array() );
603:
604: $this->labels['course'] = array( 'singular' => __( 'Course', 'woothemes-sensei' ), 'plural' => __( 'Courses', 'woothemes-sensei' ), 'menu' => __( 'Courses', 'woothemes-sensei' ) );
605: $this->labels['lesson'] = array( 'singular' => __( 'Lesson', 'woothemes-sensei' ), 'plural' => __( 'Lessons', 'woothemes-sensei' ), 'menu' => __( 'Lessons', 'woothemes-sensei' ) );
606: $this->labels['quiz'] = array( 'singular' => __( 'Quiz', 'woothemes-sensei' ), 'plural' => __( 'Quizzes', 'woothemes-sensei' ), 'menu' => __( 'Quizzes', 'woothemes-sensei' ) );
607: $this->labels['question'] = array( 'singular' => __( 'Question', 'woothemes-sensei' ), 'plural' => __( 'Questions', 'woothemes-sensei' ), 'menu' => __( 'Questions', 'woothemes-sensei' ) );
608: $this->labels['multiple_question'] = array( 'singular' => __( 'Multiple Question', 'woothemes-sensei' ), 'plural' => __( 'Multiple Questions', 'woothemes-sensei' ), 'menu' => __( 'Multiple Questions', 'woothemes-sensei' ) );
609: $this->labels['sensei_message'] = array( 'singular' => __( 'Message', 'woothemes-sensei' ), 'plural' => __( 'Messages', 'woothemes-sensei' ), 'menu' => __( 'Messages', 'woothemes-sensei' ) );
610:
611: }
612:
613: 614: 615: 616: 617: 618: 619: 620:
621: private function create_post_type_labels ( $singular, $plural, $menu ) {
622:
623: $lower_case_plural = function_exists( 'mb_strtolower' ) ? mb_strtolower( $plural, 'UTF-8') : strtolower( $plural );
624:
625: $labels = array(
626: 'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ),
627: 'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ),
628: 'add_new' => __( 'Add New', 'woothemes-sensei' ),
629: 'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ),
630: 'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ),
631: 'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ),
632: 'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ),
633: 'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ),
634: 'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ),
635: 'not_found' => sprintf( __( 'No %s found', 'woothemes-sensei' ), $lower_case_plural ) ,
636: 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ), $lower_case_plural ),
637: 'parent_item_colon' => '',
638: 'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu )
639: );
640:
641: return $labels;
642: }
643:
644: 645: 646: 647: 648: 649:
650: public function setup_post_type_messages ( $messages ) {
651: global $post, $post_ID;
652:
653: $messages['course'] = $this->create_post_type_messages( 'course' );
654: $messages['lesson'] = $this->create_post_type_messages( 'lesson' );
655: $messages['quiz'] = $this->create_post_type_messages( 'quiz' );
656: $messages['question'] = $this->create_post_type_messages( 'question' );
657: $messages['multiple_question'] = $this->create_post_type_messages( 'multiple_question' );
658:
659: return $messages;
660: }
661:
662: 663: 664: 665: 666: 667:
668: private function create_post_type_messages ( $post_type ) {
669: global $post, $post_ID;
670:
671: if ( ! isset( $this->labels[$post_type] ) ) { return array(); }
672:
673: $messages = array(
674: 0 => '',
675: 1 => sprintf( __( '%1$s updated. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ),
676: 2 => __( 'Custom field updated.' , 'woothemes-sensei' ),
677: 3 => __( 'Custom field deleted.' , 'woothemes-sensei' ),
678: 4 => sprintf( __( '%1$s updated.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ),
679: 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
680: 6 => sprintf( __( '%1$s published. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ),
681: 7 => sprintf( __( '%1$s saved.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ),
682: 8 => sprintf( __( '%1$s submitted. %2$sPreview %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', '</a>' ),
683: 9 => sprintf( __( '%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<strong>' . date_i18n( __( 'M j, Y @ G:i' , 'woothemes-sensei' ), strtotime( $post->post_date ) ) . '</strong>', '<a target="_blank" href="' . esc_url( get_permalink( $post_ID ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ),
684: 10 => sprintf( __( '%1$s draft updated. %2$sPreview %3$s%4$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ),
685: );
686:
687: return $messages;
688: }
689:
690: 691: 692: 693: 694: 695: 696:
697: public function enter_title_here ( $title ) {
698: if ( get_post_type() == 'course' ) {
699: $title = __( 'Enter a title for this course here', 'woothemes-sensei' );
700: } elseif ( get_post_type() == 'lesson' ) {
701: $title = __( 'Enter a title for this lesson here', 'woothemes-sensei' );
702: }
703:
704: return $title;
705: }
706:
707: 708: 709: 710: 711: 712: 713: 714:
715: public function set_role_cap_defaults( $post_types = array() ) {
716:
717: foreach ( $post_types as $post_type_item => $post_type_name ) {
718:
719: $this->role_caps[] = array( 'administrator' => array( 'edit_' . $post_type_item,
720: 'read_' . $post_type_item,
721: 'delete_' . $post_type_item,
722: 'create_' . $post_type_item . 's',
723: 'edit_' . $post_type_item . 's',
724: 'edit_others_' . $post_type_item . 's',
725: 'publish_' . $post_type_item . 's',
726: 'read_private_' . $post_type_item . 's',
727: 'read',
728: 'delete_' . $post_type_item . 's',
729: 'delete_private_' . $post_type_item . 's',
730: 'delete_published_' . $post_type_item . 's',
731: 'delete_others_' . $post_type_item . 's',
732: 'edit_private_' . $post_type_item . 's',
733: 'edit_published_' . $post_type_item . 's',
734: 'manage_sensei',
735: 'manage_sensei_grades' ),
736: 'editor' => array( 'edit_' . $post_type_item,
737: 'read_' . $post_type_item,
738: 'delete_' . $post_type_item,
739: 'create_' . $post_type_item . 's',
740: 'edit_' . $post_type_item . 's',
741: 'edit_others_' . $post_type_item . 's',
742: 'publish_' . $post_type_item . 's',
743: 'read_private_' . $post_type_item . 's',
744: 'read',
745: 'delete_' . $post_type_item . 's',
746: 'delete_private_' . $post_type_item . 's',
747: 'delete_published_' . $post_type_item . 's',
748: 'delete_others_' . $post_type_item . 's',
749: 'edit_private_' . $post_type_item . 's',
750: 'edit_published_' . $post_type_item . 's' ),
751: 'author' => array( 'edit_' . $post_type_item,
752: 'read_' . $post_type_item,
753: 'delete_' . $post_type_item,
754: 'create_' . $post_type_item . 's',
755: 'edit_' . $post_type_item . 's',
756: 'publish_' . $post_type_item . 's',
757: 'read',
758: 'delete_' . $post_type_item . 's',
759: 'delete_published_' . $post_type_item . 's',
760: 'edit_published_' . $post_type_item . 's' ),
761: 'contributor' => array( 'edit_' . $post_type_item,
762: 'read_' . $post_type_item,
763: 'delete_' . $post_type_item,
764: 'create_' . $post_type_item . 's',
765: 'edit_' . $post_type_item . 's',
766: 'read',
767: 'delete_' . $post_type_item . 's' ),
768: 'subscriber' => array( 'read' )
769:
770: );
771: }
772:
773: }
774:
775: 776: 777: 778: 779: 780: 781:
782: public function quiz_admin_bar_menu( $bar ) {
783: if ( is_single() && 'quiz' == get_queried_object()->post_type ) {
784: $lesson_id = get_post_meta( get_queried_object()->ID, '_quiz_lesson', true );
785: if ( $lesson_id ) {
786: $object_type = get_post_type_object('quiz');
787: $bar->add_menu( array(
788: 'id' => 'edit',
789: 'title' => $object_type->labels->edit_item,
790: 'href' => get_edit_post_link( $lesson_id ),
791: ) );
792: }
793: }
794: }
795:
796: }
797:
798: 799: 800: 801: 802:
803: class WooThemes_Sensei_PostTypes extends Sensei_PostTypes{}
804: