-
Notifications
You must be signed in to change notification settings - Fork 56
/
coursepress.php
5534 lines (4586 loc) · 180 KB
/
coursepress.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: CoursePress Pro
Plugin URI: http://premium.wpmudev.org/project/coursepress/
Description: CoursePress Pro turns WordPress into a powerful online learning platform. Set up online courses by creating learning units with quiz elements, video, audio etc. You can also assess student work, sell your courses and much much more.
Author: WPMU DEV
Author URI: http://premium.wpmudev.org
Developers: Marko Miljus ( https://twitter.com/markomiljus ), Rheinard Korf ( https://twitter.com/rheinardkorf )
Version: 1.2.3.3
TextDomain: cp
Domain Path: /languages/
WDP ID: 913071
License: GNU General Public License ( Version 2 - GPLv2 )
Copyright 2014 Incsub ( http://incsub.com )
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License ( Version 2 - GPLv2 ) as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
/**
* Load the common functions.
*/
require_once( 'includes/functions.php' );
if ( !class_exists( 'CoursePress' ) ) {
/**
* CoursePress plugin setup class.
*
* @package CoursePress
* @since 1.0.0
*/
class CoursePress {
public $mp_file = '198613_marketpress-ecommerce-2.9.5.9.zip';
/**
* Current running instance of CoursePress.
*
* @since 1.0.0
* @access private
* @var object
*/
private static $instance = null;
/**
* Current plugin version.
*
* @since 1.0.0
* @var string
*/
public $version = '1.2.3.3';
/**
* Plugin friendly name.
*
* @since 1.0.0
* @var string
*/
public $name = 'CoursePress Pro';
/**
* Plugin directory name.
*
* @since 1.0.0
* @var string
*/
public $dir_name = 'coursepress';
/**
* Plugin installation location.
*
* Possible values: subfolder-plugins, plugins, mu-plugins
*
* @since 1.0.0
* @var string
*/
public $location = '';
/**
* Plugin installation directory.
*
* @since 1.0.0
* @var string
*/
public $plugin_dir = '';
/**
* Plugin installation url.
*
* @since 1.0.0
* @var string
*/
public $plugin_url = '';
/**
* Is MarketPress active.
*
* MarketPress integration.
*
* @since 1.0.0
* @var bool
*/
public $marketpress_active = false;
/**
* Active MarketPress gateways.
*
* MarketPress integration.
*
* @since 1.0.0
* @var bool
*/
public static $gateway = array();
/**
* Used for naming plugin screens.
*
* Changes depending on CoursePress Pro or CoursePress.
*
* @since 1.2.1
* @var string
*/
public $screen_base = '';
/**
* CoursePress constructor.
*
* @since 1.0.0
* @return self
*/
function __construct() {
// Setup CoursePress properties
$this->init_vars();
/**
* CoursePress Object Class.
*/
require_once( $this->plugin_dir . 'includes/classes/class.coursepress-object.php' );
/**
* CoursePress Capabilities Class.
*/
require_once( $this->plugin_dir . 'includes/classes/class.coursepress-capabilities.php' );
/**
* CoursePress WordPress compatibility hooks.
*/
require_once( $this->plugin_dir . 'includes/classes/class.coursepress-compatibility.php' );
/**
* CoursePress Plugin Integrations.
*/
require_once( $this->plugin_dir . 'includes/classes/class.coursepress-integration.php' );
if ( CoursePress_Capabilities::is_pro() && !CoursePress_Capabilities::is_campus() ) {
// Prepare WPMUDev Dashboard Notifications
global $wpmudev_notices;
$wpmudev_notices[] = array(
'id' => 913071,
'name' => $this->name,
'screens' => array(
'toplevel_page_courses',
$this->screen_base . '_page_course_details',
$this->screen_base . '_page_instructors',
$this->screen_base . '_page_students',
$this->screen_base . '_page_assessment',
$this->screen_base . '_page_reports',
$this->screen_base . '_page_notifications',
$this->screen_base . '_page_settings'
)
);
/**
* Include WPMUDev Dashboard.
*/
include_once( $this->plugin_dir . 'includes/external/dashboard/wpmudev-dash-notification.php' );
}
// Define custom theme directory for CoursePress theme
$this->register_theme_directory();
// Register Globals
$GLOBALS[ 'plugin_dir' ] = $this->plugin_dir;
$GLOBALS[ 'course_slug' ] = $this->get_course_slug();
$GLOBALS[ 'units_slug' ] = $this->get_units_slug();
$GLOBALS[ 'notifications_slug' ] = $this->get_notifications_slug();
$GLOBALS[ 'module_slug' ] = $this->get_module_slug();
$GLOBALS[ 'instructor_profile_slug' ] = $this->get_instructor_profile_slug();
$GLOBALS[ 'enrollment_process_url' ] = $this->get_enrollment_process_slug( true );
$GLOBALS[ 'signup_url' ] = $this->get_signup_slug( true );
// Install Plugin
register_activation_hook( __FILE__, array( $this, 'install' ) );
/**
* @todo: Document this
*/
global $last_inserted_unit_id; //$last_inserted_module_id
global $last_inserted_front_page_module_id; //$last_inserted_module_id
/**
* CampusPress/Edublogs Specifics.
*/
require_once( $this->plugin_dir . 'includes/classes/class.coursepress-campus.php' );
//Administration area
if ( is_admin() ) {
/**
* Course search.
*/
require_once( $this->plugin_dir . 'includes/classes/class.coursesearch.php' );
/**
* Notificatioon search.
*/
require_once( $this->plugin_dir . 'includes/classes/class.notificationsearch.php' );
/**
* Contextual help.
*
* @todo: Finish this class
*/
//require_once( $this->plugin_dir . 'includes/classes/class.help.php' );
/**
* Search Students class.
*/
require_once( $this->plugin_dir . 'includes/classes/class.studentsearch.php' );
/**
* Search Instructor class.
*/
require_once( $this->plugin_dir . 'includes/classes/class.instructorsearch.php' );
/**
* Pagination Class.
*/
require_once( $this->plugin_dir . 'includes/classes/class.pagination.php' );
/**
* Tooltip Helper.
*/
require_once( $this->plugin_dir . 'includes/classes/class.cp-helper-tooltip.php' );
/**
* CoursePress Menu meta box.
*/
require_once( $this->plugin_dir . 'includes/classes/class.menumetabox.php' );
/**
* Add instructor to a course (AJAX).
*
* This also assigns the instructor capabilities.
*
* @since 1.0.0
*/
add_action( 'wp_ajax_add_course_instructor', array( &$this, 'add_course_instructor' ) );
/**
* Remove instructor from a course (AJAX).
*
* If the instructor is no longer an instructor of any courses
* then the instructor's capabilities will also be removed.
*
* @since 1.0.0
*/
add_action( 'wp_ajax_remove_course_instructor', array( &$this, 'remove_course_instructor' ) );
add_action( 'wp_ajax_update_unit', array( &$this, 'update_unit' ) );
/**
* Add instructor MD5 as meta.
*
* Used to conceal instructor ids.
*
* @since 1.2.1
*/
add_action( 'coursepress_course_instructor_added', array( &$this, 'create_instructor_hash' ), 10, 2 );
add_action( 'coursepress_instructor_invite_confirmed', array( &$this, 'create_instructor_hash' ), 10, 2 );
/**
* Update course during setup (AJAX).
*
* This method is executed during setup in the 'Course Overview'.
* Each time the user moved from one section to another or when triggered
* via the 'Update' button.
*
* @since 1.0.0
*/
add_action( 'wp_ajax_autoupdate_course_settings', array( &$this, 'autoupdate_course_settings' ) );
/**
* Determined if a gateway is active (AJAX).
*
* MarketPress integration:
* An active gateway is required to be able to sell a course.
*
* @since 1.0.0
*/
add_action( 'wp_ajax_course_has_gateway', array( &$this, 'course_has_gateway' ) );
/**
* Invite an instructor to join a course (AJAX).
*
* Sends the instructor an email with a confirmation link.
*
* @since 1.0.0
*/
add_action( 'wp_ajax_send_instructor_invite', array( &$this, 'send_instructor_invite' ) );
/**
* Remove instructor invite (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_remove_instructor_invite', array( &$this, 'remove_instructor_invite' ) );
/**
* Change course state (draft/publish) (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_change_course_state', array( &$this, 'change_course_state' ) );
/**
* Change unit state (draft/publish) (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_change_unit_state', array( &$this, 'change_unit_state' ) );
/**
* Update Course Calendar widget/shortcode (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_refresh_course_calendar', array( &$this, 'refresh_course_calendar' ) );
/**
* Update Course Calendar for all visitors (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_nopriv_refresh_course_calendar', array( &$this, 'refresh_course_calendar' ) );
/**
* Handle popup registration/signup forms (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_cp_popup_signup', array( &$this, 'popup_signup' ) );
/**
* Handle popup registration/signup forms for everyone (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_nopriv_cp_popup_signup', array( &$this, 'popup_signup' ) );
/**
* Returns whether the user already exists (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_cp_popup_user_exists', array( &$this, 'cp_popup_user_exists' ) );
/**
* Returns whether the user already exists for everyone (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_nopriv_cp_popup_user_exists', array( &$this, 'cp_popup_user_exists' ) );
/**
* Returns whether the email already exists (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_cp_popup_email_exists', array( &$this, 'cp_popup_email_exists' ) );
/**
* Returns whether the course passcode is valid (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_cp_valid_passcode', array( &$this, 'cp_valid_passcode' ) );
add_action( 'wp_ajax_nopriv_cp_valid_passcode', array( &$this, 'cp_valid_passcode' ) );
/**
* Returns whether the email already exists for everyone (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_nopriv_cp_popup_email_exists', array( &$this, 'cp_popup_email_exists' ) );
/**
* Login the user from the popup (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_cp_popup_login_user', array( &$this, 'cp_popup_login_user' ) );
/**
* Login the user from the popup for everyone (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_nopriv_cp_popup_login_user', array( &$this, 'cp_popup_login_user' ) );
/**
* Get the URL for the next unit in a course (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_get_next_unit_url', array( &$this, 'get_next_unit_url' ) );
/**
* Get the URL for the next unit in a course for everyone (AJAX).
*
* Available to everyone because of the course preview options.
*
* @since 1.0.0
*/
add_action( 'wp_ajax_nopriv_get_next_unit_url', array( &$this, 'get_next_unit_url' ) );
/**
* Create a unit element draft post (AJAX).
*
* Allows the user to preview a unit.
*
* @since 1.0.0
*/
add_action( 'wp_ajax_create_unit_element_draft', array( &$this, 'create_unit_element_draft' ) );
/**
* MarketPress Gateway Settings (AJAX).
*
* Allows access to MarketPress gateways from Course Setup.
*
* @since 1.0.0
*/
add_action( 'mp_gateway_settings', array( &$this, 'cp_marketpress_popup' ) );
/**
* Activate MarketPress or MarketPress Lite (AJAX).
*
* Dependending on whether this is CoursePress or CoursePress Pro.
*
* @since 1.0.0
*/
add_action( 'wp_ajax_cp_activate_mp_lite', array( &$this, 'activate_marketpress_lite' ) );
/**
* Hook WordPress Editor filters and actions.
*
* But do so with WordPress compatibility in mind. Therefore,
* create a new action hook to be used by CoursePress_Compatibility().
*
* @since 1.2.1
*/
do_action( 'coursepress_editor_compatibility' );
/**
* Hook CoursePress admin initialization.
*
* Allows plugins and themes to add additional hooks during CoursePress constructor
* for admin specific actions.
*
* @since 1.2.1
*
*/
do_action( 'coursepress_admin_init' );
/*
* Plugin activation class
*/
require_once($this->plugin_dir . 'includes/classes/class.plugin-activation.php');
}
/**
* Setup payment gateway array.
*
* MarketPress integration.
*
* @since 1.0.0
*/
add_action( 'init', array( $this, 'setup_gateway_array' ) );
/**
* Output buffer workaround
*
* Prevents errors from CoursePress and other plugins or themes
* from breaking AJAX calls.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'output_buffer' ), 0 );
/**
* Is there a version of MarketPress active.
*
* MarketPress integration.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'marketpress_check' ), 0 );
/**
* Class for rendering course calendar.
*/
require_once( $this->plugin_dir . 'includes/classes/class.coursecalendar.php' );
/**
* Class for creating/participating in course discussions.
*/
require_once( $this->plugin_dir . 'includes/classes/class.discussion.php' );
/**
* Class for certificate template
*/
require_once( $this->plugin_dir . 'includes/classes/class.certificate_template.php' );
/**
* Class for certificate templates
*/
require_once( $this->plugin_dir . 'includes/classes/class.certificate_templates.php' );
/**
* Class for certificate template elements
*/
require_once( $this->plugin_dir . 'includes/classes/class.certificate_template_elements.php' );
/**
* Class for certificate templates search
*/
require_once( $this->plugin_dir . 'includes/classes/class.certificate_templates_search.php' );
/**
* Class to search course discussions.
*/
require_once( $this->plugin_dir . 'includes/classes/class.discussionsearch.php' );
/**
* Class for managing instructors.
*/
require_once( $this->plugin_dir . 'includes/classes/class.instructor.php' );
/**
* Class for managing Units.
*/
require_once( $this->plugin_dir . 'includes/classes/class.course.unit.php' );
/**
* The Course class.
*/
require_once( $this->plugin_dir . 'includes/classes/class.course.php' );
/**
* Class to determine course completion.
*/
require_once( $this->plugin_dir . 'includes/classes/class.course.completion.php' );
/**
* Class for creating course or sitewide course notifications.
*/
require_once( $this->plugin_dir . 'includes/classes/class.notification.php' );
/**
* Class to manage students.
*/
require_once( $this->plugin_dir . 'includes/classes/class.student.php' );
/**
* Class to manage unit (page) elements.
*/
require_once( $this->plugin_dir . 'includes/classes/class.course.unit.module.php' );
/**
* Load all unit element classes.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'load_modules' ), 11 );
/**
* Load CoursePress widgets.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'load_widgets' ), 1 );
/**
* Class to handle shortcodes.
*/
require_once( $this->plugin_dir . 'includes/classes/class.shortcodes.php' );
/**
* Class to create virtual pages.
* Does not use existing pages.
*/
require_once( $this->plugin_dir . 'includes/classes/class.virtualpage.php' );
/**
* Register all CoursePress custom post types.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'register_custom_posts' ), 1 );
/**
* Check for forced download in 'File' unit element.
*
* Checks to see if the file needs to be downloaded on click and then
* serve up the file.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'check_for_force_download_file_request' ), 1 );
/**
* Initiate plugin localization.
*
* @since 1.0.0
*/
add_action( 'plugins_loaded', array( &$this, 'localization' ), 9 );
/**
* Handle $_GET actions.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'check_for_get_actions' ), 98 );
/**
* Add virtual pages.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'create_virtual_pages' ), 99 );
/**
* Add custom image sizes.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'add_custom_image_sizes' ) );
/**
* Add custom image sizes to media library.
*
* @todo: decide to keep it or remove it
* @since 1.0.0
*/
//add_filter( 'image_size_names_choose', array( &$this, 'add_custom_media_library_sizes' ) );
/**
* Add plugin menu for network installs.
*
* @since 1.0.0
*/
add_action( 'network_admin_menu', array( &$this, 'add_admin_menu_network' ) );
/**
* Add admin menu.
*
* @since 1.0.0
*/
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
/**
* Check for admin notices.
*
* @since 1.0.0
*/
add_action( 'admin_notices', array( &$this, 'admin_nopermalink_warning' ) );
/**
* Custom header actions.
*
* @since 1.0.0
*/
add_action( 'wp_enqueue_scripts', array( &$this, 'header_actions' ) );
/**
* Custom header actions.
*
* @since 1.0.0
*/
add_action( 'wp_head', array( &$this, 'head_actions' ) );
/**
* Custom footer actions.
*
* @since 1.0.0
*/
add_action( 'wp_footer', array( &$this, 'footer_actions' ) );
/**
* Add jQueryUI.
*
* @todo: decide if we need to keep this hook
* @since 1.0.0
*/
//add_action( 'admin_enqueue_scripts', array( &$this, 'add_jquery_ui' ) );
/**
* Admin header actions.
*
* @since 1.0.0
*/
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_header_actions' ) );
/**
* Load Course Details (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_course_details', array(
&$this,
'admin_coursepress_page_course_details'
) );
/**
* Load CoursePress Settings (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_settings', array(
&$this,
'admin_coursepress_page_settings'
) );
/**
* Load Course Page (admin).
*
* @since 1.0.0
*/
add_action( 'load-toplevel_page_courses', array( &$this, 'admin_coursepress_page_courses' ) );
/**
* Load Course Notifications Page (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_notifications', array(
&$this,
'admin_coursepress_page_notifications'
) );
/**
* Load Course Discussions Page (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_discussions', array(
&$this,
'admin_coursepress_page_discussions'
) );
/**
* Load Course Reports Page (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_reports', array(
&$this,
'admin_coursepress_page_reports'
) );
/**
* Load Course Assessments Page (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_assessment', array(
&$this,
'admin_coursepress_page_assessment'
) );
/**
* Load Course Certificates Page (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_certificates', array(
&$this,
'admin_coursepress_page_certificates'
) );
/**
* Load Course Students Page (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_students', array(
&$this,
'admin_coursepress_page_students'
) );
/**
* Load Course Instructors Page (admin).
*
* @since 1.0.0
*/
add_action( 'load-' . $this->screen_base . '_page_instructors', array(
&$this,
'admin_coursepress_page_instructors'
) );
/**
* Redirect users after login.
*
* @since 1.0.0
*/
add_filter( 'login_redirect', array( &$this, 'login_redirect' ), 10, 3 );
/**
* Check for valid permalinks.
*
* @since 1.0.0
*/
add_filter( 'post_type_link', array( &$this, 'check_for_valid_post_type_permalinks' ), 10, 3 );
/**
* Enable comments for discussions pages.
*
* @since 1.0.0
*/
add_filter( 'comments_open', array( &$this, 'comments_open_filter' ), 10, 2 );
/**
* Remove comments from Virtual Pages.
*
* @since 1.0.0
*/
add_filter( 'comments_template', array( &$this, 'no_comments_template' ) );
/**
* Load CoursePress templates.
*
* @since 1.0.0
*/
add_action( 'wp', array( &$this, 'load_plugin_templates' ) );
/**
* Add CoursePress rewrite rules.
*
* @since 1.0.0
*/
add_filter( 'rewrite_rules_array', array( &$this, 'add_rewrite_rules' ) );
/**
* Prevent Virtual Pages from redirecting.
*
* @since 1.0.0
*/
add_action( 'pre_get_posts', array( &$this, 'remove_canonical' ) );
add_action( 'pre_get_posts', array( &$this, 'course_archive_categories' ) );
add_action( 'pre_get_posts', array( &$this, 'course_archive' ) );
/**
* Filter searches.
*
* @since 1.0.0
*/
add_filter( 'pre_get_posts', array( &$this, 'filter_search' ) );
/**
* Add post type filtering.
*
* @since 1.0.0
*/
add_filter( 'posts_where', array( &$this, 'posts_where' ) );
/**
* Update unit positions of reordering (AJAX).
*
* @since 1.0.0
*/
add_action( 'wp_ajax_update_units_positions', array( $this, 'update_units_positions' ) );
/**
* Update course positions of reordering (AJAX).
*
*/
add_action( 'wp_ajax_update_course_positions', array( $this, 'update_course_positions' ) );
/**
* Apply custom filter to WP query variables (AJAX).
*
* @since 1.0.0
*/
add_filter( 'query_vars', array( $this, 'filter_query_vars' ) );
/**
* Filter 'edit' link for Course post type.
*
* @since 1.0.0
*/
add_filter( 'get_edit_post_link', array( $this, 'courses_edit_post_link' ), 10, 3 );
/**
* Continue parsing requests when WordPress is done.
*
* @since 1.0.0
*/
add_action( 'parse_request', array( $this, 'action_parse_request' ) );
/**
* Redirect to Setup Guide on plugin activation.
*
* @since 1.0.0
*/
add_action( 'admin_init', array( &$this, 'coursepress_plugin_do_activation_redirect' ), 0 );
/**
* Record last student login.
*
* @since 1.0.0
*/
add_action( 'wp_login', array( &$this, 'set_latest_student_activity_upon_login' ), 10, 2 );
/**
* Upgrade legacy instructor meta on login.
*
* @since 1.0.0
*/
add_action( 'init', array( &$this, 'upgrade_instructor_meta' ) );
/**
* Did MarketPress process a successful order.
*
* If MarketPress payment was successful, then enrol the user.
*
* @since 1.0.0
*/
add_action( 'mp_order_paid', array( &$this, 'listen_for_paid_status_for_courses' ) );
/**
* Course taxonomies (not in this version).
*
* @todo: on the roadmap to implement
* @since 1.0.0
*/
add_action( 'parent_file', array( &$this, 'parent_file_correction' ) );
/**
* Update CoursePress login/logout menu item.
*
* @since 1.0.0
*/
add_filter( 'wp_nav_menu_objects', array( &$this, 'menu_metabox_navigation_links' ), 10, 2 );
//add_filter( 'wp_nav_menu_args', array( &$this, 'modify_nav_menu_args' ), 10 );
if ( get_option( 'display_menu_items', 1 ) ) {
/**
* Create CoursePress basic menus automatically.
*
* @since 1.0.0
*/
add_filter( 'wp_nav_menu_objects', array( &$this, 'main_navigation_links' ), 10, 2 );
}
/*
* If allowing CoursePress to create a basic menu then
* make sure that there is somewhere to put it.
*/
if ( get_option( 'display_menu_items', 1 ) ) {
$theme_location = 'primary';
if ( !has_nav_menu( $theme_location ) ) {
$theme_locations = get_nav_menu_locations();
foreach ( (array) $theme_locations as $key => $location ) {