PluginProbe
School Management System – WPSchoolPress / 2.2.43
School Management System – WPSchoolPress v2.2.43
2.2.48 2.2.47 2.2.46 2.2.45 2.2.44 2.2.43 2.2.42 2.2.41 2.2.40 2.2.39 2.2.38 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 All 103 releases
wpschoolpress / wpschoolpress.php

wpschoolpress.php in School Management System – WPSchoolPress 2.2.43, at wpschoolpress.php

246 lines 10.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WPSchoolPress
4 Plugin URI: http://wpschoolpress.com
5 Description: WPSchoolpress is a school management system plugin that makes school activities transparent to parents. For more information please visit our website.
6 Version: 2.2.43
7 Author: WPSchoolPress Team
8 Author URI: wpschoolpress.com
9 Text Domain: wpschoolpress
10 Domain Path: languages
11 @package WPSchoolPress
12 */
13 // Exit if accessed directly
14 if (!defined('ABSPATH')) exit;
15 /**
16 * Basic plugin definitions
17 *
18 * @package WPSchoolPress
19 * @since 2.2.43
20 */
21 if (!defined('WPSP_PLUGIN_URL'))
22 {
23 define('WPSP_PLUGIN_URL', plugin_dir_url(__FILE__));
24 }
25 if (!defined('WPSP_PLUGIN_PATH'))
26 {
27 define('WPSP_PLUGIN_PATH', plugin_dir_path(__FILE__));
28 }
29 if (!defined('WPSP_PLUGIN_VERSION'))
30 {
31 define('WPSP_PLUGIN_VERSION', '2.2.43'); //Plugin version number
32 }
33 define('WPSP_PERMISSION_MSG', 'You don\'t have enough permission to access this page');
34 // Call the required files when plugin activate
35 register_activation_hook(__FILE__, 'wpsp_activation');
36 function wpsp_activation()
37 {
38 include_once (WPSP_PLUGIN_PATH . 'lib/wpsp-activation.php');
39 }
40 register_deactivation_hook( __FILE__, 'wpsp_deactivation');
41 function wpsp_deactivation()
42 {
43 include_once (WPSP_PLUGIN_PATH . 'lib/wpsp-deactivation.php');
44 }
45 // add action to load plugin
46 add_action('plugins_loaded', 'wpsp_plugins_loaded');
47
48 function wpsp_plugins_loaded()
49 {
50 $wpsp_lang_dir = dirname(plugin_basename(__FILE__)) . '/languages/';
51 load_plugin_textdomain('wpschoolpress', false, $wpsp_lang_dir);
52 // initialize settings of plugin Open required files for initialization
53 // NOTE: ajaxworks files are loaded on-demand below (DOING_AJAX only)
54 // so they don't parse on every normal page load.
55 require_once (WPSP_PLUGIN_PATH . 'wpsp-layout.php');
56 require_once (WPSP_PLUGIN_PATH . 'includes/wpsp-misc.php');
57
58 global $wpsp_settings_data;
59 global $wpsp_admin, $wpsp_public, $paytmClass, $paypalClass;
60 // admin class handles most of functionalities of plugin
61 include_once (WPSP_PLUGIN_PATH . 'wpsp-class-admin.php');
62 $wpsp_admin = new Wpsp_Admin();
63 $wpsp_admin->add_hooks();
64 // public class handles most of functionalities of plugin
65 include_once (WPSP_PLUGIN_PATH . 'wpsp-class-public.php');
66 $wpsp_public = new Wpsp_Public();
67 $wpsp_public->add_hooks();
68 }
69
70 /**
71 * Load settings only when actually needed.
72 *
73 * - Admin screens: always (menu, sidebar, topbar all rely on it).
74 * - Frontend: only on WPSP page slugs (sch-*). Regular visitors on
75 * posts/pages never trigger the DB query.
76 * - AJAX: handled inside the AJAX block below.
77 */
78 add_action( 'init', function() {
79 if ( defined('DOING_AJAX') && DOING_AJAX ) {
80 return; // AJAX path loads settings itself via wpsp-ajaxworks.php
81 }
82 if ( is_admin() ) {
83 if ( function_exists('wpsp_get_setting') ) {
84 wpsp_get_setting();
85 }
86 return;
87 }
88 // Frontend: defer until after the query is resolved so is_page() works.
89 add_action( 'template_redirect', function() {
90 $wpsp_slugs = array(
91 'sch-dashboard','sch-student','sch-transport','sch-parent',
92 'sch-class','sch-teacher','sch-profile',
93 'sch-exams','sch-marks','sch-attendance','sch-timetable',
94 'sch-reminder','sch-events','sch-subject','sch-settings',
95 'sch-calendar','sch-teacherattendance','sch-notify',
96 'sch-payment','sch-importhistory','sch-leavecalendar',
97 'sch-changepassword','sch-editprofile','sch-postsprofile',
98 'sch-posts','sch-posts-notification','sch-reported-posts',
99 'sch-documents','sch-request',
100 );
101 if ( is_page( $wpsp_slugs ) && function_exists('wpsp_get_setting') ) {
102 wpsp_get_setting();
103 }
104 }, 1 );
105 }, 5 );
106
107 /**
108 * AJAX actions — load ajaxworks files and register handlers only when
109 * an actual AJAX request is being processed, not on every page load.
110 * Moved from admin_init (fires on every admin request) to init with
111 * a DOING_AJAX guard so it is completely skipped on normal page loads.
112 */
113 add_action( 'init', function() {
114
115 // ALWAYS load files (functions needed everywhere)
116 if ( ! function_exists('wpsp_listdashboardschedule') ) {
117 require_once (WPSP_PLUGIN_PATH . 'lib/wpsp-ajaxworks.php');
118 require_once (WPSP_PLUGIN_PATH . 'lib/wpsp-ajaxworks-student.php');
119 require_once (WPSP_PLUGIN_PATH . 'lib/wpsp-ajaxworks-teacher.php');
120 }
121
122 // ONLY register AJAX hooks during AJAX
123 if ( defined('DOING_AJAX') && DOING_AJAX ) {
124
125 if ( function_exists('wpsp_get_setting') ) {
126 wpsp_get_setting();
127 }
128
129 ajax_actions();
130 }
131 }, 1 );
132 function ajax_actions()
133 {
134 add_action('wp_ajax_listdashboardschedule', 'wpsp_listdashboardschedule');
135 add_action('wp_ajax_StudentProfile', 'wpsp_StudentProfile');
136 add_action('wp_ajax_AddStudent', 'wpsp_AddStudent');
137 add_action('wp_ajax_UpdateStudent', 'wpsp_UpdateStudent');
138 add_action('wp_ajax_StudentPublicProfile', 'wpsp_StudentPublicProfile');
139 add_action('wp_ajax_ParentPublicProfile', 'wpsp_ParentPublicProfile');
140 add_action('wp_ajax_TeacherPublicProfile', 'wpsp_TeacherPublicProfile');
141 add_action('wp_ajax_bulkDelete', 'wpsp_BulkDelete');
142 add_action('wp_ajax_undoImport', 'wpsp_UndoImport');
143 add_action('wp_ajax_AddTeacher', 'wpsp_AddTeacher');
144 add_action('wp_ajax_AddParent', 'wpsp_AddParent');
145 add_action('wp_ajax_AddClass', 'wpsp_AddClass');
146 add_action('wp_ajax_UpdateClass', 'wpsp_UpdateClass');
147 add_action('wp_ajax_GetClass', 'wpsp_GetClass');
148 add_action('wp_ajax_DeleteClass', 'wpsp_DeleteClass');
149 add_action('wp_ajax_Updateregisterdeactive', 'wpsp_Updateregisterdeactive');
150 add_action('wp_ajax_Updateregisteractive', 'wpsp_Updateregisteractive');
151 add_action('wp_ajax_bulkaproverequest', 'wpsp_bulkaproverequest');
152 add_action('wp_ajax_bulkdisaproverequest', 'wpsp_bulkdisaproverequest');
153 add_action('wp_ajax_AddExam', 'wpsp_AddExam');
154 add_action('wp_ajax_UpdateExam', 'wpsp_UpdateExam');
155 add_action('wp_ajax_ExamInfo', 'wpsp_ExamInfo');
156 add_action('wp_ajax_DeleteExam', 'wpsp_DeleteExam');
157 add_action('wp_ajax_getStudentsList', 'wpsp_getStudentsList');
158 add_action('wp_ajax_AttendanceEntry', 'wpsp_AttendanceEntry');
159 add_action('wp_ajax_deleteAttendance', 'wpsp_DeleteAttendance');
160 add_action('wp_ajax_getStudentsAttendanceList', 'wpsp_getStudentsAttendanceList');
161 add_action('wp_ajax_getAbsentees', 'wpsp_GetAbsentees');
162 add_action('wp_ajax_getAbsentDates', 'wpsp_GetAbsentDates');
163 add_action('wp_ajax_getAttReport', 'wpsp_GetAttReport');
164 add_action('wp_ajax_AddSubject', 'wpsp_AddSubject');
165 add_action('wp_ajax_SubjectInfo', 'wpsp_SubjectInfo');
166 add_action('wp_ajax_UpdateSubject', 'wpsp_UpdateSubject');
167 add_action('wp_ajax_DeleteSubject', 'wpsp_DeleteSubject');
168 add_action('wp_ajax_subjectList', 'wpsp_SubjectList');
169 add_action('wp_ajax_save_timetable', 'wpsp_SaveTimetable');
170 add_action('wp_ajax_deletsloat', 'wpsp_DeleteTimetablesloat');
171 add_action('wp_ajax_deletTimetable', 'wpsp_DeleteTimetable');
172 add_action('wp_ajax_addMark', 'wpsp_AddMark');
173 add_action('wp_ajax_getMarksubject', 'wpsp_getMarksubject');
174
175 add_action('wp_ajax_GenSetting', 'wpsp_GenSetting');
176 add_action('wp_ajax_GenSettingsms', 'wpsp_GenSettingsms');
177 add_action('wp_ajax_GenSettingsocial', 'wpsp_GenSettingsocial');
178 add_action('wp_ajax_GenSettinglicensing', 'wpsp_GenSettinglicensing');
179 add_action('wp_ajax_addSubField', 'wpsp_AddSubField');
180 add_action('wp_ajax_updateSubField', 'wpsp_UpdateSubField');
181 add_action('wp_ajax_deleteSubField', 'wpsp_DeleteSubField');
182 add_action('wp_ajax_manageGrade', 'wpsp_ManageGrade');
183 add_action('wp_ajax_addEvent', 'wpsp_AddEvent');
184 add_action('wp_ajax_updateEvent', 'wpsp_UpdateEvent');
185 add_action('wp_ajax_deleteEvent', 'wpsp_DeleteEvent');
186 add_action('wp_ajax_listEvent', 'wpsp_ListEvent');
187 add_action('wp_ajax_deleteAllLeaves', 'wpsp_DeleteLeave');
188 add_action('wp_ajax_addLeaveDay', 'wpsp_AddLeaveDay');
189 add_action('wp_ajax_getLeaveDays', 'wpsp_GetLeaveDays');
190 add_action('wp_ajax_getClassYear', 'wpsp_GetClassYear');
191 add_action('wp_ajax_addTransport', 'wpsp_AddTransport');
192 add_action('wp_ajax_updateTransport', 'wpsp_UpdateTransport');
193 add_action('wp_ajax_viewTransport', 'wpsp_ViewTransport');
194 add_action('wp_ajax_deleteTransport', 'wpsp_DeleteTransport');
195 add_action('wp_ajax_photoUpload', 'wpsp_UploadPhoto');
196 add_action('wp_ajax_deletePhoto', 'wpsp_DeletePhoto');
197 add_action('wp_ajax_DeleteStudent', 'wpsp_DeleteStudent');
198 add_action('wp_ajax_DeleteTeacher', 'wpsp_DeleteTeacher');
199 // Teacher modules
200 add_action('wp_ajax_getTeachersList', 'wpsp_getTeachersList');
201 add_action('wp_ajax_TeacherAttendanceEntry', 'wpsp_TeacherAttendanceEntry');
202 add_action('wp_ajax_TeacherAttendanceDelete', 'wpsp_TeacherAttendanceDelete');
203 add_action('wp_ajax_TeacherAttendanceView', 'wpsp_TeacherAttendanceView');
204 add_action('wp_ajax_UpdateTeacher', 'wpsp_UpdateTeacher');
205 // Notification modules
206 add_action('wp_ajax_deleteNotify', 'wpsp_deleteNotify');
207 add_action('wp_ajax_getNotify', 'wpsp_getNotifyInfo');
208 //add notify
209 add_action('wp_ajax_addNotify', 'wpsp_addNotify');
210 // Change Password
211 add_action('wp_ajax_changepassword', 'wpsp_changepassword');
212 // Import Dummy data
213 add_action('wp_ajax_ImportContents', 'wpsp_Import_Dummy_contents');
214 }
215
216
217
218 // Get error content and update
219 function wpsp_save_error()
220 {
221 update_option('plugin_error', ob_get_contents());
222 }
223 add_action('activated_plugin', 'wpsp_save_error');
224 //Show Link Plugin Page
225 function wpsp_add_plugin_links($links)
226 {
227 $plugin_links = array(
228 '<a href="'.esc_url('admin.php?page=sch-settings').'"><strong style="color: #11967A; display: inline;">' . __('Settings', 'wpschoolpress') . '</strong></a>'
229 );
230 return array_merge($plugin_links, $links);
231 }
232 add_filter('plugin_action_links_' . plugin_basename(__FILE__) , 'wpsp_add_plugin_links', 20);
233 // Change login page logo url
234 function wp_wp_login_url() { return home_url(); }
235 add_filter( 'login_headerurl', 'wp_wp_login_url' );
236
237 // Grant students the edit_posts cap once — check before writing to avoid
238 // a DB update on every page load when the cap is already set.
239 function wpsp_std_role(){
240 $role = get_role( 'student' );
241 if ( $role && ! $role->has_cap( 'edit_posts' ) ) {
242 $role->add_cap( 'edit_posts', true );
243 }
244 }
245 add_action( 'init', 'wpsp_std_role', 11 );
246 ?>