| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if ( !defined( 'ABSPATH' ) ) exit; |
| 4 |
/** |
| 5 |
* Initilize SchoolPress |
| 6 |
* |
| 7 |
* Handle to initilize Settings of SchoolPress |
| 8 |
* |
| 9 |
* @package WPSchoolPress |
| 10 |
* @since 2.0.0 |
| 11 |
*/ |
| 12 |
function wpsp_get_setting() { |
| 13 |
global $wpsp_settings_data, $wpdb; |
| 14 |
|
| 15 |
// Try transient cache first — avoids a DB query on every page load. |
| 16 |
$cached = get_transient( 'wpsp_settings_cache' ); |
| 17 |
if ( $cached !== false && is_array( $cached ) ) { |
| 18 |
$wpsp_settings_data = $cached; |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
// Cache miss — hit the DB and store the result for 12 hours. |
| 23 |
$wpsp_settings_table = $wpdb->prefix . "wpsp_settings"; |
| 24 |
$wpsp_settings_edit = $wpdb->get_results( "SELECT * FROM $wpsp_settings_table" ); |
| 25 |
$wpsp_settings_data = array(); |
| 26 |
foreach ( $wpsp_settings_edit as $sdat ) { |
| 27 |
$wpsp_settings_data[ $sdat->option_name ] = $sdat->option_value; |
| 28 |
} |
| 29 |
set_transient( 'wpsp_settings_cache', $wpsp_settings_data, 12 * HOUR_IN_SECONDS ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Clear the settings transient cache. |
| 34 |
* Called automatically whenever any settings are saved so the next |
| 35 |
* page load always reads fresh data from the database. |
| 36 |
*/ |
| 37 |
function wpsp_clear_settings_cache() { |
| 38 |
delete_transient( 'wpsp_settings_cache' ); |
| 39 |
} |
| 40 |
/* |
| 41 |
* Send mail when new user register |
| 42 |
* @package WPSchoolPress |
| 43 |
* @since 2.0.0 |
| 44 |
*/ |
| 45 |
function wpsp_send_user_register_mail( $user_id, $userInfo = array() ) { |
| 46 |
if( !empty( $user_id ) && $user_id > 0 ) { |
| 47 |
wp_new_user_notification( $user_id, '', 'user'); |
| 48 |
} |
| 49 |
} |
| 50 |
/* |
| 51 |
* Check current user is authorized or not |
| 52 |
* @package WPSchoolPress |
| 53 |
* @since 2.0.0 |
| 54 |
*/ |
| 55 |
function wpsp_Authenticate() { |
| 56 |
global $current_user; |
| 57 |
if($current_user->roles[0]!='administrator' && $current_user->roles[0]!='teacher' ) { |
| 58 |
echo esc_html("Unauthorized Access!","wpschoolpress"); |
| 59 |
exit; |
| 60 |
} |
| 61 |
} |
| 62 |
function wpsp_StudentAuthenticate() { |
| 63 |
global $current_user; |
| 64 |
if($current_user->roles[0]!='student' && $current_user->roles[0]!='parent' ) { |
| 65 |
echo esc_html("Unauthorized Access!","wpschoolpress"); |
| 66 |
exit; |
| 67 |
} |
| 68 |
} |
| 69 |
function wpsp_TeacherAuthenticate() { |
| 70 |
global $current_user; |
| 71 |
if($current_user->roles[0]!='teacher' ) { |
| 72 |
echo esc_html("Unauthorized Access!","wpschoolpress"); |
| 73 |
exit; |
| 74 |
} |
| 75 |
} |
| 76 |
function wpsp_AdminAuthenticate() { |
| 77 |
global $current_user; |
| 78 |
if($current_user->roles[0]!='administrator' ) { |
| 79 |
echo esc_html("Unauthorized Access!","wpschoolpress"); |
| 80 |
exit; |
| 81 |
} |
| 82 |
} |
| 83 |
function wpsp_AllAuthenticate() { |
| 84 |
global $current_user; |
| 85 |
if($current_user->roles[0]!='student' && $current_user->roles[0]!='parent' && $current_user->roles[0]!='administrator' && $current_user->roles[0]!='teacher' ) { |
| 86 |
echo esc_html("Unauthorized Access!","wpschoolpress"); |
| 87 |
exit; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
/* |
| 92 |
* Check current user has update access or not |
| 93 |
* @package WPSchoolPress |
| 94 |
* @since 2.0.0 |
| 95 |
*/ |
| 96 |
function wpsp_UpdateAccess($role,$id){ |
| 97 |
global $current_user; |
| 98 |
$current_user_role=$current_user->roles[0]; |
| 99 |
if( $current_user_role=='administrator' || ( $current_user_role==$role && $current_user->ID==$id ) || $current_user_role=='teacher' ) { |
| 100 |
return true; |
| 101 |
} else { |
| 102 |
return false; |
| 103 |
} |
| 104 |
} |
| 105 |
/* |
| 106 |
* Get role of current user |
| 107 |
* @package WPSchoolPress |
| 108 |
* @since 2.0.0 |
| 109 |
*/ |
| 110 |
function wpsp_CurrentUserRole(){ |
| 111 |
global $current_user; |
| 112 |
return isset( $current_user->roles[0] ) ? $current_user->roles[0] : ''; |
| 113 |
} |
| 114 |
/* |
| 115 |
* Get add as per given setting |
| 116 |
* @package WPSchoolPress |
| 117 |
* @since 2.0.0 |
| 118 |
*/ |
| 119 |
function wpsp_ViewDate($date){ |
| 120 |
global $wpdb, $wpsp_settings_data; |
| 121 |
$date_format = isset( $wpsp_settings_data['date_format'] ) ? $wpsp_settings_data['date_format'] : ''; |
| 122 |
$dformat = empty( $date_format ) ? 'm/d/Y' : $date_format; |
| 123 |
return ( !empty( $date ) && $date!='0000-00-00' ) ? date( $dformat,strtotime($date) ) : $date; |
| 124 |
} |
| 125 |
/* |
| 126 |
* Store date as per given setting |
| 127 |
* @package WPSchoolPress |
| 128 |
* @since 2.0.0 |
| 129 |
*/ |
| 130 |
function wpsp_StoreDate($date) { |
| 131 |
return ( !empty ( $date ) && $date!='0000-00-00' ) ? date('Y-m-d',strtotime($date)) : $date; |
| 132 |
} |
| 133 |
/* |
| 134 |
* Check for username exists or not |
| 135 |
* @package WPSchoolPress |
| 136 |
* @since 2.0.0 |
| 137 |
*/ |
| 138 |
function wpsp_CheckUsername($username='',$return=false){ |
| 139 |
$username = empty( $username ) ? sanitize_user($_POST['username'] ) : $username ; |
| 140 |
if ( username_exists( $username ) ) { |
| 141 |
if ($return) |
| 142 |
return true; |
| 143 |
else{ |
| 144 |
echo esc_html("true","wpschoolpress"); |
| 145 |
wp_die(); |
| 146 |
} |
| 147 |
} else { |
| 148 |
if ($return) |
| 149 |
return false; |
| 150 |
else { |
| 151 |
echo esc_html("false","wpschoolpress"); |
| 152 |
wp_die(); |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
/* |
| 157 |
* Check for emailID exists or not |
| 158 |
* @package WPSchoolPress |
| 159 |
* @since 2.0.0 |
| 160 |
*/ |
| 161 |
function wpsp_CheckEmail(){ |
| 162 |
$email=sanitize_email($_POST['email']); |
| 163 |
echo email_exists( $email ) ? esc_html("true","wpschoolpress") : esc_html("false","wpschoolpress"); |
| 164 |
wp_die(); |
| 165 |
} |
| 166 |
/* |
| 167 |
* Create dynamic email id if not specified |
| 168 |
* @package WPSchoolPress |
| 169 |
* @since 2.0.0 |
| 170 |
*/ |
| 171 |
function wpsp_EmailGen($username){ |
| 172 |
return $username."@wpschoolpress.com"; |
| 173 |
} |
| 174 |
/* This function is used for send mail */ |
| 175 |
function wpsp_send_mail( $to, $subject, $body, $attachment='' ) { |
| 176 |
global $wpsp_settings_data; |
| 177 |
$email = $wpsp_settings_data['sch_email']; |
| 178 |
$from = $wpsp_settings_data['sch_name']; |
| 179 |
$admin_email = get_option( 'admin_email' ); |
| 180 |
$email = !empty( $email ) ? wp_unslash($email) : wp_unslash($admin_email); |
| 181 |
$from = !empty( $from ) ? $from : get_option( 'blogname' ); |
| 182 |
$headers = array(); |
| 183 |
if( !empty( $email ) && !empty( $from ) ) { |
| 184 |
$headers[] = "From: $from <$email>"; |
| 185 |
$headers[] = 'Content-Type: text/html; charset=UTF-8'; |
| 186 |
} |
| 187 |
if( wp_mail( $to, $subject, $body, $headers, $attachment )) return true; |
| 188 |
else return false; |
| 189 |
} |
| 190 |
/* This function is return country list */ |
| 191 |
function wpsp_county_list() { |
| 192 |
return array( |
| 193 |
'AF' => __( 'Afghanistan', 'wpschoolpress' ), |
| 194 |
'AX' => __( 'Åland Islands', 'wpschoolpress' ), |
| 195 |
'AL' => __( 'Albania', 'wpschoolpress' ), |
| 196 |
'DZ' => __( 'Algeria', 'wpschoolpress' ), |
| 197 |
'AD' => __( 'Andorra', 'wpschoolpress' ), |
| 198 |
'AO' => __( 'Angola', 'wpschoolpress' ), |
| 199 |
'AI' => __( 'Anguilla', 'wpschoolpress' ), |
| 200 |
'AQ' => __( 'Antarctica', 'wpschoolpress' ), |
| 201 |
'AG' => __( 'Antigua and Barbuda', 'wpschoolpress' ), |
| 202 |
'AR' => __( 'Argentina', 'wpschoolpress' ), |
| 203 |
'AM' => __( 'Armenia', 'wpschoolpress' ), |
| 204 |
'AW' => __( 'Aruba', 'wpschoolpress' ), |
| 205 |
'AU' => __( 'Australia', 'wpschoolpress' ), |
| 206 |
'AT' => __( 'Austria', 'wpschoolpress' ), |
| 207 |
'AZ' => __( 'Azerbaijan', 'wpschoolpress' ), |
| 208 |
'BS' => __( 'Bahamas', 'wpschoolpress' ), |
| 209 |
'BH' => __( 'Bahrain', 'wpschoolpress' ), |
| 210 |
'BD' => __( 'Bangladesh', 'wpschoolpress' ), |
| 211 |
'BB' => __( 'Barbados', 'wpschoolpress' ), |
| 212 |
'BY' => __( 'Belarus', 'wpschoolpress' ), |
| 213 |
'BE' => __( 'Belgium', 'wpschoolpress' ), |
| 214 |
'PW' => __( 'Belau', 'wpschoolpress' ), |
| 215 |
'BZ' => __( 'Belize', 'wpschoolpress' ), |
| 216 |
'BJ' => __( 'Benin', 'wpschoolpress' ), |
| 217 |
'BM' => __( 'Bermuda', 'wpschoolpress' ), |
| 218 |
'BT' => __( 'Bhutan', 'wpschoolpress' ), |
| 219 |
'BO' => __( 'Bolivia', 'wpschoolpress' ), |
| 220 |
'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'wpschoolpress' ), |
| 221 |
'BA' => __( 'Bosnia and Herzegovina', 'wpschoolpress' ), |
| 222 |
'BW' => __( 'Botswana', 'wpschoolpress' ), |
| 223 |
'BV' => __( 'Bouvet Island', 'wpschoolpress' ), |
| 224 |
'BR' => __( 'Brazil', 'wpschoolpress' ), |
| 225 |
'IO' => __( 'British Indian Ocean Territory', 'wpschoolpress' ), |
| 226 |
'VG' => __( 'British Virgin Islands', 'wpschoolpress' ), |
| 227 |
'BN' => __( 'Brunei', 'wpschoolpress' ), |
| 228 |
'BG' => __( 'Bulgaria', 'wpschoolpress' ), |
| 229 |
'BF' => __( 'Burkina Faso', 'wpschoolpress' ), |
| 230 |
'BI' => __( 'Burundi', 'wpschoolpress' ), |
| 231 |
'KH' => __( 'Cambodia', 'wpschoolpress' ), |
| 232 |
'CM' => __( 'Cameroon', 'wpschoolpress' ), |
| 233 |
'CA' => __( 'Canada', 'wpschoolpress' ), |
| 234 |
'CV' => __( 'Cape Verde', 'wpschoolpress' ), |
| 235 |
'KY' => __( 'Cayman Islands', 'wpschoolpress' ), |
| 236 |
'CF' => __( 'Central African Republic', 'wpschoolpress' ), |
| 237 |
'TD' => __( 'Chad', 'wpschoolpress' ), |
| 238 |
'CL' => __( 'Chile', 'wpschoolpress' ), |
| 239 |
'CN' => __( 'China', 'wpschoolpress' ), |
| 240 |
'CX' => __( 'Christmas Island', 'wpschoolpress' ), |
| 241 |
'CC' => __( 'Cocos (Keeling) Islands', 'wpschoolpress' ), |
| 242 |
'CO' => __( 'Colombia', 'wpschoolpress' ), |
| 243 |
'KM' => __( 'Comoros', 'wpschoolpress' ), |
| 244 |
'CG' => __( 'Congo (Brazzaville)', 'wpschoolpress' ), |
| 245 |
'CD' => __( 'Congo (Kinshasa)', 'wpschoolpress' ), |
| 246 |
'CK' => __( 'Cook Islands', 'wpschoolpress' ), |
| 247 |
'CR' => __( 'Costa Rica', 'wpschoolpress' ), |
| 248 |
'HR' => __( 'Croatia', 'wpschoolpress' ), |
| 249 |
'CU' => __( 'Cuba', 'wpschoolpress' ), |
| 250 |
'CW' => __( 'CuraÇao', 'wpschoolpress' ), |
| 251 |
'CY' => __( 'Cyprus', 'wpschoolpress' ), |
| 252 |
'CZ' => __( 'Czech Republic', 'wpschoolpress' ), |
| 253 |
'DK' => __( 'Denmark', 'wpschoolpress' ), |
| 254 |
'DJ' => __( 'Djibouti', 'wpschoolpress' ), |
| 255 |
'DM' => __( 'Dominica', 'wpschoolpress' ), |
| 256 |
'DO' => __( 'Dominican Republic', 'wpschoolpress' ), |
| 257 |
'EC' => __( 'Ecuador', 'wpschoolpress' ), |
| 258 |
'EG' => __( 'Egypt', 'wpschoolpress' ), |
| 259 |
'SV' => __( 'El Salvador', 'wpschoolpress' ), |
| 260 |
'GQ' => __( 'Equatorial Guinea', 'wpschoolpress' ), |
| 261 |
'ER' => __( 'Eritrea', 'wpschoolpress' ), |
| 262 |
'EE' => __( 'Estonia', 'wpschoolpress' ), |
| 263 |
'ET' => __( 'Ethiopia', 'wpschoolpress' ), |
| 264 |
'FK' => __( 'Falkland Islands', 'wpschoolpress' ), |
| 265 |
'FO' => __( 'Faroe Islands', 'wpschoolpress' ), |
| 266 |
'FJ' => __( 'Fiji', 'wpschoolpress' ), |
| 267 |
'FI' => __( 'Finland', 'wpschoolpress' ), |
| 268 |
'FR' => __( 'France', 'wpschoolpress' ), |
| 269 |
'GF' => __( 'French Guiana', 'wpschoolpress' ), |
| 270 |
'PF' => __( 'French Polynesia', 'wpschoolpress' ), |
| 271 |
'TF' => __( 'French Southern Territories', 'wpschoolpress' ), |
| 272 |
'GA' => __( 'Gabon', 'wpschoolpress' ), |
| 273 |
'GM' => __( 'Gambia', 'wpschoolpress' ), |
| 274 |
'GE' => __( 'Georgia', 'wpschoolpress' ), |
| 275 |
'DE' => __( 'Germany', 'wpschoolpress' ), |
| 276 |
'GH' => __( 'Ghana', 'wpschoolpress' ), |
| 277 |
'GI' => __( 'Gibraltar', 'wpschoolpress' ), |
| 278 |
'GR' => __( 'Greece', 'wpschoolpress' ), |
| 279 |
'GL' => __( 'Greenland', 'wpschoolpress' ), |
| 280 |
'GD' => __( 'Grenada', 'wpschoolpress' ), |
| 281 |
'GP' => __( 'Guadeloupe', 'wpschoolpress' ), |
| 282 |
'GT' => __( 'Guatemala', 'wpschoolpress' ), |
| 283 |
'GG' => __( 'Guernsey', 'wpschoolpress' ), |
| 284 |
'GN' => __( 'Guinea', 'wpschoolpress' ), |
| 285 |
'GW' => __( 'Guinea-Bissau', 'wpschoolpress' ), |
| 286 |
'GY' => __( 'Guyana', 'wpschoolpress' ), |
| 287 |
'HT' => __( 'Haiti', 'wpschoolpress' ), |
| 288 |
'HM' => __( 'Heard Island and McDonald Islands', 'wpschoolpress' ), |
| 289 |
'HN' => __( 'Honduras', 'wpschoolpress' ), |
| 290 |
'HK' => __( 'Hong Kong', 'wpschoolpress' ), |
| 291 |
'HU' => __( 'Hungary', 'wpschoolpress' ), |
| 292 |
'IS' => __( 'Iceland', 'wpschoolpress' ), |
| 293 |
'IN' => __( 'India', 'wpschoolpress' ), |
| 294 |
'ID' => __( 'Indonesia', 'wpschoolpress' ), |
| 295 |
'IR' => __( 'Iran', 'wpschoolpress' ), |
| 296 |
'IQ' => __( 'Iraq', 'wpschoolpress' ), |
| 297 |
'IE' => __( 'Republic of Ireland', 'wpschoolpress' ), |
| 298 |
'IM' => __( 'Isle of Man', 'wpschoolpress' ), |
| 299 |
'IL' => __( 'Israel', 'wpschoolpress' ), |
| 300 |
'IT' => __( 'Italy', 'wpschoolpress' ), |
| 301 |
'CI' => __( 'Ivory Coast', 'wpschoolpress' ), |
| 302 |
'JM' => __( 'Jamaica', 'wpschoolpress' ), |
| 303 |
'JP' => __( 'Japan', 'wpschoolpress' ), |
| 304 |
'JE' => __( 'Jersey', 'wpschoolpress' ), |
| 305 |
'JO' => __( 'Jordan', 'wpschoolpress' ), |
| 306 |
'KZ' => __( 'Kazakhstan', 'wpschoolpress' ), |
| 307 |
'KE' => __( 'Kenya', 'wpschoolpress' ), |
| 308 |
'KI' => __( 'Kiribati', 'wpschoolpress' ), |
| 309 |
'KW' => __( 'Kuwait', 'wpschoolpress' ), |
| 310 |
'KG' => __( 'Kyrgyzstan', 'wpschoolpress' ), |
| 311 |
'LA' => __( 'Laos', 'wpschoolpress' ), |
| 312 |
'LV' => __( 'Latvia', 'wpschoolpress' ), |
| 313 |
'LB' => __( 'Lebanon', 'wpschoolpress' ), |
| 314 |
'LS' => __( 'Lesotho', 'wpschoolpress' ), |
| 315 |
'LR' => __( 'Liberia', 'wpschoolpress' ), |
| 316 |
'LY' => __( 'Libya', 'wpschoolpress' ), |
| 317 |
'LI' => __( 'Liechtenstein', 'wpschoolpress' ), |
| 318 |
'LT' => __( 'Lithuania', 'wpschoolpress' ), |
| 319 |
'LU' => __( 'Luxembourg', 'wpschoolpress' ), |
| 320 |
'MO' => __( 'Macao S.A.R., China', 'wpschoolpress' ), |
| 321 |
'MK' => __( 'Macedonia', 'wpschoolpress' ), |
| 322 |
'MG' => __( 'Madagascar', 'wpschoolpress' ), |
| 323 |
'MW' => __( 'Malawi', 'wpschoolpress' ), |
| 324 |
'MY' => __( 'Malaysia', 'wpschoolpress' ), |
| 325 |
'MV' => __( 'Maldives', 'wpschoolpress' ), |
| 326 |
'ML' => __( 'Mali', 'wpschoolpress' ), |
| 327 |
'MT' => __( 'Malta', 'wpschoolpress' ), |
| 328 |
'MH' => __( 'Marshall Islands', 'wpschoolpress' ), |
| 329 |
'MQ' => __( 'Martinique', 'wpschoolpress' ), |
| 330 |
'MR' => __( 'Mauritania', 'wpschoolpress' ), |
| 331 |
'MU' => __( 'Mauritius', 'wpschoolpress' ), |
| 332 |
'YT' => __( 'Mayotte', 'wpschoolpress' ), |
| 333 |
'MX' => __( 'Mexico', 'wpschoolpress' ), |
| 334 |
'FM' => __( 'Micronesia', 'wpschoolpress' ), |
| 335 |
'MD' => __( 'Moldova', 'wpschoolpress' ), |
| 336 |
'MC' => __( 'Monaco', 'wpschoolpress' ), |
| 337 |
'MN' => __( 'Mongolia', 'wpschoolpress' ), |
| 338 |
'ME' => __( 'Montenegro', 'wpschoolpress' ), |
| 339 |
'MS' => __( 'Montserrat', 'wpschoolpress' ), |
| 340 |
'MA' => __( 'Morocco', 'wpschoolpress' ), |
| 341 |
'MZ' => __( 'Mozambique', 'wpschoolpress' ), |
| 342 |
'MM' => __( 'Myanmar', 'wpschoolpress' ), |
| 343 |
'NA' => __( 'Namibia', 'wpschoolpress' ), |
| 344 |
'NR' => __( 'Nauru', 'wpschoolpress' ), |
| 345 |
'NP' => __( 'Nepal', 'wpschoolpress' ), |
| 346 |
'NL' => __( 'Netherlands', 'wpschoolpress' ), |
| 347 |
'AN' => __( 'Netherlands Antilles', 'wpschoolpress' ), |
| 348 |
'NC' => __( 'New Caledonia', 'wpschoolpress' ), |
| 349 |
'NZ' => __( 'New Zealand', 'wpschoolpress' ), |
| 350 |
'NI' => __( 'Nicaragua', 'wpschoolpress' ), |
| 351 |
'NE' => __( 'Niger', 'wpschoolpress' ), |
| 352 |
'NG' => __( 'Nigeria', 'wpschoolpress' ), |
| 353 |
'NU' => __( 'Niue', 'wpschoolpress' ), |
| 354 |
'NF' => __( 'Norfolk Island', 'wpschoolpress' ), |
| 355 |
'KP' => __( 'North Korea', 'wpschoolpress' ), |
| 356 |
'NO' => __( 'Norway', 'wpschoolpress' ), |
| 357 |
'OM' => __( 'Oman', 'wpschoolpress' ), |
| 358 |
'PK' => __( 'Pakistan', 'wpschoolpress' ), |
| 359 |
'PS' => __( 'Palestinian Territory', 'wpschoolpress' ), |
| 360 |
'PA' => __( 'Panama', 'wpschoolpress' ), |
| 361 |
'PG' => __( 'Papua New Guinea', 'wpschoolpress' ), |
| 362 |
'PY' => __( 'Paraguay', 'wpschoolpress' ), |
| 363 |
'PE' => __( 'Peru', 'wpschoolpress' ), |
| 364 |
'PH' => __( 'Philippines', 'wpschoolpress' ), |
| 365 |
'PN' => __( 'Pitcairn', 'wpschoolpress' ), |
| 366 |
'PL' => __( 'Poland', 'wpschoolpress' ), |
| 367 |
'PT' => __( 'Portugal', 'wpschoolpress' ), |
| 368 |
'QA' => __( 'Qatar', 'wpschoolpress' ), |
| 369 |
'RE' => __( 'Reunion', 'wpschoolpress' ), |
| 370 |
'RO' => __( 'Romania', 'wpschoolpress' ), |
| 371 |
'RU' => __( 'Russia', 'wpschoolpress' ), |
| 372 |
'RW' => __( 'Rwanda', 'wpschoolpress' ), |
| 373 |
'BL' => __( 'Saint Barthélemy', 'wpschoolpress' ), |
| 374 |
'SH' => __( 'Saint Helena', 'wpschoolpress' ), |
| 375 |
'KN' => __( 'Saint Kitts and Nevis', 'wpschoolpress' ), |
| 376 |
'LC' => __( 'Saint Lucia', 'wpschoolpress' ), |
| 377 |
'MF' => __( 'Saint Martin (French part)', 'wpschoolpress' ), |
| 378 |
'SX' => __( 'Saint Martin (Dutch part)', 'wpschoolpress' ), |
| 379 |
'PM' => __( 'Saint Pierre and Miquelon', 'wpschoolpress' ), |
| 380 |
'VC' => __( 'Saint Vincent and the Grenadines', 'wpschoolpress' ), |
| 381 |
'SM' => __( 'San Marino', 'wpschoolpress' ), |
| 382 |
'ST' => __( 'São Tomé and Príncipe', 'wpschoolpress' ), |
| 383 |
'SA' => __( 'Saudi Arabia', 'wpschoolpress' ), |
| 384 |
'SN' => __( 'Senegal', 'wpschoolpress' ), |
| 385 |
'RS' => __( 'Serbia', 'wpschoolpress' ), |
| 386 |
'SC' => __( 'Seychelles', 'wpschoolpress' ), |
| 387 |
'SL' => __( 'Sierra Leone', 'wpschoolpress' ), |
| 388 |
'SG' => __( 'Singapore', 'wpschoolpress' ), |
| 389 |
'SK' => __( 'Slovakia', 'wpschoolpress' ), |
| 390 |
'SI' => __( 'Slovenia', 'wpschoolpress' ), |
| 391 |
'SB' => __( 'Solomon Islands', 'wpschoolpress' ), |
| 392 |
'SO' => __( 'Somalia', 'wpschoolpress' ), |
| 393 |
'ZA' => __( 'South Africa', 'wpschoolpress' ), |
| 394 |
'GS' => __( 'South Georgia/Sandwich Islands', 'wpschoolpress' ), |
| 395 |
'KR' => __( 'South Korea', 'wpschoolpress' ), |
| 396 |
'SS' => __( 'South Sudan', 'wpschoolpress' ), |
| 397 |
'ES' => __( 'Spain', 'wpschoolpress' ), |
| 398 |
'LK' => __( 'Sri Lanka', 'wpschoolpress' ), |
| 399 |
'SD' => __( 'Sudan', 'wpschoolpress' ), |
| 400 |
'SR' => __( 'Suriname', 'wpschoolpress' ), |
| 401 |
'SJ' => __( 'Svalbard and Jan Mayen', 'wpschoolpress' ), |
| 402 |
'SZ' => __( 'Swaziland', 'wpschoolpress' ), |
| 403 |
'SE' => __( 'Sweden', 'wpschoolpress' ), |
| 404 |
'CH' => __( 'Switzerland', 'wpschoolpress' ), |
| 405 |
'SY' => __( 'Syria', 'wpschoolpress' ), |
| 406 |
'TW' => __( 'Taiwan', 'wpschoolpress' ), |
| 407 |
'TJ' => __( 'Tajikistan', 'wpschoolpress' ), |
| 408 |
'TZ' => __( 'Tanzania', 'wpschoolpress' ), |
| 409 |
'TH' => __( 'Thailand', 'wpschoolpress' ), |
| 410 |
'TL' => __( 'Timor-Leste', 'wpschoolpress' ), |
| 411 |
'TG' => __( 'Togo', 'wpschoolpress' ), |
| 412 |
'TK' => __( 'Tokelau', 'wpschoolpress' ), |
| 413 |
'TO' => __( 'Tonga', 'wpschoolpress' ), |
| 414 |
'TT' => __( 'Trinidad and Tobago', 'wpschoolpress' ), |
| 415 |
'TN' => __( 'Tunisia', 'wpschoolpress' ), |
| 416 |
'TR' => __( 'Turkey', 'wpschoolpress' ), |
| 417 |
'TM' => __( 'Turkmenistan', 'wpschoolpress' ), |
| 418 |
'TC' => __( 'Turks and Caicos Islands', 'wpschoolpress' ), |
| 419 |
'TV' => __( 'Tuvalu', 'wpschoolpress' ), |
| 420 |
'UG' => __( 'Uganda', 'wpschoolpress' ), |
| 421 |
'UA' => __( 'Ukraine', 'wpschoolpress' ), |
| 422 |
'AE' => __( 'United Arab Emirates', 'wpschoolpress' ), |
| 423 |
'GB' => __( 'United Kingdom (UK)', 'wpschoolpress' ), |
| 424 |
'US' => __( 'United States (US)', 'wpschoolpress' ), |
| 425 |
'UY' => __( 'Uruguay', 'wpschoolpress' ), |
| 426 |
'UZ' => __( 'Uzbekistan', 'wpschoolpress' ), |
| 427 |
'VU' => __( 'Vanuatu', 'wpschoolpress' ), |
| 428 |
'VA' => __( 'Vatican', 'wpschoolpress' ), |
| 429 |
'VE' => __( 'Venezuela', 'wpschoolpress' ), |
| 430 |
'VN' => __( 'Vietnam', 'wpschoolpress' ), |
| 431 |
'WF' => __( 'Wallis and Futuna', 'wpschoolpress' ), |
| 432 |
'EH' => __( 'Western Sahara', 'wpschoolpress' ), |
| 433 |
'WS' => __( 'Western Samoa', 'wpschoolpress' ), |
| 434 |
'YE' => __( 'Yemen', 'wpschoolpress' ), |
| 435 |
'ZM' => __( 'Zambia', 'wpschoolpress' ), |
| 436 |
'ZW' => __( 'Zimbabwe', 'wpschoolpress' ) |
| 437 |
); |
| 438 |
} |
| 439 |
/* This Function is Check Pro Version */ |
| 440 |
function wpsp_check_pro_version( $class='wpsp_pro_version' ) { |
| 441 |
// Static cache: class_exists() is called many times per request with the |
| 442 |
// same arguments. Cache results for the lifetime of the request so each |
| 443 |
// class name is checked only once regardless of how many times it is called. |
| 444 |
static $wpsp_version_cache = array(); |
| 445 |
|
| 446 |
if ( isset( $wpsp_version_cache[ $class ] ) ) { |
| 447 |
return $wpsp_version_cache[ $class ]; |
| 448 |
} |
| 449 |
|
| 450 |
$response = array(); |
| 451 |
$response['status'] = true; |
| 452 |
if ( ! empty( $class ) && ! class_exists( $class ) ) { |
| 453 |
$response['status'] = false; |
| 454 |
$response['class'] = 'upgrade-to-wpsp-version'; |
| 455 |
$response['message'] = 'Please Purchase This Add-on'; |
| 456 |
} |
| 457 |
|
| 458 |
$wpsp_version_cache[ $class ] = $response; |
| 459 |
return $response; |
| 460 |
} |
| 461 |
|
| 462 |
?> |