1: <?php
2: if ( ! defined( 'ABSPATH' ) ) exit;
3:
4: 5: 6: 7: 8: 9: 10:
11: class Sensei_Main {
12:
13: 14: 15: 16:
17: private $file;
18:
19: 20: 21: 22:
23: protected static $_instance = null;
24:
25: 26: 27:
28: public $version;
29:
30: 31: 32:
33: public $token = 'woothemes-sensei';
34:
35: 36: 37:
38: public $plugin_url;
39: public $plugin_path;
40: public $template_url;
41:
42: 43: 44: 45: 46:
47: public $post_types;
48:
49: 50: 51:
52: public $settings;
53:
54: 55: 56:
57: public $course_results;
58:
59: 60: 61:
62: public $updates;
63: 64: 65:
66: public $course;
67:
68: 69: 70:
71: public $lesson;
72:
73: 74: 75:
76: public $quiz;
77:
78: 79: 80:
81: public $question;
82:
83: 84: 85:
86: public $admin;
87:
88: 89: 90:
91: public $frontend;
92:
93: 94: 95:
96: public $notices;
97:
98: 99: 100:
101: public $grading;
102:
103: 104: 105:
106: public $emails;
107:
108: 109: 110:
111: public $learner_profiles;
112:
113: 114: 115:
116: public $teacher;
117:
118: 119: 120:
121: public $learners;
122:
123: 124: 125: 126: 127:
128: public $permissions_message;
129:
130: 131: 132:
133: public $modules;
134:
135: 136: 137:
138: public $analysis;
139:
140: 141: 142:
143: private $id;
144:
145: 146: 147: 148: 149:
150: public function __construct ( $file ) {
151:
152:
153: $this->file = $file;
154: $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) );
155: $this->plugin_path = trailingslashit( dirname( $file ) );
156: $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' );
157:
158:
159: $this->init();
160:
161:
162: if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install();
163:
164:
165: register_activation_hook( $this->file, array( $this, 'activation' ) );
166:
167:
168: $this->init_image_sizes();
169:
170:
171: $this->load_hooks();
172:
173: }
174:
175: 176: 177: 178:
179: protected function init(){
180:
181:
182: $this->load_plugin_textdomain();
183: add_action( 'init', array( $this, 'load_localisation' ), 0 );
184:
185:
186: $this->settings = new Sensei_Settings();
187:
188:
189:
190: new Sensei_Shortcode_Loader();
191:
192: }
193:
194: 195: 196: 197: 198: 199: 200: 201: 202: 203:
204: public static function instance() {
205:
206: if ( is_null( self::$_instance ) ) {
207:
208:
209: $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php';
210:
211: self::$_instance = new self( $sensei_main_plugin_file );
212:
213:
214: self::$_instance->initialize_global_objects();
215:
216: }
217:
218: return self::$_instance;
219:
220: }
221:
222: 223: 224: 225: 226: 227: 228: 229:
230: public static function activation_flush_rules( $plugin ){
231:
232: if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){
233:
234: flush_rewrite_rules(true);
235:
236: }
237:
238: }
239:
240: 241: 242: 243:
244: public function __clone() {
245: _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' );
246: }
247:
248: 249: 250: 251:
252: public function __wakeup() {
253: _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' );
254: }
255:
256: 257: 258: 259: 260:
261: public function initialize_global_objects(){
262:
263:
264: $this->post_types = new Sensei_PostTypes();
265:
266:
267: $this->updates = new Sensei_Updates( $this );
268:
269:
270: $this->course_results = new Sensei_Course_Results();
271:
272:
273: $this->teacher = new Sensei_Teacher();
274:
275:
276: $this->course = $this->post_types->course;
277:
278:
279: $this->lesson = $this->post_types->lesson;
280:
281:
282: $this->question = $this->post_types->question;
283:
284:
285: $this->quiz = $this->post_types->quiz;
286:
287:
288: $this->load_modules_class();
289:
290:
291: $this->learners = new Sensei_Learner_Management( $this->file );
292:
293:
294: if ( is_admin() ) {
295:
296:
297: new Sensei_Welcome();
298:
299:
300: $this->admin = new Sensei_Admin( $this->file );
301:
302:
303: $this->analysis = new Sensei_Analysis( $this->file );
304:
305: } else {
306:
307:
308: $this->frontend = new Sensei_Frontend();
309:
310:
311: $this->notices = new Sensei_Notices();
312:
313:
314: new Sensei_Theme_Integration_Loader();
315:
316:
317: }
318:
319:
320: $this->grading = new Sensei_Grading( $this->file );
321:
322:
323: $this->emails = new Sensei_Emails( $this->file );
324:
325:
326: $this->learner_profiles = new Sensei_Learner_Profiles();
327:
328: }
329:
330: 331: 332: 333: 334:
335: public function load_hooks(){
336:
337: add_action( 'widgets_init', array( $this, 'register_widgets' ) );
338: add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) );
339:
340:
341: add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 );
342:
343: add_action( 'body_class', array( $this, 'body_class' ) );
344:
345:
346: add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 );
347:
348:
349: add_action( 'plugins_loaded', array( $this, 'wp_quicklatex_support'), 200 );
350:
351:
352: add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 );
353:
354:
355: add_filter( 'plugin_action_links_' . plugin_basename( $this->file ), array( $this, 'plugin_action_links' ) );
356:
357: }
358:
359: 360: 361: 362: 363: 364:
365: public function run_updates() {
366:
367: if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) {
368:
369: $this->updates->update();
370:
371: }
372: }
373:
374: 375: 376: 377: 378: 379:
380: public function register_widgets () {
381:
382: $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component',
383: 'lesson-component' => 'Lesson_Component',
384: 'course-categories' => 'Course_Categories',
385: 'category-courses' => 'Category_Courses' )
386: );
387: foreach ( $widget_list as $key => $value ) {
388: if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) {
389: require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' );
390: register_widget( 'WooThemes_Sensei_' . $value . '_Widget' );
391: }
392: }
393:
394: do_action( 'sensei_register_widgets' );
395:
396: }
397:
398: 399: 400: 401: 402: 403:
404: public function load_localisation () {
405:
406: load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' );
407:
408: }
409:
410: 411: 412: 413: 414: 415:
416: public function load_plugin_textdomain () {
417:
418: $domain = 'woothemes-sensei';
419:
420: $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
421: load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
422: load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' );
423:
424: }
425:
426: 427: 428: 429: 430: 431:
432: public function activation () {
433:
434: $this->register_plugin_version();
435:
436: }
437:
438:
439: 440: 441: 442: 443: 444:
445: public function install () {
446:
447: register_activation_hook( $this->file, array( $this, 'activate_sensei' ) );
448: register_activation_hook( $this->file, 'flush_rewrite_rules' );
449:
450: }
451:
452:
453: 454: 455: 456: 457: 458:
459: public function activate_sensei () {
460:
461: update_option( 'skip_install_sensei_pages', 0 );
462: update_option( 'sensei_installed', 1 );
463:
464: }
465:
466: 467: 468: 469: 470: 471:
472: private function register_plugin_version () {
473: if ( $this->version != '' ) {
474:
475: update_option( 'woothemes-sensei-version', $this->version );
476:
477: }
478: }
479:
480: 481: 482: 483: 484: 485:
486: public function ensure_post_thumbnails_support () {
487:
488: if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); }
489:
490: }
491:
492: 493: 494: 495: 496: 497: 498: 499:
500: public function template_loader ( $template = '' ) {
501:
502: _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' );
503: Sensei_Templates::template_loader( $template );
504:
505: }
506:
507: 508: 509: 510: 511: 512:
513: public function plugin_path () {
514:
515: if ( $this->plugin_path ) {
516:
517: $sensei_plugin_path = $this->plugin_path;
518:
519: }else{
520:
521: $sensei_plugin_path = plugin_dir_path( __FILE__ );
522:
523: }
524:
525: return $sensei_plugin_path;
526:
527: }
528:
529: 530: 531: 532: 533: 534: 535:
536: public function get_page_id ( $page ) {
537: $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) );
538: return ( $page ) ? $page : -1;
539: }
540:
541: 542: 543: 544: 545: 546: 547: 548:
549: public function check_user_permissions ( $page = '' ) {
550:
551: global $current_user, $post;
552:
553: $user_allowed = false;
554:
555: switch ( $page ) {
556: case 'course-single':
557:
558: $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true );
559: $update_course = Sensei_WC::course_update( $post->ID );
560:
561:
562: if ( 0 < absint( $course_prerequisite_id ) ) {
563:
564: $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID );
565:
566: } else {
567: $prerequisite_complete = true;
568: }
569:
570:
571: if ( ( ! $prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) ) {
572:
573: $user_allowed = false;
574: $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
575: $this->notices->add_notice( sprintf( __( 'Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ), 'info' );
576:
577: } elseif( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $post->ID ) && ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) {
578:
579: $message = sprintf( __( 'Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei' ), '<a href="'.sensei_user_login_url().'">', '</a>' );
580: $this->notices->add_notice( $message, 'info' );
581:
582:
583: } elseif ( ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) {
584:
585:
586: $user_allowed = true;
587:
588:
589:
590: } else {
591:
592: $user_allowed = true;
593:
594: }
595: break;
596: case 'lesson-single':
597:
598: $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true );
599:
600: $update_course = Sensei_WC::course_update( $lesson_course_id );
601: $is_preview = Sensei_Utils::is_preview_lesson( $post->ID );
602:
603: if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) {
604: $user_allowed = true;
605: } elseif( $this->access_settings() && false == $is_preview ) {
606:
607: $user_allowed = true;
608:
609: } else {
610: $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
611: $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
612: $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true );
613: if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
614: if ( $is_preview ) {
615: $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link );
616: } else {
617: $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link );
618: }
619: } else {
620: if ( $is_preview ) {
621: $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link );
622: } else {
623:
624: $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
625: }
626: }
627: }
628: break;
629: case 'quiz-single':
630: $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true );
631: $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true );
632:
633: $update_course = Sensei_WC::course_update( $lesson_course_id );
634: if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) {
635:
636:
637: $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true);
638: $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID);
639:
640:
641: if( sensei_all_access() ) {
642:
643: $user_allowed = true;
644:
645: } else {
646:
647: if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) {
648:
649: $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
650: $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>';
651: $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link );
652:
653: } else {
654:
655: $user_allowed = true;
656:
657: }
658: }
659: } elseif( $this->access_settings() ) {
660:
661:
662: if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) {
663:
664: $user_allowed = false;
665: $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
666: $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
667: $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true );
668: if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
669: $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link );
670: } else {
671: $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link );
672: }
673: } else {
674: $user_allowed = true;
675: }
676: } else {
677: $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
678: $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
679: $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link );
680: }
681: break;
682: default:
683: $user_allowed = true;
684: break;
685:
686: }
687:
688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700:
701: $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID );
702:
703:
704:
705: if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) {
706: $user_allowed = true;
707: }
708:
709: 710: 711: 712: 713: 714: 715: 716: 717: 718:
719: return apply_filters( 'sensei_access_permissions', $user_allowed, $current_user->ID );
720:
721: }
722:
723:
724: 725: 726: 727: 728: 729:
730: public function access_settings () {
731:
732: if( sensei_all_access() ) return true;
733:
734: if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) {
735: if ( is_user_logged_in() ) {
736: return true;
737: } else {
738: return false;
739: }
740: } else {
741: return true;
742: }
743: }
744:
745: 746: 747: 748: 749: 750:
751: public function load_class ( $class_name = '' ) {
752: if ( '' != $class_name && '' != $this->token ) {
753: require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' );
754: }
755: }
756:
757: 758: 759: 760: 761: 762: 763: 764:
765: public function sensei_count_comments( $comments, $post_id ) {
766: global $wpdb;
767:
768: $post_id = (int) $post_id;
769:
770: $count = wp_cache_get("comments-{$post_id}", 'counts');
771:
772: if ( false !== $count ) {
773: return $count;
774: }
775:
776: $statuses = array( '' );
777: $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A );
778: foreach ( (array) $stati AS $status ) {
779: if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) {
780: $statuses[] = $status['comment_type'];
781: }
782: }
783: $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')";
784:
785: if ( $post_id > 0 )
786: $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id );
787:
788: $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
789:
790: $total = 0;
791: $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
792: foreach ( (array) $count as $row ) {
793:
794: if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
795: $total += $row['num_comments'];
796: if ( isset( $approved[$row['comment_approved']] ) )
797: $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
798: }
799:
800: $stats['total_comments'] = $total;
801: foreach ( $approved as $key ) {
802: if ( empty($stats[$key]) )
803: $stats[$key] = 0;
804: }
805:
806: $stats = (object) $stats;
807: wp_cache_set("comments-{$post_id}", $stats, 'counts');
808:
809: return $stats;
810: }
811:
812: 813: 814: 815: 816: 817: 818:
819: public function init_image_sizes() {
820: $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' );
821: $course_single_thumbnail = $this->get_image_size( 'course_single_image' );
822: $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' );
823: $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' );
824:
825: add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] );
826: add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] );
827: add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] );
828: add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] );
829: }
830:
831: 832: 833: 834: 835: 836: 837: 838: 839: 840:
841: public function get_image_size( $image_size ) {
842:
843:
844: if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) )
845: return apply_filters( 'sensei_get_image_size_' . $image_size, '' );
846:
847: if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) {
848: $this->settings->settings[ $image_size . '_width' ] = false;
849: }
850: if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) {
851: $this->settings->settings[ $image_size . '_height' ] = false;
852: }
853: if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) {
854: $this->settings->settings[ $image_size . '_hard_crop' ] = false;
855: }
856:
857: $size = array_filter( array(
858: 'width' => $this->settings->settings[ $image_size . '_width' ],
859: 'height' => $this->settings->settings[ $image_size . '_height' ],
860: 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ]
861: ) );
862:
863: $size['width'] = isset( $size['width'] ) ? $size['width'] : '100';
864: $size['height'] = isset( $size['height'] ) ? $size['height'] : '100';
865: $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0;
866:
867: return apply_filters( 'sensei_get_image_size_' . $image_size, $size );
868: }
869:
870: public function body_class( $classes ) {
871: if( is_sensei() ) {
872: $classes[] = 'sensei';
873: }
874: return $classes;
875: }
876:
877: 878: 879: 880: 881: 882:
883: public function jetpack_latex_support() {
884: if ( function_exists( 'latex_markup') ) {
885: add_filter( 'sensei_question_title', 'latex_markup' );
886: add_filter( 'sensei_answer_text', 'latex_markup' );
887: }
888: }
889:
890: 891: 892: 893: 894:
895: public function wp_quicklatex_support() {
896: if ( function_exists( 'quicklatex_parser') ) {
897: add_filter( 'sensei_question_title', 'quicklatex_parser' );
898: add_filter( 'sensei_answer_text', 'quicklatex_parser' );
899: }
900: }
901:
902: 903: 904: 905: 906: 907: 908: 909:
910: public function load_modules_class(){
911: global $sensei_modules;
912:
913: if( !class_exists( 'Sensei_Modules' )
914: && 'Sensei_Modules' != get_class( $sensei_modules ) ) {
915:
916:
917: require_once( 'class-sensei-modules.php');
918: Sensei()->modules = new Sensei_Core_Modules( $this->file );
919:
920: }else{
921:
922: global $sensei_modules;
923: Sensei()->modules = $sensei_modules;
924: add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 );
925: }
926: }
927:
928: 929: 930: 931: 932:
933: public function disable_sensei_modules_extension(){ ?>
934: <div class="notice updated fade">
935: <p>
936: <?php
937: $plugin_manage_url = admin_url().'plugins.php#sensei-modules';
938: $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> ';
939: ?>
940: <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension.
941: Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules).
942: </p>
943: </div>
944:
945: <?php }
946:
947: 948: 949: 950: 951: 952: 953: 954: 955:
956: public function flush_rewrite_rules(){
957:
958:
959:
960:
961:
962: $option = get_option('sensei_flush_rewrite_rules');
963: if( '1' == $option ) {
964:
965: update_option('sensei_flush_rewrite_rules', '2');
966:
967: }elseif( '2' == $option ) {
968:
969: flush_rewrite_rules();
970: update_option('sensei_flush_rewrite_rules', '0');
971:
972: }
973:
974: }
975:
976: 977: 978: 979: 980: 981:
982: public function initiate_rewrite_rules_flush(){
983:
984: update_option('sensei_flush_rewrite_rules', '1');
985:
986: }
987:
988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998:
999: public function sensei_woocommerce_email_course_details( $order ) {
1000:
1001: Sensei_WC::email_course_details( $order );
1002:
1003: }
1004:
1005: 1006: 1007: 1008: 1009:
1010: public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ){
1011:
1012: Sensei_WC::reactivate_subscription( $user_id, $subscription_key );
1013: }
1014:
1015: 1016: 1017: 1018: 1019:
1020: public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ){
1021:
1022: Sensei_WC::end_subscription( $user_id, $subscription_key );
1023: }
1024:
1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034:
1035: public function sensei_woocommerce_complete_order ( $order_id = 0 ) {
1036:
1037: Sensei_WC::complete_order( $order_id );
1038:
1039: }
1040:
1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049:
1050: public function sensei_woocommerce_cancel_order ( $order_id ) {
1051:
1052: Sensei_WC::cancel_order( $order_id );
1053:
1054: }
1055:
1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063:
1064: public function sensei_activate_subscription( $order_id = 0 ) {
1065:
1066: Sensei_WC::activate_subscription( $order_id );
1067:
1068: }
1069:
1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077:
1078: public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) {
1079:
1080: return Sensei_WC::course_update( $course_id, $order_user );
1081:
1082: }
1083:
1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096:
1097: public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) {
1098:
1099: return Sensei_WC::get_product_object( $wc_product_id, $product_type );
1100:
1101: }
1102:
1103: 1104: 1105: 1106: 1107: 1108:
1109: public function set_woocommerce_functionality() {
1110:
1111: _deprecated_function('Sensei()->set_woocommerce_functionality', 'Sensei 1.9.0');
1112:
1113: }
1114:
1115: 1116: 1117: 1118: 1119: 1120:
1121: public function disable_guest_checkout( $guest_checkout ) {
1122:
1123: return Sensei_WC::disable_guest_checkout( $guest_checkout );
1124:
1125: }
1126:
1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136:
1137: public function virtual_order_payment_complete( $order_status, $order_id ) {
1138:
1139: return Sensei_WC::virtual_order_payment_complete( $order_status, $order_id );
1140: }
1141:
1142: 1143: 1144: 1145: 1146: 1147:
1148: public function plugin_action_links( $actions ) {
1149:
1150: $custom_actions = array();
1151:
1152:
1153: if ( $this->get_settings_link( $this->get_id() ) ) {
1154: $custom_actions['configure'] = $this->get_settings_link( $this->get_id() );
1155: }
1156:
1157:
1158: if ( $this->get_documentation_url() ) {
1159:
1160: $custom_actions['docs'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_documentation_url(), esc_html__( 'Docs', 'woothemes-sensei' ) );
1161: }
1162:
1163:
1164: if ( $this->get_support_url() ) {
1165: $custom_actions['support'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_support_url(), esc_html_x( 'Support', 'noun', 'woothemes-sensei' ) );
1166: }
1167:
1168:
1169: return array_merge( $custom_actions, $actions );
1170: }
1171:
1172: 1173: 1174: 1175: 1176: 1177:
1178: public function get_settings_link( $plugin_id = null ) {
1179: $settings_url = $this->get_settings_url( $plugin_id );
1180: if ( $settings_url ) {
1181: return sprintf( '<a href="%s">%s</a>', $settings_url, esc_html_x( 'Configure', 'plugin action link', 'woothemes-sensei' ) );
1182: }
1183:
1184:
1185: return '';
1186: }
1187:
1188: 1189: 1190: 1191: 1192:
1193: public function get_settings_url( $plugin_id = null ) {
1194: return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' );
1195: }
1196:
1197: 1198: 1199: 1200: 1201:
1202: public function get_documentation_url() {
1203: return sprintf( 'https://docs.woothemes.com/documentation/plugins/sensei/?utm_source=SenseiPlugin&utm_medium=PluginPage&utm_content=Docs&utm_campaign=SenseiPlugin' );
1204: }
1205:
1206: 1207: 1208: 1209: 1210:
1211: public function get_support_url() {
1212: return 'https://www.woothemes.com/my-account/create-a-ticket/?utm_source=SenseiPlugin&utm_medium=PluginPage&utm_content=Support&utm_campaign=SenseiPlugin';
1213: }
1214:
1215: 1216: 1217: 1218: 1219:
1220: public function get_id() {
1221: return $this->id;
1222: }
1223:
1224: 1225: 1226: 1227: 1228:
1229: public function is_general_configuration_page() {
1230: return isset( $_GET['page'] ) && 'woothemes-sensei-settings' == $_GET['page'] && ( ! isset( $_GET['tab'] ) || 'general' == $_GET['tab'] );
1231: }
1232:
1233:
1234: 1235: 1236: 1237: 1238:
1239: public function get_general_configuration_url() {
1240: return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' );
1241: }
1242:
1243: }
1244:
1245: 1246: 1247: 1248: 1249:
1250: class Woothemes_Sensei extends Sensei_Main{ }
1251: