- renamed PLGNTLS_class -> Plgntls - changed method 'add_to_front()' to static method - moved fetch script as inline script, so the plgntls file is single - improved the way inline script and styles are added
101 lines
1.5 KiB
PHP
101 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* it means someone outside wp is accessing the file, in this case kill it.
|
|
*/
|
|
if (!defined('ABSPATH')) {
|
|
die('You can not access this file!');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* early checks on payment page
|
|
*
|
|
*/
|
|
function payment_page_checks_CIPF() {
|
|
Plgntls::debug_infos(2);
|
|
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
|
|
|
// check the slug
|
|
if (!is_page($slug_paypal_page)) {
|
|
return;
|
|
}
|
|
Plgntls::debug_infos();
|
|
|
|
// get the user id
|
|
$user_id = get_current_user_id();
|
|
|
|
// do checks here
|
|
}
|
|
add_action('wp', 'payment_page_checks_CIPF');
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* only profs can access this page
|
|
*
|
|
*/
|
|
function payment_page_redirects_CIPF() {
|
|
Plgntls::debug_infos(2);
|
|
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
|
$role_prof = Plgntls::ROLE_PROF;
|
|
|
|
// don't redirect if it is the divi builder mode
|
|
if (et_fb_is_enabled()) {
|
|
return;
|
|
}
|
|
// check the slug
|
|
if (!is_page($slug_paypal_page)) {
|
|
return;
|
|
}
|
|
Plgntls::debug_infos();
|
|
|
|
/*
|
|
* if prof, don't redirect
|
|
* for everyone else, redirect
|
|
*
|
|
*/
|
|
if (current_user_can($role_prof)) {
|
|
return;
|
|
}
|
|
redirect_home_CIPF();
|
|
|
|
}
|
|
add_action('template_redirect', 'payment_page_redirects_CIPF');
|
|
|
|
|
|
|
|
|
|
/*
|
|
* time to upload some scripts and styles on prof profil page
|
|
*
|
|
*/
|
|
function payment_page_scripts_CIPF() {
|
|
Plgntls::debug_infos(2);
|
|
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
|
|
|
// check the slug
|
|
if (!is_page($slug_paypal_page)) {
|
|
return;
|
|
}
|
|
Plgntls::debug_infos();
|
|
|
|
// get the user id
|
|
$user_id = get_current_user_id();
|
|
|
|
// enqueue files here
|
|
display_page_css_CIPF($user_id);
|
|
}
|
|
add_action('wp_enqueue_scripts', 'payment_page_scripts_CIPF');
|
|
|
|
|
|
|
|
|
|
?>
|