-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwpsp-class-public.php
executable file
·127 lines (117 loc) · 3.84 KB
/
wpsp-class-public.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
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Public Class
*
* Handles generic Public functionality.
*
* @package WPSchoolPress
* @since 2.0.0
*/
class Wpsp_Public{
public function __construct() {
}
/*
* Redirect user to dashboard
* @package WPSchoolPress
* @since 2.0.0
*/
function wpsp_login_redirect( $redirect_to, $request, $user ) {
global $user;
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( 'administrator', $user->roles ) ) { //check for admins
return $redirect_to; // redirect them to the default place
} else {
return site_url('sch-dashboard');
}
}
return $redirect_to;
}
/*
* redirect to specific page
* @package WPSchoolPress
* @since 2.0.0
*/
function wpsp_page_template( $page_template ) {
if ( is_page( 'sch-dashboard' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-dashboard.php';
}
if ( is_page( 'sch-student' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-student.php';
}
if ( is_page( 'sch-transport' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-transport.php';
}
if ( is_page( 'sch-parent' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-parent.php';
}
if ( is_page( 'sch-class' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-class.php';
}
if ( is_page( 'sch-teacher' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-teacher.php';
}
if ( is_page( 'sch-messages' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-messages.php';
}
if ( is_page( 'sch-profile' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-profile.php';
}
if ( is_page( 'sch-exams' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-exams.php';
}
if ( is_page( 'sch-marks' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-marks.php';
}
if ( is_page( 'sch-attendance' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-attendance.php';
}
if ( is_page( 'sch-timetable' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-timetable.php';
}
if ( is_page( 'sch-reminder' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-reminder.php';
}
if ( is_page( 'sch-events' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-events.php';
}
if ( is_page( 'sch-subject' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-subject.php';
}
if ( is_page( 'sch-settings' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-settings.php';
}
if ( is_page( 'sch-calendar' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-calendar.php';
}
if ( is_page( 'sch-teacherattendance' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-teacher-attendance.php';
}
if ( is_page( 'sch-profile' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-profile.php';
}
if ( is_page( 'sch-notify' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-notify.php';
}
if ( is_page( 'sch-payment' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-paymentdetail.php';
}
if ( is_page( 'sch-importhistory' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-importhistory.php';
}
if ( is_page( 'sch-leavecalendar' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-leavecalendar.php';
}
if ( is_page( 'sch-changepassword' ) ) {
$page_template = dirname( __FILE__ ) . '/pages/wpsp-changepassword.php';
}
return $page_template;
}
function add_hooks() {
//redirect user to dashboard page
add_filter( 'login_redirect', array( $this, 'wpsp_login_redirect' ) , 10, 3 );
//set page template as
add_filter( 'page_template', array( $this, 'wpsp_page_template' ) );
}
}