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
This commit is contained in:
asus
2024-03-29 21:56:12 +01:00
parent 42e8cbc4e9
commit ade0be87ce
41 changed files with 457 additions and 421 deletions

View File

@@ -1,10 +1,10 @@
<?php <?php
/* /*
Plugin Name: cipf_plugin Plugin Name: hggg_cipf
Plugin URI: Plugin URI:
Description: Description:
Author: hugogogo Author: hugogogo
Version: 0.4.3 Version: 0.5.0
Author URI: Author URI:
*/ */
@@ -25,32 +25,32 @@ include_once( plugin_dir_path(__FILE__) . '/utils/plgntls_class.php');
* general inclusions * general inclusions
// utils : // utils :
*/ */
include_once(PLGNTLS_class::root_path() . 'php/utils/globals.php'); include_once(Plgntls::root_path() . 'php/utils/globals.php');
include_once(PLGNTLS_class::root_path() . 'utils/console_log.php'); include_once(Plgntls::root_path() . 'php/utils/console_log.php');
include_once(PLGNTLS_class::root_path() . 'php/admin_menu/admin_menu.php'); include_once(Plgntls::root_path() . 'php/admin_menu/admin_menu.php');
include_once(PLGNTLS_class::root_path() . 'php/admin_menu/admin_menu_toggle.php'); include_once(Plgntls::root_path() . 'php/admin_menu/admin_menu_toggle.php');
include_once(PLGNTLS_class::root_path() . 'php/admin_menu/menu_content.php'); include_once(Plgntls::root_path() . 'php/admin_menu/menu_content.php');
include_once(PLGNTLS_class::root_path() . 'php/admin_menu/post_paypal.php'); include_once(Plgntls::root_path() . 'php/admin_menu/post_paypal.php');
include_once(PLGNTLS_class::root_path() . 'php/admin_menu/post_payment_messages.php'); include_once(Plgntls::root_path() . 'php/admin_menu/post_payment_messages.php');
include_once(PLGNTLS_class::root_path() . 'php/admin_menu/post_email.php'); include_once(Plgntls::root_path() . 'php/admin_menu/post_email.php');
include_once(PLGNTLS_class::root_path() . 'php/paypal/paypal.php'); include_once(Plgntls::root_path() . 'php/paypal/paypal.php');
include_once(PLGNTLS_class::root_path() . '/php/hide_admin.php'); include_once(Plgntls::root_path() . '/php/hide_admin.php');
//include_once(PLGNTLS_class::root_path() . '/php/menus.php'); //include_once(Plgntls::root_path() . '/php/menus.php');
include_once(PLGNTLS_class::root_path() . 'php/redirections.php'); include_once(Plgntls::root_path() . 'php/redirections.php');
include_once(PLGNTLS_class::root_path() . 'php/profs_profil.php'); include_once(Plgntls::root_path() . 'php/profs_profil.php');
include_once(PLGNTLS_class::root_path() . 'php/profs_form_commande.php'); include_once(Plgntls::root_path() . 'php/profs_form_commande.php');
include_once(PLGNTLS_class::root_path() . 'php/profs_dates.php'); include_once(Plgntls::root_path() . 'php/profs_dates.php');
include_once(PLGNTLS_class::root_path() . 'php/profs_states.php'); include_once(Plgntls::root_path() . 'php/profs_states.php');
include_once(PLGNTLS_class::root_path() . 'php/profs_handle_states.php'); include_once(Plgntls::root_path() . 'php/profs_handle_states.php');
include_once(PLGNTLS_class::root_path() . 'php/partners_register.php'); include_once(Plgntls::root_path() . 'php/partners_register.php');
include_once(PLGNTLS_class::root_path() . 'php/partners_page.php'); include_once(Plgntls::root_path() . 'php/partners_page.php');
include_once(PLGNTLS_class::root_path() . 'php/display_css.php'); include_once(Plgntls::root_path() . 'php/display_css.php');
include_once(PLGNTLS_class::root_path() . 'php/payments.php'); include_once(Plgntls::root_path() . 'php/payments.php');
include_once(PLGNTLS_class::root_path() . 'php/email_registration.php'); include_once(Plgntls::root_path() . 'php/email_registration.php');
include_once(PLGNTLS_class::root_path() . 'php/random_posts.php'); include_once(Plgntls::root_path() . 'php/random_posts.php');

View File

@@ -1,5 +1,4 @@
import { resultMessage } from './result_message.js'; import { resultMessage } from './result_message.js';
import { PLGNTLS_fetch } from '../../utils/plgntls_fetch.js';
/* /*

View File

@@ -1,6 +1,4 @@
import { resultMessage } from './result_message.js'; import { resultMessage } from './result_message.js';
import { PLGNTLS_fetch } from '../../utils/plgntls_fetch.js';
/* /*
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend * @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend

View File

@@ -1,13 +0,0 @@
//function PLGNTLS_fetch(url, options = {}) {
export function PLGNTLS_fetch(url, options = {}) {
console.log("inside PLGNTLS_fetch");
url = PLGNTLS_data.fetch_url + url;
options.headers = options.headers || {};
options.headers['X-WP-Nonce'] = PLGNTLS_data.fetch_nonce,
console.log("options:", options);
return fetch(url, options);
}

View File

@@ -14,7 +14,7 @@ if (!defined('ABSPATH')) {
* menu plugin * menu plugin
*/ */
function cipf_plugin_menu_CIPF() { function cipf_plugin_menu_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$menu_page_title = 'cipf'; $menu_page_title = 'cipf';
$menu_title = 'cipf'; $menu_title = 'cipf';
$menu_capability = 'manage_options'; $menu_capability = 'manage_options';
@@ -40,11 +40,11 @@ ajax
use $_POST['property_name'] use $_POST['property_name']
*/ */
//function cipfcard_menu_fetch_handler() { //function cipfcard_menu_fetch_handler() {
// PLGNTLS_class::debug_infos(); // Plgntls::debug_infos();
// return new WP_REST_Response('hello', 200); // return new WP_REST_Response('hello', 200);
//} //}
//function cipfcard_menu_endpoint() { //function cipfcard_menu_endpoint() {
// PLGNTLS_class::debug_infos(); // Plgntls::debug_infos();
// register_rest_route('plgntls', '/get_data', array( // register_rest_route('plgntls', '/get_data', array(
// 'methods' => 'POST', // 'methods' => 'POST',
// 'callback' => 'cipfcard_menu_fetch_handler', // 'callback' => 'cipfcard_menu_fetch_handler',

View File

@@ -12,8 +12,8 @@ if (!defined('ABSPATH')) {
function toggle_menu_CIPF($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback) { function toggle_menu_CIPF($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$toggle_menu = PLGNTLS_class::TOGGLE_ADMIN_MENU; $toggle_menu = Plgntls::TOGGLE_ADMIN_MENU;
if (false === get_option($toggle_menu['_name'])) { if (false === get_option($toggle_menu['_name'])) {
add_option($toggle_menu['_name'], $toggle_menu['hide'], '', 'no'); add_option($toggle_menu['_name'], $toggle_menu['hide'], '', 'no');
@@ -39,9 +39,9 @@ function toggle_menu_CIPF($menu_page_title, $menu_title, $menu_capability, $menu
* *
*/ */
function add_link_to_custer_plugin_CIPF($links) { function add_link_to_custer_plugin_CIPF($links) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$slug_toggle = PLGNTLS_class::SLUG_TOOGLE_ADMIN_MENU; $slug_toggle = Plgntls::SLUG_TOOGLE_ADMIN_MENU;
$toggle_menu = PLGNTLS_class::TOGGLE_ADMIN_MENU; $toggle_menu = Plgntls::TOGGLE_ADMIN_MENU;
$toggle = get_option($toggle_menu['_name']); $toggle = get_option($toggle_menu['_name']);
@@ -63,16 +63,16 @@ add_filter('plugin_action_links_cipf_plugin/cipf_plugin.php', 'add_link_to_custe
* *
*/ */
function toggle_custer_plugin_menu_CIPF() { function toggle_custer_plugin_menu_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$slug_toggle = PLGNTLS_class::SLUG_TOOGLE_ADMIN_MENU; $slug_toggle = Plgntls::SLUG_TOOGLE_ADMIN_MENU;
$toggle_menu = PLGNTLS_class::TOGGLE_ADMIN_MENU; $toggle_menu = Plgntls::TOGGLE_ADMIN_MENU;
global $wp; global $wp;
$current_slug = $wp->request; $current_slug = $wp->request;
if ($current_slug !== $slug_toggle['_name']) { if ($current_slug !== $slug_toggle['_name']) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$show = null; $show = null;
if (!isset($_GET)) { if (!isset($_GET)) {

View File

@@ -11,34 +11,34 @@ if (!defined('ABSPATH')) {
function add_plugin_content_CIPF() { function add_plugin_content_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*
* paypal * paypal
* *
*/ */
$admin_post_paypal = PLGNTLS_class::ADMIN_POST_PAYPAL; $admin_post_paypal = Plgntls::ADMIN_POST_PAYPAL;
$nonce_paypal = PLGNTLS_class::ADMIN_MENU_NONCE_PAYPAL; $nonce_paypal = Plgntls::ADMIN_MENU_NONCE_PAYPAL;
$paypal_credentials = get_paypal_options_CIPF(); $paypal_credentials = get_paypal_options_CIPF();
/* /*
* registration email * registration email
* *
*/ */
$admin_post_email_registration = PLGNTLS_class::ADMIN_POST_EMAIL_REGISTRATION; $admin_post_email_registration = Plgntls::ADMIN_POST_EMAIL_REGISTRATION;
$nonce_email = PLGNTLS_class::ADMIN_MENU_NONCE_EMAIL_REGISTRATION; $nonce_email = Plgntls::ADMIN_MENU_NONCE_EMAIL_REGISTRATION;
$email_registration = get_email_registration_option_CIPF(); $email_registration = get_email_registration_option_CIPF();
/* /*
* registration email * registration email
* *
*/ */
$admin_post_payment_messages = PLGNTLS_class::ADMIN_POST_PAYMENT_MESSAGES; $admin_post_payment_messages = Plgntls::ADMIN_POST_PAYMENT_MESSAGES;
$nonce_payment_messages = PLGNTLS_class::ADMIN_MENU_NONCE_PAYMENT_MESSAGES; $nonce_payment_messages = Plgntls::ADMIN_MENU_NONCE_PAYMENT_MESSAGES;
$payment_messages = get_payment_messages_option_CIPF(); $payment_messages = get_payment_messages_option_CIPF();
ob_start(); ob_start();
include(PLGNTLS_class::root_path() . '/html/menu/cipf_menu.html'); include(Plgntls::root_path() . '/html/menu/cipf_menu.html');
$html = ob_get_clean(); $html = ob_get_clean();
echo $html; echo $html;
} }
@@ -53,7 +53,7 @@ function add_plugin_content_CIPF() {
* *
*/ */
function redirect_menu_referer_CIPF($post) { function redirect_menu_referer_CIPF($post) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if (!isset($post)) { if (!isset($post)) {
wp_redirect(admin_url(), 301); wp_redirect(admin_url(), 301);
exit; exit;

View File

@@ -22,8 +22,8 @@ if (!defined('ABSPATH')) {
* *
*/ */
function change_email_registration_CIPF() { function change_email_registration_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$nonce_email = PLGNTLS_class::ADMIN_MENU_NONCE_EMAIL_REGISTRATION; $nonce_email = Plgntls::ADMIN_MENU_NONCE_EMAIL_REGISTRATION;
if (!isset($_POST[$nonce_email['_name']])) { if (!isset($_POST[$nonce_email['_name']])) {
redirect_menu_referer_CIPF($_POST); redirect_menu_referer_CIPF($_POST);
@@ -39,14 +39,14 @@ function change_email_registration_CIPF() {
redirect_menu_referer_CIPF($_POST); redirect_menu_referer_CIPF($_POST);
} }
add_action('admin_post_'.PLGNTLS_class::ADMIN_POST_EMAIL_REGISTRATION, 'change_email_registration_CIPF'); add_action('admin_post_'.Plgntls::ADMIN_POST_EMAIL_REGISTRATION, 'change_email_registration_CIPF');
function update_email_registration_option_CIPF($post) { function update_email_registration_option_CIPF($post) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*

View File

@@ -22,8 +22,8 @@ if (!defined('ABSPATH')) {
* *
*/ */
function change_payment_messages_CIPF() { function change_payment_messages_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$nonce_payment_messages = PLGNTLS_class::ADMIN_MENU_NONCE_PAYMENT_MESSAGES; $nonce_payment_messages = Plgntls::ADMIN_MENU_NONCE_PAYMENT_MESSAGES;
if (!isset($_POST[$nonce_payment_messages['_name']])) { if (!isset($_POST[$nonce_payment_messages['_name']])) {
redirect_menu_referer_CIPF($_POST); redirect_menu_referer_CIPF($_POST);
@@ -39,14 +39,14 @@ function change_payment_messages_CIPF() {
redirect_menu_referer_CIPF($_POST); redirect_menu_referer_CIPF($_POST);
} }
add_action('admin_post_'.PLGNTLS_class::ADMIN_POST_PAYMENT_MESSAGES, 'change_payment_messages_CIPF'); add_action('admin_post_'.Plgntls::ADMIN_POST_PAYMENT_MESSAGES, 'change_payment_messages_CIPF');
function update_payment_messages_option_CIPF($post) { function update_payment_messages_option_CIPF($post) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
error_log("post: " . json_encode($post)); error_log("post: " . json_encode($post));

View File

@@ -21,8 +21,8 @@ if (!defined('ABSPATH')) {
* *
*/ */
function paypal_credentials_CIPF() { function paypal_credentials_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$nonce_paypal = PLGNTLS_class::ADMIN_MENU_NONCE_PAYPAL; $nonce_paypal = Plgntls::ADMIN_MENU_NONCE_PAYPAL;
if (!isset($_POST[$nonce_paypal['_name']])) { if (!isset($_POST[$nonce_paypal['_name']])) {
redirect_menu_referer_CIPF($_POST); redirect_menu_referer_CIPF($_POST);
@@ -38,14 +38,14 @@ function paypal_credentials_CIPF() {
redirect_menu_referer_CIPF($_POST); redirect_menu_referer_CIPF($_POST);
} }
add_action('admin_post_'.PLGNTLS_class::ADMIN_POST_PAYPAL, 'paypal_credentials_CIPF'); add_action('admin_post_'.Plgntls::ADMIN_POST_PAYPAL, 'paypal_credentials_CIPF');
function update_paypal_credentials_CIPF($post) { function update_paypal_credentials_CIPF($post) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*

View File

@@ -12,7 +12,7 @@ if (!defined('ABSPATH')) {
function display_page_css_CIPF($user_id = null) { function display_page_css_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$css_for_states = array(); $css_for_states = array();
/* /*
@@ -91,8 +91,7 @@ function display_page_css_CIPF($user_id = null) {
$css_for_states[] = 'css/display_states/type_virement.css'; $css_for_states[] = 'css/display_states/type_virement.css';
} }
$cipf_states = new PLGNTLS_class(); Plgntls::add_to_front($css_for_states);
$cipf_states->add_to_front($css_for_states);
} }

View File

@@ -17,9 +17,9 @@ if (!defined('ABSPATH')) {
* *
*/ */
function send_registration_email_CIPF($send, $user) { function send_registration_email_CIPF($send, $user) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$role_partner = PLGNTLS_class::ROLE_PARTNER; $role_partner = Plgntls::ROLE_PARTNER;
$role_prof = PLGNTLS_class::ROLE_PROF; $role_prof = Plgntls::ROLE_PROF;
if (user_can($user, $role_prof)) { if (user_can($user, $role_prof)) {
$send = is_email_registration_prof_CIPF(); $send = is_email_registration_prof_CIPF();
@@ -46,7 +46,7 @@ add_filter( 'wp_send_new_user_notification_to_user', 'send_registration_email_CI
* *
*/ */
function filter_regitration_email_CIPF($wp_new_user_notification_email, $user, $blogname) { function filter_regitration_email_CIPF($wp_new_user_notification_email, $user, $blogname) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$wp_new_user_notification_email['message'] = get_email_registration_CIPF(); $wp_new_user_notification_email['message'] = get_email_registration_CIPF();
return $wp_new_user_notification_email; return $wp_new_user_notification_email;
} }
@@ -64,8 +64,8 @@ add_filter('wp_new_user_notification_email', 'filter_regitration_email_CIPF', 21
*/ */
function set_email_registration_CIPF($email, $is_email_prof, $is_email_partner) { function set_email_registration_CIPF($email, $is_email_prof, $is_email_partner) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$option_email = PLGNTLS_class::OPTION_EMAIL; $option_email = Plgntls::OPTION_EMAIL;
$option_data = array(); $option_data = array();
$option_data['email'] = $email; $option_data['email'] = $email;
@@ -77,8 +77,8 @@ function set_email_registration_CIPF($email, $is_email_prof, $is_email_partner)
function get_email_registration_option_CIPF() { function get_email_registration_option_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$option_email = PLGNTLS_class::OPTION_EMAIL; $option_email = Plgntls::OPTION_EMAIL;
$email_option_serialized = get_option($option_email['_name']); $email_option_serialized = get_option($option_email['_name']);
if (false === $email_option_serialized) { if (false === $email_option_serialized) {
@@ -93,18 +93,18 @@ function get_email_registration_option_CIPF() {
function get_email_registration_CIPF() { function get_email_registration_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$email_option = get_email_registration_option_CIPF(); $email_option = get_email_registration_option_CIPF();
return $email_option['email']; return $email_option['email'];
} }
function is_email_registration_prof_CIPF() { function is_email_registration_prof_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$email_option = get_email_registration_option_CIPF(); $email_option = get_email_registration_option_CIPF();
return $email_option['is_email_prof']; return $email_option['is_email_prof'];
} }
function is_email_registration_partner_CIPF() { function is_email_registration_partner_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$email_option = get_email_registration_option_CIPF(); $email_option = get_email_registration_option_CIPF();
return $email_option['is_email_partner']; return $email_option['is_email_partner'];
} }

View File

@@ -15,9 +15,9 @@ if (!defined('ABSPATH')) {
* hide admin bar if access a front page and is not an admin * hide admin bar if access a front page and is not an admin
*/ */
function hide_admin_bar_CIPF() { function hide_admin_bar_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$role_admin = PLGNTLS_class::ROLE_ADMIN; $role_admin = Plgntls::ROLE_ADMIN;
$role_fipf = PLGNTLS_class::ROLE_FIPF; $role_fipf = Plgntls::ROLE_FIPF;
/* /*
@@ -27,7 +27,7 @@ function hide_admin_bar_CIPF() {
if (is_admin()) { if (is_admin()) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*
@@ -53,9 +53,9 @@ add_action('after_setup_theme', 'hide_admin_bar_CIPF');
* *
*/ */
function restrict_admin_access_CIPF() { function restrict_admin_access_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$role_admin = PLGNTLS_class::ROLE_ADMIN; $role_admin = Plgntls::ROLE_ADMIN;
$role_fipf = PLGNTLS_class::ROLE_FIPF; $role_fipf = Plgntls::ROLE_FIPF;
/* /*
* this concerns logged_in users, for admin page * this concerns logged_in users, for admin page
@@ -67,7 +67,7 @@ function restrict_admin_access_CIPF() {
if (!is_admin()) { if (!is_admin()) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*
* some roles are allowed to access the admin panel * some roles are allowed to access the admin panel

View File

@@ -23,7 +23,7 @@ if (!defined('ABSPATH')) {
* - $menu_redirect = 'www.un_autre_site.net/contact' -> https://www.un_autre_site.net/contact * - $menu_redirect = 'www.un_autre_site.net/contact' -> https://www.un_autre_site.net/contact
*/ */
function change_menu_logout($items){ function change_menu_logout($items){
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$menu_title = 'special logout'; $menu_title = 'special logout';
// quelques urls utiles : // quelques urls utiles :

View File

@@ -17,8 +17,8 @@ if (!defined('ABSPATH')) {
* *
*/ */
function partner_page_scripts_CIPF() { function partner_page_scripts_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$role_partner = PLGNTLS_class::ROLE_PARTNER; $role_partner = Plgntls::ROLE_PARTNER;
/* /*
* dont do anything if : * dont do anything if :
@@ -37,7 +37,7 @@ function partner_page_scripts_CIPF() {
if (is_null($post)) { if (is_null($post)) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$current_post_author = (int)($post->post_author); $current_post_author = (int)($post->post_author);
$current_user_id = (int)get_current_user_id(); $current_user_id = (int)get_current_user_id();
if ($current_user_id !== $current_post_author) { if ($current_user_id !== $current_post_author) {
@@ -48,8 +48,7 @@ function partner_page_scripts_CIPF() {
* on partner own page, load css * on partner own page, load css
* *
*/ */
$cipf_partner = new PLGNTLS_class(); Plgntls::add_to_front(array('css/partner_page.css'));
$cipf_partner->add_to_front(array('css/partner_page.css'));
} }
add_action('wp_enqueue_scripts', 'partner_page_scripts_CIPF', 11); add_action('wp_enqueue_scripts', 'partner_page_scripts_CIPF', 11);

View File

@@ -18,10 +18,10 @@ if (!defined('ABSPATH')) {
* *
*/ */
function add_fields_register_CIPF($args) { function add_fields_register_CIPF($args) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$role_partner = PLGNTLS_class::ROLE_PARTNER; $role_partner = Plgntls::ROLE_PARTNER;
$slug_partner_registration = PLGNTLS_class::SLUG_PARTNER_REGISTRATION; $slug_partner_registration = Plgntls::SLUG_PARTNER_REGISTRATION;
$input_hidden_role = PLGNTLS_class::INPUT_HIDDEN_ROLE; $input_hidden_role = Plgntls::INPUT_HIDDEN_ROLE;
/* /*
* compare current slug to partner-register slug * compare current slug to partner-register slug
@@ -46,9 +46,9 @@ add_action('xoo_el_register_add_fields', 'add_fields_register_CIPF');
* *
*/ */
function add_role_partners_CIPF($customer_data){ function add_role_partners_CIPF($customer_data){
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$role_partner = PLGNTLS_class::ROLE_PARTNER; $role_partner = Plgntls::ROLE_PARTNER;
$input_hidden_role = PLGNTLS_class::INPUT_HIDDEN_ROLE; $input_hidden_role = Plgntls::INPUT_HIDDEN_ROLE;
/* /*
* check query of form submit * check query of form submit

View File

@@ -12,8 +12,8 @@ if (!defined('ABSPATH')) {
function set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret) { function set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$option_paypal = PLGNTLS_class::OPTION_PAYPAL; $option_paypal = Plgntls::OPTION_PAYPAL;
$option_data = array(); $option_data = array();
$option_data['is_sandbox'] = $is_sandbox; $option_data['is_sandbox'] = $is_sandbox;
@@ -28,8 +28,8 @@ function set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret) {
function get_paypal_options_CIPF() { function get_paypal_options_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$option_paypal = PLGNTLS_class::OPTION_PAYPAL; $option_paypal = Plgntls::OPTION_PAYPAL;
$paypal_credentials_serialized = get_option($option_paypal['_name']); $paypal_credentials_serialized = get_option($option_paypal['_name']);
if (false === $paypal_credentials_serialized) { if (false === $paypal_credentials_serialized) {
@@ -46,26 +46,26 @@ function get_paypal_options_CIPF() {
function get_paypal_client_id_CIPF() { function get_paypal_client_id_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF(); $paypal_credentials = get_paypal_options_CIPF();
return $paypal_credentials['client_id']; return $paypal_credentials['client_id'];
} }
function get_paypal_client_secret_CIPF() { function get_paypal_client_secret_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF(); $paypal_credentials = get_paypal_options_CIPF();
return $paypal_credentials['client_secret']; return $paypal_credentials['client_secret'];
} }
function get_paypal_api_base_url_CIPF() { function get_paypal_api_base_url_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF(); $paypal_credentials = get_paypal_options_CIPF();
$paypal_base_url = ''; $paypal_base_url = '';
$is_sandbox = $paypal_credentials['is_sandbox']; $is_sandbox = $paypal_credentials['is_sandbox'];
if ($is_sandbox) { if ($is_sandbox) {
$paypal_base_url = PLGNTLS_class::PAYPAL_SBOX_API_BASE_URL; $paypal_base_url = Plgntls::PAYPAL_SBOX_API_BASE_URL;
} }
else { else {
$paypal_base_url = PLGNTLS_class::PAYPAL_LIVE_API_BASE_URL; $paypal_base_url = Plgntls::PAYPAL_LIVE_API_BASE_URL;
} }
return $paypal_base_url; return $paypal_base_url;
} }
@@ -79,8 +79,8 @@ function get_paypal_api_base_url_CIPF() {
*/ */
function set_payment_messages_option_CIPF($success, $failure) { function set_payment_messages_option_CIPF($success, $failure) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$option_payment = PLGNTLS_class::OPTION_PAYMENT; $option_payment = Plgntls::OPTION_PAYMENT;
$option_data = array(); $option_data = array();
$option_data['success'] = $success; $option_data['success'] = $success;
@@ -90,8 +90,8 @@ function set_payment_messages_option_CIPF($success, $failure) {
} }
function get_payment_messages_option_CIPF() { function get_payment_messages_option_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$option_payment = PLGNTLS_class::OPTION_PAYMENT; $option_payment = Plgntls::OPTION_PAYMENT;
$payment_option_serialized = get_option($option_payment['_name']); $payment_option_serialized = get_option($option_payment['_name']);
if (false === $payment_option_serialized) { if (false === $payment_option_serialized) {
@@ -103,13 +103,13 @@ function get_payment_messages_option_CIPF() {
} }
function get_payment_message_success_CIPF() { function get_payment_message_success_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$payment_option = get_payment_messages_option_CIPF(); $payment_option = get_payment_messages_option_CIPF();
return $payment_option['success']; return $payment_option['success'];
} }
function get_payment_message_failure_CIPF() { function get_payment_message_failure_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$payment_option = get_payment_messages_option_CIPF(); $payment_option = get_payment_messages_option_CIPF();
return $payment_option['failure']; return $payment_option['failure'];
} }

View File

@@ -17,14 +17,14 @@ if (!defined('ABSPATH')) {
* *
*/ */
function payment_page_checks_CIPF() { function payment_page_checks_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE; $slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
// check the slug // check the slug
if (!is_page($slug_paypal_page)) { if (!is_page($slug_paypal_page)) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
// get the user id // get the user id
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@@ -42,9 +42,9 @@ add_action('wp', 'payment_page_checks_CIPF');
* *
*/ */
function payment_page_redirects_CIPF() { function payment_page_redirects_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE; $slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
$role_prof = PLGNTLS_class::ROLE_PROF; $role_prof = Plgntls::ROLE_PROF;
// don't redirect if it is the divi builder mode // don't redirect if it is the divi builder mode
if (et_fb_is_enabled()) { if (et_fb_is_enabled()) {
@@ -54,7 +54,7 @@ function payment_page_redirects_CIPF() {
if (!is_page($slug_paypal_page)) { if (!is_page($slug_paypal_page)) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*
* if prof, don't redirect * if prof, don't redirect
@@ -77,14 +77,14 @@ add_action('template_redirect', 'payment_page_redirects_CIPF');
* *
*/ */
function payment_page_scripts_CIPF() { function payment_page_scripts_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE; $slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
// check the slug // check the slug
if (!is_page($slug_paypal_page)) { if (!is_page($slug_paypal_page)) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
// get the user id // get the user id
$user_id = get_current_user_id(); $user_id = get_current_user_id();

View File

@@ -9,15 +9,15 @@ if (!defined('ABSPATH')) {
include_once(PLGNTLS_class::root_path() . '/php/utils/http_errors.php'); include_once(Plgntls::root_path() . '/php/utils/http_errors.php');
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_utils.php'); include_once(Plgntls::root_path() . '/php/paypal/route_api_utils.php');
include_once(PLGNTLS_class::root_path() . '/php/paypal/user_can_pay.php'); include_once(Plgntls::root_path() . '/php/paypal/user_can_pay.php');
include_once(PLGNTLS_class::root_path() . '/php/paypal/update_user_payment.php'); include_once(Plgntls::root_path() . '/php/paypal/update_user_payment.php');
include_once(PLGNTLS_class::root_path() . '/php/paypal/shortcode.php'); include_once(Plgntls::root_path() . '/php/paypal/shortcode.php');
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_orders.php'); include_once(Plgntls::root_path() . '/php/paypal/route_api_orders.php');
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_orders_capture.php'); include_once(Plgntls::root_path() . '/php/paypal/route_api_orders_capture.php');
include_once(PLGNTLS_class::root_path() . '/php/paypal/routes.php'); include_once(Plgntls::root_path() . '/php/paypal/routes.php');
include_once(PLGNTLS_class::root_path() . '/php/paypal/payment_page.php'); include_once(Plgntls::root_path() . '/php/paypal/payment_page.php');

View File

@@ -20,7 +20,7 @@ if (!defined('ABSPATH')) {
* *
*/ */
function handle_orders_request_CIPF($request_data) { function handle_orders_request_CIPF($request_data) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
// declaring outside the try..catch scope // declaring outside the try..catch scope
$order_response = array(); $order_response = array();
@@ -90,9 +90,9 @@ function handle_orders_request_CIPF($request_data) {
* *
*/ */
function create_order_CIPF() { function create_order_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$paypal_api_base_url = get_paypal_api_base_url_CIPF(); $paypal_api_base_url = get_paypal_api_base_url_CIPF();
$acf_card_price_total = PLGNTLS_class::ACF_CARD_PRICE_TOTAL; $acf_card_price_total = Plgntls::ACF_CARD_PRICE_TOTAL;
$access_token = generate_access_token_CIPF(); $access_token = generate_access_token_CIPF();

View File

@@ -11,7 +11,7 @@ if (!defined('ABSPATH')) {
function handle_orders_capture_request_CIPF($request) { function handle_orders_capture_request_CIPF($request) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$order_id = $request['orderID']; $order_id = $request['orderID'];
// declaring outside the try..catch scope // declaring outside the try..catch scope
$response_json = array(); $response_json = array();
@@ -75,7 +75,7 @@ function handle_orders_capture_request_CIPF($request) {
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture * @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
*/ */
function capture_order_CIPF($order_id) { function capture_order_CIPF($order_id) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$paypal_api_base_url = get_paypal_api_base_url_CIPF(); $paypal_api_base_url = get_paypal_api_base_url_CIPF();
$access_token = generate_access_token_CIPF(); $access_token = generate_access_token_CIPF();
$url = $paypal_api_base_url . '/v2/checkout/orders/' . $order_id . '/capture'; $url = $paypal_api_base_url . '/v2/checkout/orders/' . $order_id . '/capture';

View File

@@ -14,7 +14,7 @@ if (!defined('ABSPATH')) {
* *
*/ */
function handle_json_response_CIPF($response, $ch) { function handle_json_response_CIPF($response, $ch) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if ($response === false) if ($response === false)
throw new HttpException('cURL error: ' . curl_error($ch), 502); throw new HttpException('cURL error: ' . curl_error($ch), 502);
@@ -33,7 +33,7 @@ function handle_json_response_CIPF($response, $ch) {
); );
} }
function handle_response_CIPF($response) { function handle_response_CIPF($response) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
try try
{ {
// Decode JSON response // Decode JSON response
@@ -60,7 +60,7 @@ function handle_response_CIPF($response) {
* @see https://developer.paypal.com/api/rest/authentication/ * @see https://developer.paypal.com/api/rest/authentication/
*/ */
function generate_access_token_CIPF() { function generate_access_token_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$paypal_client_id = get_paypal_client_id_CIPF(); $paypal_client_id = get_paypal_client_id_CIPF();
$paypal_client_secret = get_paypal_client_secret_CIPF(); $paypal_client_secret = get_paypal_client_secret_CIPF();
$paypal_api_base_url = get_paypal_api_base_url_CIPF(); $paypal_api_base_url = get_paypal_api_base_url_CIPF();

View File

@@ -12,11 +12,11 @@ if (!defined('ABSPATH')) {
// handling routes and endpoints // handling routes and endpoints
// diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573 // diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573
function routes_endpoints_CIPF() { function routes_endpoints_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if (is_admin()) { if (is_admin()) {
return; return;
} }
$base_rest_route = PLGNTLS_class::URL_BASE_REST_ROUTE; $base_rest_route = Plgntls::URL_BASE_REST_ROUTE;
register_rest_route($base_rest_route, '/orders', array( register_rest_route($base_rest_route, '/orders', array(
'methods' => 'POST', 'methods' => 'POST',
'callback' => 'handle_orders_request_CIPF', 'callback' => 'handle_orders_request_CIPF',

View File

@@ -16,16 +16,15 @@ if (!defined('ABSPATH')) {
* call to paypal_shortcode_content() * call to paypal_shortcode_content()
*/ */
function paypal_shortcode_content_CIPF() { function paypal_shortcode_content_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$slug_paypal_redirection_success = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_SUCCESS; $slug_paypal_redirection_success = Plgntls::SLUG_PAYPAL_REDIRECTION_SUCCESS;
$slug_paypal_redirection_failure = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_FAILURE; $slug_paypal_redirection_failure = Plgntls::SLUG_PAYPAL_REDIRECTION_FAILURE;
$paypal_client_id = get_paypal_client_id_CIPF(); $paypal_client_id = get_paypal_client_id_CIPF();
$paypal_message_success = get_payment_message_success_CIPF(); $paypal_message_success = get_payment_message_success_CIPF();
$paypal_message_failure = get_payment_message_failure_CIPF(); $paypal_message_failure = get_payment_message_failure_CIPF();
// if (!can_pay_now_CIPF()) // if (!can_pay_now_CIPF())
// return no_payment_CIPF(); // return no_payment_CIPF();
$cipfcard_paypal = new PLGNTLS_class();
$pp_client_id = $paypal_client_id; $pp_client_id = $paypal_client_id;
$pp_sdk_currency = "EUR"; $pp_sdk_currency = "EUR";
@@ -35,7 +34,7 @@ function paypal_shortcode_content_CIPF() {
$paypal_redirection_success = home_url() . '/' . $slug_paypal_redirection_success; $paypal_redirection_success = home_url() . '/' . $slug_paypal_redirection_success;
$paypal_redirection_failure = home_url() . '/' . $slug_paypal_redirection_failure; $paypal_redirection_failure = home_url() . '/' . $slug_paypal_redirection_failure;
$added_to_front = $cipfcard_paypal->add_to_front( $added_to_front = Plgntls::add_to_front(
array( array(
$pp_sdk_url, $pp_sdk_url,
array("js/paypal/paypal.js", 'type'=>'module'), array("js/paypal/paypal.js", 'type'=>'module'),
@@ -55,7 +54,7 @@ add_shortcode('cipf_paypal_shortcode', 'paypal_shortcode_content_CIPF');
function no_payment_CIPF() { function no_payment_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return; return;
} }

View File

@@ -35,9 +35,9 @@ if (!defined('ABSPATH')) {
* *
*/ */
function update_user_pre_order_CIPF($message) { function update_user_pre_order_CIPF($message) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE; $acf_payment_status = Plgntls::ACF_CARD_PAYMENT_STATE;
$meta_order_id = PLGNTLS_class::META_ORDER_ID; $meta_order_id = Plgntls::META_ORDER_ID;
$order_id = $message->id; $order_id = $message->id;
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@@ -71,7 +71,7 @@ function update_user_pre_order_CIPF($message) {
* *
*/ */
function update_user_post_capture_CIPF($message) { function update_user_post_capture_CIPF($message) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$order_id = $message->id; $order_id = $message->id;
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@@ -127,8 +127,8 @@ function update_user_post_capture_CIPF($message) {
* *
*/ */
function failure_payment_for_user_CIPF($user_id, $order_id, $status) { function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$meta_order_id = PLGNTLS_class::META_ORDER_ID; $meta_order_id = Plgntls::META_ORDER_ID;
$acf_id = 'user_'.$user_id; $acf_id = 'user_'.$user_id;
@@ -149,8 +149,8 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
* *
*/ */
function success_payment_for_user_CIPF($user_id, $order_id) { function success_payment_for_user_CIPF($user_id, $order_id) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$meta_order_id = PLGNTLS_class::META_ORDER_ID; $meta_order_id = Plgntls::META_ORDER_ID;
$acf_id = 'user_'.$user_id; $acf_id = 'user_'.$user_id;
@@ -185,9 +185,9 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
* *
*/ */
function find_user_with_order_id_CIPF($current_user_id, $order_id) { function find_user_with_order_id_CIPF($current_user_id, $order_id) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$meta_order_id = PLGNTLS_class::META_ORDER_ID; $meta_order_id = Plgntls::META_ORDER_ID;
$role_prof = PLGNTLS_class::ROLE_PROF; $role_prof = Plgntls::ROLE_PROF;
$user_metas = get_user_meta($current_user_id, $meta_order_id, false); $user_metas = get_user_meta($current_user_id, $meta_order_id, false);
if (in_array($order_id, $user_metas)) { if (in_array($order_id, $user_metas)) {

View File

@@ -42,13 +42,13 @@ function get_acf_value_CIPF($acf_field, $acf_id) {
* *
*/ */
function check_can_pay_CIPF() { function check_can_pay_CIPF() {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_payment_method = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD; $acf_card_payment_method = Plgntls::ACF_CARD_PAYMENT_METHOD;
$acf_card_price_choice = PLGNTLS_class::ACF_CARD_PRICE_CHOICE; $acf_card_price_choice = Plgntls::ACF_CARD_PRICE_CHOICE;
$acf_card_price_delivery = PLGNTLS_class::ACF_CARD_PRICE_DELIVERY; $acf_card_price_delivery = Plgntls::ACF_CARD_PRICE_DELIVERY;
$acf_card_price_total = PLGNTLS_class::ACF_CARD_PRICE_TOTAL; $acf_card_price_total = Plgntls::ACF_CARD_PRICE_TOTAL;
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION; $acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
$card_renew_period = PLGNTLS_class::CARD_RENEW_PERIOD; $card_renew_period = Plgntls::CARD_RENEW_PERIOD;
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
$user_id = get_current_user_id(); $user_id = get_current_user_id();

View File

@@ -17,8 +17,8 @@ if (!defined('ABSPATH')) {
* *
*/ */
function get_date_limit_CIPF($user_id = null) { function get_date_limit_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION; $acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
/* /*
* define ids * define ids
@@ -71,7 +71,7 @@ function get_date_limit_CIPF($user_id = null) {
* *
*/ */
function card_date_diff_CIPF($user_id = null) { function card_date_diff_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*
* get date limit as DateTime object * get date limit as DateTime object
* *
@@ -99,7 +99,7 @@ function card_date_diff_CIPF($user_id = null) {
* *
*/ */
function is_card_date_expired_CIPF($user_id = null) { function is_card_date_expired_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*
* define user_id * define user_id
@@ -131,8 +131,8 @@ function is_card_date_expired_CIPF($user_id = null) {
* *
*/ */
function card_date_exists_CIPF($user_id = null) { function card_date_exists_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION; $acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
/* /*
* define ids * define ids
@@ -168,9 +168,9 @@ function card_date_exists_CIPF($user_id = null) {
* *
*/ */
function update_card_expiration_CIPF($user_id = null) { function update_card_expiration_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION; $acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
$card_duration = PLGNTLS_class::CARD_VALIDITY_TIME; $card_duration = Plgntls::CARD_VALIDITY_TIME;
/* /*
* define acf id and acf date format * define acf id and acf date format

View File

@@ -16,9 +16,9 @@ if (!defined('ABSPATH')) {
* *
*/ */
function prof_after_form_commande_CIPF($form_id, $post_array, $form_type) { function prof_after_form_commande_CIPF($form_id, $post_array, $form_type) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_account_state = PLGNTLS_class::ACF_ACCOUNT_STATE; $acf_account_state = Plgntls::ACF_ACCOUNT_STATE;
$form_prof_commande_id = PLGNTLS_class::FORM_PROF_COMMANDE_ID; $form_prof_commande_id = Plgntls::FORM_PROF_COMMANDE_ID;
if ($form_prof_commande_id !== $form_id) { if ($form_prof_commande_id !== $form_id) {
return; return;
@@ -75,9 +75,9 @@ add_action('df_after_process', 'prof_after_form_commande_CIPF', 10, 3);
* *
*/ */
function prof_form_restrictions_CIPF(){ function prof_form_restrictions_CIPF(){
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$slug_command_card = PLGNTLS_class::SLUG_COMMAND_CARD; $slug_command_card = Plgntls::SLUG_COMMAND_CARD;
$role_prof = PLGNTLS_class::ROLE_PROF; $role_prof = Plgntls::ROLE_PROF;
// don't redirect if it is the divi builder mode // don't redirect if it is the divi builder mode
if (et_fb_is_enabled()) { if (et_fb_is_enabled()) {
@@ -86,7 +86,7 @@ function prof_form_restrictions_CIPF(){
if (!is_page($slug_command_card)) { if (!is_page($slug_command_card)) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*
* if prof, don't redirect * if prof, don't redirect
@@ -108,12 +108,12 @@ add_action('template_redirect', 'prof_form_restrictions_CIPF');
* *
*/ */
function renew_page_filter_message_CIPF(){ function renew_page_filter_message_CIPF(){
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$slug_command_card = PLGNTLS_class::SLUG_COMMAND_CARD; $slug_command_card = Plgntls::SLUG_COMMAND_CARD;
if (!is_page($slug_command_card)) if (!is_page($slug_command_card))
return; return;
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$user_id = get_current_user_id(); $user_id = get_current_user_id();

View File

@@ -23,7 +23,7 @@ if (!defined('ABSPATH')) {
* *
*/ */
function handle_transfert_validation_CIPF($user_id) { function handle_transfert_validation_CIPF($user_id) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if (false === is_transfert_success_CIPF($user_id)) { if (false === is_transfert_success_CIPF($user_id)) {
return; return;
} }
@@ -44,7 +44,7 @@ function handle_transfert_validation_CIPF($user_id) {
* *
*/ */
function handle_card_expire_CIPF($user_id) { function handle_card_expire_CIPF($user_id) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if (false === card_date_exists_CIPF($user_id)) { if (false === card_date_exists_CIPF($user_id)) {
return; return;
} }

View File

@@ -16,9 +16,9 @@ if (!defined('ABSPATH')) {
* *
*/ */
function prof_after_form_transfert_validation_CIPF($form_id, $post_array, $form_type) { function prof_after_form_transfert_validation_CIPF($form_id, $post_array, $form_type) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_account_state = PLGNTLS_class::ACF_ACCOUNT_STATE; $acf_account_state = Plgntls::ACF_ACCOUNT_STATE;
$form_prof_transfert_id = PLGNTLS_class::FORM_PROF_TRANSFERT_ID; $form_prof_transfert_id = Plgntls::FORM_PROF_TRANSFERT_ID;
if ($form_prof_transfert_id !== $form_id) { if ($form_prof_transfert_id !== $form_id) {
return; return;
@@ -41,12 +41,12 @@ add_action('df_after_process', 'prof_after_form_transfert_validation_CIPF', 10,
* *
*/ */
function prof_profil_check_CIPF() { function prof_profil_check_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
// is an author page // is an author page
if (!is_author()) if (!is_author())
return; return;
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
// the way to find the id of the author of an author_page // the way to find the id of the author of an author_page
$author_id = get_queried_object_id(); $author_id = get_queried_object_id();
@@ -64,10 +64,10 @@ add_action('wp', 'prof_profil_check_CIPF', 11);
* *
*/ */
function prof_profil_redirects_CIPF() { function prof_profil_redirects_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$role_fipf = PLGNTLS_class::ROLE_FIPF; $role_fipf = Plgntls::ROLE_FIPF;
$role_admin = PLGNTLS_class::ROLE_ADMIN; $role_admin = Plgntls::ROLE_ADMIN;
$role_partner = PLGNTLS_class::ROLE_PARTNER; $role_partner = Plgntls::ROLE_PARTNER;
// is an author page // is an author page
if (!is_author()) if (!is_author())
@@ -76,7 +76,7 @@ function prof_profil_redirects_CIPF() {
if (et_fb_is_enabled()) { if (et_fb_is_enabled()) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
/* /*
@@ -130,12 +130,12 @@ add_action('template_redirect', 'prof_profil_redirects_CIPF', 11);
* *
*/ */
function prof_profil_scripts_CIPF() { function prof_profil_scripts_CIPF() {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
// is an author page // is an author page
if (!is_author()) if (!is_author())
return; return;
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
// the way to find the id of the author of an author_page // the way to find the id of the author of an author_page
$author_id = get_queried_object_id(); $author_id = get_queried_object_id();

View File

@@ -44,7 +44,7 @@ if (!defined('ABSPATH')) {
function get_field_init_CIPF($acf_field_name, $acf_id) { function get_field_init_CIPF($acf_field_name, $acf_id) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_state = get_field($acf_field_name, $acf_id); $acf_state = get_field($acf_field_name, $acf_id);
if ($acf_state !== null) { if ($acf_state !== null) {
return $acf_state; return $acf_state;
@@ -80,7 +80,7 @@ function get_field_init_CIPF($acf_field_name, $acf_id) {
* *
*/ */
function is_acf_state_CIPF($acf_field, $state_name, $user_id = null) { function is_acf_state_CIPF($acf_field, $state_name, $user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if (is_null($user_id)) { if (is_null($user_id)) {
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@@ -108,7 +108,7 @@ function is_acf_state_CIPF($acf_field, $state_name, $user_id = null) {
return false; return false;
} }
function set_acf_state_CIPF($acf_field, $state_name, $user_id = null) { function set_acf_state_CIPF($acf_field, $state_name, $user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if (is_null($user_id)) { if (is_null($user_id)) {
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@@ -137,37 +137,37 @@ function set_acf_state_CIPF($acf_field, $state_name, $user_id = null) {
* *
*/ */
function is_account_state_CIPF($state_name, $user_id = null) { function is_account_state_CIPF($state_name, $user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_account_state = PLGNTLS_class::ACF_ACCOUNT_STATE; $acf_account_state = Plgntls::ACF_ACCOUNT_STATE;
return is_acf_state_CIPF($acf_account_state, $state_name, $user_id); return is_acf_state_CIPF($acf_account_state, $state_name, $user_id);
} }
function is_account_new_CIPF($user_id = null) { function is_account_new_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_account_state_CIPF('new', $user_id); return is_account_state_CIPF('new', $user_id);
} }
function is_account_to_pay_CIPF($user_id = null) { function is_account_to_pay_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_account_state_CIPF('to_pay', $user_id); return is_account_state_CIPF('to_pay', $user_id);
} }
function is_account_valid_CIPF($user_id = null) { function is_account_valid_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_account_state_CIPF('valid', $user_id); return is_account_state_CIPF('valid', $user_id);
} }
function is_account_waiting_invalid_CIPF($user_id = null) { function is_account_waiting_invalid_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_account_state_CIPF('waiting_invalid', $user_id); return is_account_state_CIPF('waiting_invalid', $user_id);
} }
function is_account_waiting_valid_CIPF($user_id = null) { function is_account_waiting_valid_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_account_state_CIPF('waiting_valid', $user_id); return is_account_state_CIPF('waiting_valid', $user_id);
} }
function is_account_expired_CIPF($user_id = null) { function is_account_expired_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_account_state_CIPF('expired', $user_id); return is_account_state_CIPF('expired', $user_id);
} }
// additional : check both waitings // additional : check both waitings
function is_account_waiting_transfert_CIPF($user_id = null) { function is_account_waiting_transfert_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if (is_account_waiting_valid_CIPF($user_id)) { if (is_account_waiting_valid_CIPF($user_id)) {
return true; return true;
} }
@@ -180,32 +180,32 @@ function is_account_waiting_transfert_CIPF($user_id = null) {
* setters : * setters :
*/ */
function set_account_state_CIPF($state_name, $user_id = null) { function set_account_state_CIPF($state_name, $user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_account_state = PLGNTLS_class::ACF_ACCOUNT_STATE; $acf_account_state = Plgntls::ACF_ACCOUNT_STATE;
set_acf_state_CIPF($acf_account_state, $state_name, $user_id); set_acf_state_CIPF($acf_account_state, $state_name, $user_id);
} }
function set_account_new_CIPF($user_id = null) { function set_account_new_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_account_state_CIPF('new', $user_id); set_account_state_CIPF('new', $user_id);
} }
function set_account_to_pay_CIPF($user_id = null) { function set_account_to_pay_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_account_state_CIPF('to_pay', $user_id); set_account_state_CIPF('to_pay', $user_id);
} }
function set_account_valid_CIPF($user_id = null) { function set_account_valid_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_account_state_CIPF('valid', $user_id); set_account_state_CIPF('valid', $user_id);
} }
function set_account_waiting_invalid_CIPF($user_id = null) { function set_account_waiting_invalid_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_account_state_CIPF('waiting_invalid', $user_id); set_account_state_CIPF('waiting_invalid', $user_id);
} }
function set_account_waiting_valid_CIPF($user_id = null) { function set_account_waiting_valid_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_account_state_CIPF('waiting_valid', $user_id); set_account_state_CIPF('waiting_valid', $user_id);
} }
function set_account_expired_CIPF($user_id = null) { function set_account_expired_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_account_state_CIPF('expired', $user_id); set_account_state_CIPF('expired', $user_id);
} }
@@ -221,23 +221,23 @@ function set_account_expired_CIPF($user_id = null) {
* *
*/ */
function is_card_new_CIPF($user_id = null) { function is_card_new_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE; $acf_card_state = Plgntls::ACF_CARD_STATE;
return is_acf_state_CIPF($acf_card_state, 'new', $user_id); return is_acf_state_CIPF($acf_card_state, 'new', $user_id);
} }
function is_card_renew_CIPF($user_id = null) { function is_card_renew_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE; $acf_card_state = Plgntls::ACF_CARD_STATE;
return is_acf_state_CIPF($acf_card_state, 'renew', $user_id); return is_acf_state_CIPF($acf_card_state, 'renew', $user_id);
} }
function set_card_new_CIPF($user_id = null) { function set_card_new_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE; $acf_card_state = Plgntls::ACF_CARD_STATE;
set_acf_state_CIPF($acf_card_state, 'new', $user_id); set_acf_state_CIPF($acf_card_state, 'new', $user_id);
} }
function set_card_renew_CIPF($user_id = null) { function set_card_renew_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE; $acf_card_state = Plgntls::ACF_CARD_STATE;
set_acf_state_CIPF($acf_card_state, 'renew', $user_id); set_acf_state_CIPF($acf_card_state, 'renew', $user_id);
} }
@@ -253,13 +253,13 @@ function set_card_renew_CIPF($user_id = null) {
* *
*/ */
function is_payment_method_paypal_CIPF($user_id = null) { function is_payment_method_paypal_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_payment_method = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD; $acf_card_payment_method = Plgntls::ACF_CARD_PAYMENT_METHOD;
return is_acf_state_CIPF($acf_card_payment_method, 'paypal', $user_id); return is_acf_state_CIPF($acf_card_payment_method, 'paypal', $user_id);
} }
function is_payment_method_transfert_CIPF($user_id = null) { function is_payment_method_transfert_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_payment_method = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD; $acf_card_payment_method = Plgntls::ACF_CARD_PAYMENT_METHOD;
return is_acf_state_CIPF($acf_card_payment_method, 'transfert', $user_id); return is_acf_state_CIPF($acf_card_payment_method, 'transfert', $user_id);
} }
@@ -279,48 +279,48 @@ function is_payment_method_transfert_CIPF($user_id = null) {
* *
*/ */
function is_payment_state_CIPF($type, $user_id = null) { function is_payment_state_CIPF($type, $user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_payment_state = PLGNTLS_class::ACF_CARD_PAYMENT_STATE; $acf_card_payment_state = Plgntls::ACF_CARD_PAYMENT_STATE;
return is_acf_state_CIPF($acf_card_payment_state, $type, $user_id); return is_acf_state_CIPF($acf_card_payment_state, $type, $user_id);
} }
function is_payment_started_CIPF($user_id = null) { function is_payment_started_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_payment_state_CIPF('started', $user_id); return is_payment_state_CIPF('started', $user_id);
} }
function is_payment_success_CIPF($user_id = null) { function is_payment_success_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_payment_state_CIPF('success', $user_id); return is_payment_state_CIPF('success', $user_id);
} }
function is_payment_failure_CIPF($user_id = null) { function is_payment_failure_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_payment_state_CIPF('failure', $user_id); return is_payment_state_CIPF('failure', $user_id);
} }
function is_payment_nothing_CIPF($user_id = null) { function is_payment_nothing_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
return is_payment_state_CIPF('nothing', $user_id); return is_payment_state_CIPF('nothing', $user_id);
} }
/* /*
* setters * setters
*/ */
function set_payment_state_CIPF($type, $user_id = null) { function set_payment_state_CIPF($type, $user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_payment_state = PLGNTLS_class::ACF_CARD_PAYMENT_STATE; $acf_card_payment_state = Plgntls::ACF_CARD_PAYMENT_STATE;
set_acf_state_CIPF($acf_card_payment_state, $type, $user_id); set_acf_state_CIPF($acf_card_payment_state, $type, $user_id);
} }
function set_payment_started_CIPF($user_id = null) { function set_payment_started_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_payment_state_CIPF('started', $user_id); set_payment_state_CIPF('started', $user_id);
} }
function set_payment_success_CIPF($user_id = null) { function set_payment_success_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_payment_state_CIPF('success', $user_id); set_payment_state_CIPF('success', $user_id);
} }
function set_payment_failure_CIPF($user_id = null) { function set_payment_failure_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_payment_state_CIPF('failure', $user_id); set_payment_state_CIPF('failure', $user_id);
} }
function set_payment_nothing_CIPF($user_id = null) { function set_payment_nothing_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
set_payment_state_CIPF('nothing', $user_id); set_payment_state_CIPF('nothing', $user_id);
} }
@@ -333,8 +333,8 @@ function set_payment_nothing_CIPF($user_id = null) {
* *
*/ */
function set_card_number_CIPF($user_id = null) { function set_card_number_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_card_number = PLGNTLS_class::ACF_CARD_NUMBER; $acf_card_number = Plgntls::ACF_CARD_NUMBER;
if (is_null($user_id)) { if (is_null($user_id)) {
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@@ -355,8 +355,8 @@ function set_card_number_CIPF($user_id = null) {
* *
*/ */
function reset_acf_cgv_CIPF($user_id = null) { function reset_acf_cgv_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_cgv = PLGNTLS_class::ACF_PROF_CGV; $acf_cgv = Plgntls::ACF_PROF_CGV;
if (is_null($user_id)) { if (is_null($user_id)) {
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@@ -374,8 +374,8 @@ function reset_acf_cgv_CIPF($user_id = null) {
* *
*/ */
function is_transfert_success_CIPF($user_id = null) { function is_transfert_success_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_transfert_state = PLGNTLS_class::ACF_TRANSFERT_STATE; $acf_transfert_state = Plgntls::ACF_TRANSFERT_STATE;
if (is_null($user_id)) { if (is_null($user_id)) {
$user_id = get_current_user_id(); $user_id = get_current_user_id();
@@ -400,8 +400,8 @@ function is_transfert_success_CIPF($user_id = null) {
} }
} }
function reset_acf_transfert_CIPF($user_id = null) { function reset_acf_transfert_CIPF($user_id = null) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$acf_transfert_state = PLGNTLS_class::ACF_TRANSFERT_STATE; $acf_transfert_state = Plgntls::ACF_TRANSFERT_STATE;
if (is_null($user_id)) { if (is_null($user_id)) {
$user_id = get_current_user_id(); $user_id = get_current_user_id();

View File

@@ -18,7 +18,7 @@ if (!defined('ABSPATH')) {
* *
*/ */
function randomize_post_output_CIPF($query) { function randomize_post_output_CIPF($query) {
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$posts_per_page = $query->get('posts_per_page'); $posts_per_page = $query->get('posts_per_page');
if (is_null($posts_per_page)) { if (is_null($posts_per_page)) {
return; return;
@@ -26,7 +26,7 @@ function randomize_post_output_CIPF($query) {
if ($posts_per_page >= -1) { if ($posts_per_page >= -1) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
error_log("posts_per_page: " . json_encode($posts_per_page)); error_log("posts_per_page: " . json_encode($posts_per_page));
$query->set('orderby', 'rand'); $query->set('orderby', 'rand');

View File

@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) {
* *
*/ */
function redirect_home_CIPF(){ function redirect_home_CIPF(){
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers(); nocache_headers();
@@ -32,8 +32,8 @@ function redirect_home_CIPF(){
* *
*/ */
function redirect_command_CIPF(){ function redirect_command_CIPF(){
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$slug_command_card = PLGNTLS_class::SLUG_COMMAND_CARD; $slug_command_card = Plgntls::SLUG_COMMAND_CARD;
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers(); nocache_headers();
@@ -52,10 +52,10 @@ function redirect_command_CIPF(){
* *
*/ */
function redirection_profil_CIPF(){ function redirection_profil_CIPF(){
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
$role_prof = PLGNTLS_class::ROLE_PROF; $role_prof = Plgntls::ROLE_PROF;
$role_partner = PLGNTLS_class::ROLE_PARTNER; $role_partner = Plgntls::ROLE_PARTNER;
$slug_partner_create_page = PLGNTLS_class::SLUG_PARTNER_CREATE_PAGE; $slug_partner_create_page = Plgntls::SLUG_PARTNER_CREATE_PAGE;
$partner_page_creation = home_url($slug_partner_create_page); $partner_page_creation = home_url($slug_partner_create_page);
$current_user_id = get_current_user_id(); $current_user_id = get_current_user_id();
@@ -122,8 +122,8 @@ error_log("is prof");
* *
*/ */
function redirection_page_CIPF(){ function redirection_page_CIPF(){
PLGNTLS_class::debug_infos(2); Plgntls::debug_infos(2);
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION; $slug_page_redirection = Plgntls::SLUG_PAGE_REDIRECTION;
/* /*
@@ -139,7 +139,7 @@ function redirection_page_CIPF(){
if ($current_slug !== $slug_page_redirection) { if ($current_slug !== $slug_page_redirection) {
return; return;
} }
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
redirection_profil_CIPF(); redirection_profil_CIPF();
} }

View File

@@ -19,12 +19,12 @@ if (!defined('ABSPATH')) {
* *
*/ */
//function schedule_delete_orderid_CIPF($user_id, $order_id) { //function schedule_delete_orderid_CIPF($user_id, $order_id) {
// PLGNTLS_class::debug_infos(); // Plgntls::debug_infos();
// $delay = time() + MINUTE_IN_SECONDS; // $delay = time() + MINUTE_IN_SECONDS;
// wp_schedule_single_event($delay, 'orderid_deletion_event_CIPF', array($user_id, $order_id)); // wp_schedule_single_event($delay, 'orderid_deletion_event_CIPF', array($user_id, $order_id));
//} //}
//function delete_order_id_later_CIPF($user_id, $order_id) { //function delete_order_id_later_CIPF($user_id, $order_id) {
// PLGNTLS_class::debug_infos(); // Plgntls::debug_infos();
// delete_user_meta($user_id, 'cipf_order_id', $order_id); // delete_user_meta($user_id, 'cipf_order_id', $order_id);
//} //}
//add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 5, 2); //add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 5, 2);

View File

@@ -12,7 +12,7 @@ if (!defined('ABSPATH')) {
https://stackify.com/how-to-log-to-console-in-php/ https://stackify.com/how-to-log-to-console-in-php/
*/ */
function console_log(...$outputs) { function console_log(...$outputs) {
PLGNTLS_class::debug_infos(); Plgntls::debug_infos();
if (CIPF_CONSOLE_OFF) if (CIPF_CONSOLE_OFF)
return; return;
foreach($outputs as $output) foreach($outputs as $output)

View File

@@ -12,7 +12,7 @@ if (!defined('ABSPATH')) {
* include those two lines at the top of the main plugin file * include those two lines at the top of the main plugin file
* *
* include_once( plugin_dir_path(__FILE__) . '/php/utils/plugin_tools.php'); * include_once( plugin_dir_path(__FILE__) . '/php/utils/plugin_tools.php');
* PLGNTLS_class::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) ); * Plgntls::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) );
* *
* PLGNTLS means PLUGIN TOOLS * PLGNTLS means PLUGIN TOOLS
* *
@@ -22,11 +22,10 @@ if (!defined('ABSPATH')) {
* *
* ex: * ex:
* *
* $my_plugin_class = new PLGNTLS_class();
* $var_1 = 'value_1'; * $var_1 = 'value_1';
* $var_2 = 'value_2'; * $var_2 = 'value_2';
* $var_3 = 'value_3'; * $var_3 = 'value_3';
* return $my_plugin_class->add_to_front( * return Plgntls::add_to_front(
* array( // files added in order by types * array( // files added in order by types
* 'path/to/style1.css', // * 'path/to/style1.css', //
* 'path/to/script1.js', // * 'path/to/script1.js', //
@@ -54,7 +53,7 @@ if (!defined('ABSPATH')) {
* *
*/ */
class PLGNTLS_class { class Plgntls {
/* /*
* const declarations * const declarations
* *
@@ -284,26 +283,9 @@ vous allez être redirigés vers votre espace',
} }
public function add_to_front($srcs_arr = array(), $vars = array()) { public static function add_to_front($srcs_arr = array(), $vars = array()) {
/* $instance = new self();
* event if the function is called with no srcs return $instance->_add_to_front($srcs_arr, $vars);
* add fetch, because it can be used just for that
*/
$this->add_fetch($srcs_arr, $vars);
$this->add_default_css($srcs_arr, $vars);
$srcs = array();
foreach($srcs_arr as $src_key => $src_value) {
$init = $this->init_src($src_key, $src_value);
if ($init !== null)
$srcs[] = $init;
}
if (!is_null($srcs_arr))
$this->add_srcs_to_front($srcs);
if (!is_null($vars))
$this->add_vars_to_front($vars);
return $this->create_html($srcs, $vars);
} }
@@ -325,19 +307,40 @@ vous allez être redirigés vers votre espace',
private function _add_to_front($srcs_arr, $vars) {
/*
* event if the function is called with no srcs
* add fetch, because it can be used just for that
*/
$this->_add_fetch($srcs_arr, $vars);
$srcs = array();
foreach($srcs_arr as $src_key => $src_value) {
$init = $this->_init_src($src_key, $src_value);
if ($init !== null)
$srcs[] = $init;
}
if (!is_null($srcs_arr))
$this->_add_srcs_to_front($srcs);
if (!is_null($vars))
$this->_add_vars_to_front($vars);
return $this->_create_html($srcs, $vars);
}
/* /*
* for fetch, we add the file script that contains the fetch function * for fetch, we add the script that contains the fetch function
* it is an es6 module with the export keyword * it's an inline script, but is made globally available by adding it to window
* that way, it can also be used by modules scripts *
* to achieve that, we wouldn't need to include it here though
* but we need that the fetch function is also available for inline scripts
* so we could attach a copy of the script file without the export keyword
* but instead, inside the file, we add the fetch function to the global scope
*/ */
private function add_fetch(&$srcs_arr, &$vars) { private function _add_fetch(&$srcs_arr, &$vars) {
// add fetch script at beginning of scripts list // add fetch script at end of scripts list
array_unshift($srcs_arr, array(self::$_file_dir_path."/plgntls_fetch.js", 'type'=>'module')); // it will try to be added at the first script anyway,
// but for that, the scripts must be already enqueued,
// hence adding it at the end of the array
$srcs_arr[] = array('js'=>$this->_fetch_script());
// for the custom endpoints in rest api to work // for the custom endpoints in rest api to work
// they need to have a nonce named 'wp_rest' // they need to have a nonce named 'wp_rest'
// see : https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/ // see : https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/
@@ -346,11 +349,21 @@ vous allez être redirigés vers votre espace',
$vars = array_merge($vars, $fetch_nonce); $vars = array_merge($vars, $fetch_nonce);
$vars = array_merge($vars, $fetch_url); $vars = array_merge($vars, $fetch_url);
} }
private function _fetch_script() {
return "
if (typeof window !== 'undefined') {
window.PLGNTLS_fetch = function PLGNTLS_fetch(url, options = {}) {
url = PLGNTLS_data.fetch_url + url;
private function add_default_css(&$srcs_arr, &$vars) { options.headers = options.headers || {};
// add default css file at beginning of style list options.headers['X-WP-Nonce'] = PLGNTLS_data.fetch_nonce;
array_unshift($srcs_arr, self::$_file_dir_path."/plgntls_default.css");
return fetch(url, options);
} }
}
";
}
@@ -366,8 +379,8 @@ vous allez être redirigés vers votre espace',
* 2. list of variables to make available to this files * 2. list of variables to make available to this files
* - in the form of key => val * - in the form of key => val
* - recommanded to do it with compact() * - recommanded to do it with compact()
* ex: create_html( "file.html", compact("var1","var2",) ); * ex: _create_html( "file.html", compact("var1","var2",) );
* ex: create_html( array("file1.html", "file2.html"), array("var1"=>"value") ); * ex: _create_html( array("file1.html", "file2.html"), array("var1"=>"value") );
* @return a string of html code * @return a string of html code
* *
* using ob_start() and ob_get_clean() * using ob_start() and ob_get_clean()
@@ -376,7 +389,7 @@ vous allez être redirigés vers votre espace',
* *
* https://stackoverflow.com/a/4402045/9497573 * https://stackoverflow.com/a/4402045/9497573
*/ */
private function create_html($files = null, $vars = null) { private function _create_html($files = null, $vars = null) {
if (is_null($files)) if (is_null($files))
return null; return null;
$plgn_dir = $this->root_path(); $plgn_dir = $this->root_path();
@@ -405,7 +418,7 @@ vous allez être redirigés vers votre espace',
* this name is the filename + "_" + extension : * this name is the filename + "_" + extension :
* init.js -> init_js * init.js -> init_js
*/ */
private function add_vars_to_front($vars_arr) { private function _add_vars_to_front($vars_arr) {
if (is_null($this->_first_script)) if (is_null($this->_first_script))
return ; return ;
if (is_null($vars_arr)) if (is_null($vars_arr))
@@ -422,7 +435,7 @@ vous allez être redirigés vers votre espace',
wp_add_inline_script($handle, $front, 'before'); wp_add_inline_script($handle, $front, 'before');
} }
/** /*
* @param array : list of files : * @param array : list of files :
* - with their path from root of their type of file (ex: from js/ to .js files) * - with their path from root of their type of file (ex: from js/ to .js files)
* - and with their extension * - and with their extension
@@ -430,32 +443,32 @@ vous allez être redirigés vers votre espace',
* - to add ajax script and variables * - to add ajax script and variables
* - default to true * - default to true
*/ */
private function add_srcs_to_front($srcs_arr) { private function _add_srcs_to_front($srcs_arr) {
//wp_enqueue_script(<give_it_a_name>, /url/to/script, [depends on], version, defer? ); //wp_enqueue_script(<give_it_a_name>, /url/to/script, [depends on], version, defer? );
//wp_enqueue_style( <give_it_a_name>, /url/to/script, [depends on], version, media ); //wp_enqueue_style( <give_it_a_name>, /url/to/script, [depends on], version, media );
$previous_css_basename = ''; $previous_css_basename = '';
$previous_js_basename = ''; $previous_js_basename = '';
foreach ($srcs_arr as $src) { foreach ($srcs_arr as $src) {
if ($src->inline !== null) { if ($src->inline === "js") {
if ($src->inline === "js") $this->_add_inline_script($src);
$this->add_inline_script($src); }
else if ($src->inline === "css") else if ($src->inline === "css") {
$this->add_inline_style($src); $this->_add_inline_style($src);
} }
else if (in_array($src->ext, array("js", "url"))) { else if (in_array($src->ext, array("js", "url"))) {
$this->add_script($src, $previous_js_basename); $this->_add_script($src, $previous_js_basename);
$previous_js_basename = $src->handle; $previous_js_basename = $src->handle;
} }
else if ($src->ext === "css") { else if ($src->ext === "css") {
$this->add_style($src, $previous_css_basename); $this->_add_style($src, $previous_css_basename);
$previous_css_basename = $src->handle; $previous_css_basename = $src->handle;
} }
} }
// https://developer.wordpress.org/reference/hooks/wp_script_attributes/ // https://developer.wordpress.org/reference/hooks/wp_script_attributes/
// https://wordpress.stackexchange.com/questions/66843/attach-a-private-function-at-a-hook // https://wordpress.stackexchange.com/questions/66843/attach-a-private-function-at-a-hook
add_filter( 'wp_script_attributes', fn($attr)=>$this->add_attributes_to_script($attr), 10, 1 ); add_filter( 'wp_script_attributes', fn($attr)=>$this->_add_attributes_to_script($attr), 10, 1 );
/* /*
* uncomment to print all enqueued files, can be usefull * uncomment to print all enqueued files, can be usefull
@@ -469,42 +482,58 @@ vous allez être redirigés vers votre espace',
error_log(json_encode($wp_styles->queue)); error_log(json_encode($wp_styles->queue));
*/ */
} }
private function add_script($script, $previous_js_basename) { private function _add_script($script, $previous_js_basename) {
if (is_null($this->_first_script)) if (is_null($this->_first_script)) {
$this->_first_script = $script->handle; $this->_first_script = $script->handle;
$depends_on = $this->check_dependencies($script, $previous_js_basename); }
if ($depends_on !== null) $depends_on = $this->_check_dependencies($script, $previous_js_basename);
if ($depends_on !== null) {
wp_enqueue_script( $script->handle, $script->url, $depends_on, $script->version, true); wp_enqueue_script( $script->handle, $script->url, $depends_on, $script->version, true);
} }
private function add_style($style, $previous_css_basename) { }
if (is_null($this->_first_style)) private function _add_style($style, $previous_css_basename) {
if (is_null($this->_first_style)) {
$this->_first_style = $style->handle; $this->_first_style = $style->handle;
$depends_on = $this->check_dependencies($style, $previous_css_basename); }
if ($depends_on !== null) $depends_on = $this->_check_dependencies($style, $previous_css_basename);
if ($depends_on !== null) {
wp_enqueue_style( $style->handle, $style->url, $depends_on, $style->version, ''); wp_enqueue_style( $style->handle, $style->url, $depends_on, $style->version, '');
} }
private function add_inline_script($src) { }
$handle = $src->depends; private function _add_inline_script($src) {
if ($handle === null || empty($handle)) $handle = $this->_check_inline_handles($src);
$handle = $this->_first_script; if (!is_null($handle)) {
wp_add_inline_script($handle, $src->src, 'before'); wp_add_inline_script($handle, $src->src, 'before');
} }
private function add_inline_style($src) { else {
$handle = $src->depends; // in last ressort, only add the script inline, it's not ideal,
if ($handle === null || empty($handle)) // but the only situation where it should not work is if another script is loaded before
$handle = $this->_first_style; // and it should not be the case otherwise the handle would not have returned true
echo '<script>'.$src->src.'</script>';
}
}
private function _add_inline_style($src) {
$handle = $this->_check_inline_handles($src);
if (!is_null($handle)) {
wp_add_inline_style($handle, $src->src); wp_add_inline_style($handle, $src->src);
} }
else {
// in last ressort, cf script notes above
echo '<style>'.$src->src.'</style>';
}
}
private function _add_attributes_to_script($attr) {
private function add_attributes_to_script($attr) { if (empty($attr['id'])) {
if (empty($attr['id']))
return $attr; return $attr;
}
$handle = $attr['id']; $handle = $attr['id'];
if (isset($this->_scripts_attributes[$handle])) if (isset($this->_scripts_attributes[$handle])) {
$script = $this->_scripts_attributes[$handle]; $script = $this->_scripts_attributes[$handle];
else }
else {
return $attr; return $attr;
}
foreach($script as $key => $value){ foreach($script as $key => $value){
$attr[$key] = $value; $attr[$key] = $value;
@@ -514,33 +543,85 @@ vous allez être redirigés vers votre espace',
return $attr; return $attr;
} }
private function check_dependencies(&$src, $previous_basename) private function _check_dependencies(&$src, $previous_basename) {
{ if (in_array($src->ext, array("js", "url"))) {
if (in_array($src->ext, array("js", "url")))
{
global $wp_scripts; global $wp_scripts;
$already_enqueued = array_search($src->handle, $wp_scripts->queue); $already_enqueued = array_search($src->handle, $wp_scripts->queue);
if ($already_enqueued !== false) if ($already_enqueued !== false) {
return null; return null;
} }
else if ($src->ext === "css") }
{ else if ($src->ext === "css") {
global $wp_styles; global $wp_styles;
$already_enqueued = array_search($src->handle, $wp_styles->queue); $already_enqueued = array_search($src->handle, $wp_styles->queue);
if ($already_enqueued !== false) if ($already_enqueued !== false) {
return null; return null;
} }
}
$depends_on = array(); $depends_on = array();
if (isset($src->depends) && $src->depends !== '') if (isset($src->depends) && $src->depends !== '') {
$depends_on[] = $src->depends; $depends_on[] = $src->depends;
if (isset($previous_basename) && $previous_basename !== '') }
if (isset($previous_basename) && $previous_basename !== '') {
$depends_on[] = $previous_basename; $depends_on[] = $previous_basename;
}
return $depends_on; return $depends_on;
} }
/** private function _check_inline_handles(&$src) {
/*
* first, try to simply get the explicit dependency
*
*/
$handle = $src->depends;
if (!empty($handle) && !is_null($handle)) {
return $handle;
}
/*
* second, try to get the first enqueued src of this call to 'add_to_front()'
* and make it the dependency
*
*/
if ($src->inline === "js") {
$handle = $this->_first_script;
}
else if ($src->inline === "css") {
$handle = $this->_first_style;
}
if (!empty($handle) && !is_null($handle)) {
return $handle;
}
/*
* third, try to get the last enqueued src of the page
* https://www.php.net/manual/en/function.array-key-last.php
*
*/
if ($src->inline === "js") {
global $wp_scripts;
$array = $wp_scripts->queue;
}
else if ($src->inline === "css") {
global $wp_styles;
$array = $wp_styles->queue;
}
$last_key = array_key_last($array);
if (!is_null($last_key)) {
return $array[$last_key];
}
/*
* didn't find any handle to add the src to it
*
*/
return null;
}
/*
* @param string : name of the file, with its path from its extension directory * @param string : name of the file, with its path from its extension directory
* - from js/ root for .js files * - from js/ root for .js files
* - from css/ root for .css files * - from css/ root for .css files
@@ -560,7 +641,7 @@ vous allez être redirigés vers votre espace',
* 9. inline : array("js" => "name.js") -> js * 9. inline : array("js" => "name.js") -> js
* array("css" => "name.css") -> css * array("css" => "name.css") -> css
*/ */
private function init_src($key, $value) { private function _init_src($key, $value) {
if (empty($value)) if (empty($value))
return null; return null;
$src = (object)[ $src = (object)[

View File

@@ -1,4 +0,0 @@
/*
* this css file will be automatically added to front by PLGNTLS_class
* no need to write any style here, but you can if you want
*/

View File

@@ -1,22 +0,0 @@
/*
* this file is there for scripts that uses modules import
*
*/
export function PLGNTLS_fetch(url, options = {}) {
url = PLGNTLS_data.fetch_url + url;
options.headers = options.headers || {};
options.headers['X-WP-Nonce'] = PLGNTLS_data.fetch_nonce;
return fetch(url, options);
}
/*
* For non-module scripts, attach to the global scope
*
*/
if (typeof window !== 'undefined') {
window.PLGNTLS_fetch = PLGNTLS_fetch;
}

View File

@@ -1,10 +1,10 @@
<?php <?php
/* /*
Plugin Name: custer_plugin Plugin Name: hggg_custer
Plugin URI: Plugin URI:
Description: customize user : output infos on page, on email, and change current user id momentarly Description: customize user : output infos on page, on email, and change current user id momentarly
Author: hugogogo Author: hugogogo
Version: 0.1.8 Version: 0.2.0
Author URI: Author URI:
*/ */

View File

@@ -1,10 +1,10 @@
<?php <?php
/* /*
Plugin Name: fbpatch_plugin Plugin Name: hggg_fbpatch
Plugin URI: Plugin URI:
Description: some patchs for the form_builder plugin's bugs Description: some patchs for the form_builder plugin's bugs
Author: hugogogo Author: hugogogo
Version: 0.1.3.1 Version: 0.2.0
Author URI: Author URI:
*/ */

Submodule private updated: e14896ac9c...182b39ca01