Files
2024_WEBSITE_fipf/plugins/cipf_plugin/php/paypal/payment_page.php

98 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_class::debug_infos();
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
// check the slug
if (!is_page($slug_paypal_page)) {
return;
}
// 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_class::debug_infos();
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
$role_prof = PLGNTLS_class::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;
}
/*
* 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_class::debug_infos();
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
// check the slug
if (!is_page($slug_paypal_page)) {
return;
}
// 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');
?>