Files
2024_WEBSITE_fipf/plugins/cipf_plugin/php/partners_page.php
asus ade0be87ce updated plgntls :
- 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
2024-03-29 21:56:12 +01:00

62 lines
950 B
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!');
}
/*
* upload scripts and styles on partner page
*
*/
function partner_page_scripts_CIPF() {
Plgntls::debug_infos(2);
$role_partner = Plgntls::ROLE_PARTNER;
/*
* dont do anything if :
* - user not logged in
* - user no partner
* - partner not author of the page
*
*/
if (!is_user_logged_in()) {
return;
}
if (!current_user_can($role_partner)) {
return;
}
global $post;
if (is_null($post)) {
return;
}
Plgntls::debug_infos();
$current_post_author = (int)($post->post_author);
$current_user_id = (int)get_current_user_id();
if ($current_user_id !== $current_post_author) {
return;
}
/*
* on partner own page, load css
*
*/
Plgntls::add_to_front(array('css/partner_page.css'));
}
add_action('wp_enqueue_scripts', 'partner_page_scripts_CIPF', 11);
?>