- updated all occurences of Plgntls:: constantes for Cipf:: const
- update menu to use the new methods
This commit is contained in:
@@ -4,7 +4,7 @@ Plugin Name: hggg_cipf
|
||||
Plugin URI:
|
||||
Description:
|
||||
Author: hugogogo
|
||||
Version: 0.5.1
|
||||
Version: 0.5.2
|
||||
Author URI:
|
||||
*/
|
||||
|
||||
@@ -56,10 +56,132 @@ include_once(Plgntls::root_path() . 'php/scheduled_events.php');
|
||||
// admin
|
||||
include_once(Plgntls::root_path() . 'php/admin_hide_bar.php');
|
||||
include_once(Plgntls::root_path() . 'php/admin_user_profil.php');
|
||||
include_once(Plgntls::root_path() . 'php/admin_menu.php');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Cipf {
|
||||
/*
|
||||
* const declarations
|
||||
*
|
||||
*/
|
||||
// ACF
|
||||
const ACF_CARD_STATE = ['_name'=>'etat_carte', 'new'=>'Commande', 'renew'=>'Renouvellement']; // radio button
|
||||
const ACF_CARD_PAYMENT_METHOD = ['_name'=>'paiement', 'paypal'=>'Paypal', 'transfert'=>'Virement']; // radio button
|
||||
const ACF_CARD_PRICE_CHOICE = ['_name'=>'tarif', 'low'=>'10', 'high'=>'15']; // radio button
|
||||
const ACF_CARD_PRICE_DELIVERY = ['_name'=>'livraison', 'pdf'=>'0', 'post'=>'5']; // radio button
|
||||
const ACF_PROF_IS_ACTIV = ['_name'=>'compte-actif', 'activ'=>'Actif', 'inactiv'=>'Inactif']; // radio button
|
||||
const ACF_PROF_CGV = ['_name'=>'cgv', 'cgv'=>'cgv']; // checkbox
|
||||
const ACF_CARD_PRICE_TOTAL = ['_name'=>'somme_a_regler']; // number
|
||||
const ACF_CARD_NUMBER = ['_name'=>'numero_de_la_carte']; // number
|
||||
const ACF_CARD_EXPIRATION = ['_name'=>'fin_de_validite']; // date picker
|
||||
const ACF_CARD_PAYMENT_STATE = ['_name'=>'etat_paiement', 'started'=>'en_cours', 'success'=>'reussi', 'failure'=>'echec', 'nothing'=>'aucun']; // radio button
|
||||
const ACF_ACCOUNT_STATE = ['_name'=>'etat_compte', 'new'=>'nouveau prof', 'to_pay'=>'doit payer', 'valid'=>'carte valide', 'waiting_invalid'=>'en attente invalide', 'waiting_valid'=>'en attente valide', 'expired'=>'carte expiree'];
|
||||
const ACF_TRANSFERT_STATE = ['_name'=>'etat_virement', 'success'=>'virement validé'];
|
||||
const ACF_PAGE_STATE = ['_name'=>'etat_page_partenaire', 'publish'=>'Publiee', 'draft'=>'Brouillon'];
|
||||
|
||||
// META
|
||||
const META_PAYEMENT_STATUS = 'cipf_payement_status';
|
||||
const META_ORDER_ID = 'cipf_order_id';
|
||||
|
||||
// SLUG
|
||||
const SLUG_PROF_INACTIV = 'validation-en-cours';
|
||||
const SLUG_COMMAND_CARD = 'commande';
|
||||
const SLUG_PAGE_REDIRECTION = 'redirection_cipf';
|
||||
const SLUG_PAYPAL_PAGE = 'paiement';
|
||||
const SLUG_PAYPAL_REDIRECTION_SUCCESS = self::SLUG_PAGE_REDIRECTION;
|
||||
const SLUG_PAYPAL_REDIRECTION_FAILURE = self::SLUG_PAGE_REDIRECTION;
|
||||
const SLUG_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php
|
||||
const SLUG_PARTNER_REGISTRATION = 'compte-partenaire';
|
||||
const SLUG_PARTNER_CREATE_PAGE = 'ma-page-partenaire';
|
||||
|
||||
// URL
|
||||
const URL_BASE_REST_ROUTE = 'cipf_plugin/api/v1'; // for routes, in php/paypal/routes.php && php/admin_modif_prof.php
|
||||
|
||||
// QUERY
|
||||
const QUERY_TOGGLE_PARTNER_PAGE = 'toggle_partner_page_cipf';
|
||||
|
||||
// PAYPAL
|
||||
const PAYPAL_SBOX_API_BASE_URL = "https://api-m.sandbox.paypal.com";
|
||||
const PAYPAL_LIVE_API_BASE_URL = "https://api-m.paypal.com";
|
||||
const PAYPAL_HUGO_SBOX_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl";
|
||||
const PAYPAL_HUGO_SBOX_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-";
|
||||
const PAYPAL_HUGO_LIVE_CLIENT_ID = "Aedn5e8z__hPBvKirqw5bwlhI9ChG8_N6c1xbgybYyBr4B4oP8uVzmVdH1QVKdPQKf6bWg7orPV4PDrO";
|
||||
const PAYPAL_HUGO_LIVE_CLIENT_SECRET = "EGeGwfHGxHxsjnC-tH8W0IL4nN3_xlc3sXFRPCQOw5uUoWae3eOgghuDKMnZc5DVGTbP6yIjVJ1BaAra";
|
||||
const PAYPAL_DIEGO_SBOX_CLIENT_ID = "AegZZ6vDrTBzUNGf-UOVoUwh51YU4cvjGGPQkOQ7gM3H2xij9Pdkf751WO1ZvLoFjqbeNN-M5F6WqrdL";
|
||||
const PAYPAL_DIEGO_SBOX_CLIENT_SECRET = "ENH2n-trvWrs4B6IWdhl7NM_Wp-Rpyo5ONJJMjJFevGVJ2wtSdORPXFx-vPZ2RQGV0RUQzAp6qt4_qVn";
|
||||
const PAYPAL_DIEGO_LIVE_CLIENT_ID = "Abp6y2Outx8bMsEQRXBjH7qYK7-sTHmCMWlmJcw0Ctl5c9XpNsbGt5Vl1tD1ZmFhuBGGjT8ec3FKoLCo";
|
||||
const PAYPAL_DIEGO_LIVE_CLIENT_SECRET = "EFLFOATSMM1m9BZwfj209qAeYDrsH-ltcFnVBmyPAJM-KjQiMtUVDQNPeyikDO1Y41yMiKu_IoELp_vD";
|
||||
//const PAYPAL_CLIENT_ID = self::PAYPAL_HUGO_LIVE_CLIENT_ID;
|
||||
//const PAYPAL_CLIENT_SECRET = self::PAYPAL_HUGO_LIVE_CLIENT_SECRET;
|
||||
//const PAYPAL_API_BASE_URL = self::PAYPAL_HUGO_LIVE_API_BASE_URL;
|
||||
const PAYPAL_MESSAGE_SUCCESS = 'Paiement reussi, vous allez être redirigé-es vers votre espace';
|
||||
const PAYPAL_MESSAGE_FAILURE = 'Paiement raté, vous allez être redirigé-es vers votre espace';
|
||||
|
||||
// ROLES
|
||||
const ROLE_PROF = 'professeur__professeure';
|
||||
const ROLE_PARTNER = 'partenaire';
|
||||
const ROLE_FIPF = 'fipf';
|
||||
const ROLE_ADMIN = 'administrator';
|
||||
|
||||
// SHORTCODES
|
||||
|
||||
// OPTIONS
|
||||
const OPTION_PAYPAL = [
|
||||
'_name'=>'cipf_paypal_credentials',
|
||||
'_callback'=>'update_paypal_credentials_CIPF',
|
||||
'_default' => [
|
||||
'is_sandbox' =>true,
|
||||
'client_id' =>'AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl',
|
||||
'client_secret'=>'EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-',
|
||||
],
|
||||
];
|
||||
const OPTION_PAYMENT = [
|
||||
'_name'=>'cipf_payment_messages',
|
||||
'_callback'=>'update_payment_messages_option_CIPF',
|
||||
'_default'=>[
|
||||
'success'=>
|
||||
'Paiement réussi,
|
||||
vous allez être redirigés vers votre espace',
|
||||
'failure'=>
|
||||
'Paiement échoué,
|
||||
vous allez être redirigés vers votre espace',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
// ADMIN MENU
|
||||
const SLUG_TOOGLE_ADMIN_MENU = ['_name'=>'toogle_admin_menu_url_cipf', 'toggle'=>'toggle', 'show'=>'show', 'hide'=>'hide'];
|
||||
const TOGGLE_ADMIN_MENU = ['_name'=>'toggle_admin_menu_option_cipf', 'show'=>'show', 'hide'=>'hide'];
|
||||
const ADMIN_POST_PAYPAL = 'paypal_credentials_CIPF';
|
||||
const ADMIN_MENU_NONCE_PAYPAL = ['_name'=>'nonce_paypal_cipf', '_action'=>'action_admin_menu_paypal_cipf'];
|
||||
const ADMIN_POST_EMAIL_REGISTRATION = 'email_registration_message_CIPF';
|
||||
const ADMIN_MENU_NONCE_EMAIL_REGISTRATION = ['_name'=>'nonce_email_cipf', '_action'=>'action_admin_menu_email_registration_cipf'];
|
||||
const ADMIN_POST_PAYMENT_MESSAGES = 'payment_messages_CIPF';
|
||||
const ADMIN_MENU_NONCE_PAYMENT_MESSAGES = ['_name'=>'nonce_payment_cipf', '_action'=>'action_admin_menu_payment_messages_cipf'];
|
||||
|
||||
// FORMS
|
||||
const FORM_PROF_COMMANDE_ID = 'prof_commande';
|
||||
const FORM_PROF_TRANSFERT_ID = 'prof_valide_virement';
|
||||
|
||||
// OTHER
|
||||
const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible
|
||||
const CARD_VALIDITY_TIME = '1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days')
|
||||
const USER_INFO_DATE_FORMAT = 'd/m/Y'; // for user_infos.php (date format : https://www.php.net/manual/fr/datetime.format.php)
|
||||
const ADMIN_VALIDATE_PROF_FIELD = 'admin_activate_prof_cipf'; // for admin_modif_prof.php
|
||||
const INPUT_HIDDEN_ROLE = 'cipf_user_role';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -27,27 +27,24 @@
|
||||
|
||||
<!-- https://developer.wordpress.org/reference/hooks/admin_post_action/ -->
|
||||
<h1>paypal credentials</h1>
|
||||
<form method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
|
||||
<input type="hidden" name="action" value="<?php echo $admin_post_paypal; ?>">
|
||||
<?php wp_nonce_field($nonce_paypal['_action'], $nonce_paypal['_name']); ?>
|
||||
|
||||
<?php echo Plgntls::open_form_option($option_paypal_name); ?>
|
||||
<div class="define_paypal_credentials_cipf define_paypal_client_id_cipf vertical_wrapper">
|
||||
<label for="paypal_client_id_cipf">client id : </label>
|
||||
<input type="text" id="paypal_client_id_cipf" name="client_id" value="<?php echo $paypal_credentials['client_id']; ?>" />
|
||||
<input type="text" id="paypal_client_id_cipf" name="client_id" value="<?php echo $option_paypal['client_id']; ?>" />
|
||||
</div>
|
||||
|
||||
<div class="define_paypal_credentials_cipf define_paypal_secret_id_cipf vertical_wrapper">
|
||||
<label for="paypal_client_secret_cipf">client secret : </label>
|
||||
<input type="text" id="paypal_client_secret_cipf" name="client_secret" value="<?php echo $paypal_credentials['client_secret']; ?>" />
|
||||
<input type="text" id="paypal_client_secret_cipf" name="client_secret" value="<?php echo $option_paypal['client_secret']; ?>" />
|
||||
</div>
|
||||
|
||||
<div class="choose_sandbox_live_cipf choose_sandbox_cipf">
|
||||
<input type="radio" id="sandbox" name="sandbox_or_live" value="sandbox" <?php if ($paypal_credentials['is_sandbox'] === true) {echo 'checked';} ?> />
|
||||
<input type="radio" id="sandbox" name="sandbox_or_live" value="sandbox" <?php if ($option_paypal['is_sandbox'] === true) {echo 'checked';} ?> />
|
||||
<label for="sandbox">sandbox</label>
|
||||
</div>
|
||||
|
||||
<div class="choose_sandbox_live_cipf choose_live_cipf">
|
||||
<input type="radio" id="live" name="sandbox_or_live" value="live" <?php if ($paypal_credentials['is_sandbox'] === false) {echo 'checked';} ?> />
|
||||
<input type="radio" id="live" name="sandbox_or_live" value="live" <?php if ($option_paypal['is_sandbox'] === false) {echo 'checked';} ?> />
|
||||
<label for="live">live</label>
|
||||
</div>
|
||||
|
||||
@@ -59,18 +56,15 @@
|
||||
<!--
|
||||
-->
|
||||
<h1>messages apres paiement, avant redirection</h1>
|
||||
<form id="payments_messages_cipf" method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
|
||||
<input type="hidden" name="action" value="<?php echo $admin_post_payment_messages; ?>">
|
||||
<?php wp_nonce_field($nonce_payment_messages['_action'], $nonce_payment_messages['_name']); ?>
|
||||
|
||||
<?php echo Plgntls::open_form_option($option_payment_name); ?>
|
||||
<div class="define_payment_message_cipf vertical_wrapper">
|
||||
<label for="define_payment_message_success_cipf">paiement réussi : </label>
|
||||
<textarea id="define_payment_message_success_cipf" name="message_success"><?php echo $payment_messages['success']; ?></textarea>
|
||||
<textarea id="define_payment_message_success_cipf" name="message_success"><?php echo $option_payment['success']; ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="define_payment_message_cipf vertical_wrapper">
|
||||
<label for="define_payment_message_failure_cipf">paiement echec : </label>
|
||||
<textarea id="define_payment_message_failure_cipf" name="message_failure"><?php echo $payment_messages['failure']; ?></textarea>
|
||||
<textarea id="define_payment_message_failure_cipf" name="message_failure"><?php echo $option_payment['failure']; ?></textarea>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="send"/>
|
||||
|
||||
@@ -16,8 +16,8 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function hide_admin_bar_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
$role_admin = Plgntls::ROLE_ADMIN;
|
||||
$role_fipf = Plgntls::ROLE_FIPF;
|
||||
$role_admin = Cipf::ROLE_ADMIN;
|
||||
$role_fipf = Cipf::ROLE_FIPF;
|
||||
|
||||
|
||||
/*
|
||||
@@ -54,8 +54,8 @@ add_action('after_setup_theme', 'hide_admin_bar_CIPF');
|
||||
*/
|
||||
function restrict_admin_access_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
$role_admin = Plgntls::ROLE_ADMIN;
|
||||
$role_fipf = Plgntls::ROLE_FIPF;
|
||||
$role_admin = Cipf::ROLE_ADMIN;
|
||||
$role_fipf = Cipf::ROLE_FIPF;
|
||||
|
||||
/*
|
||||
* this concerns logged_in users, for admin page
|
||||
|
||||
155
plugins/cipf_plugin/php/admin_menu.php
Normal file
155
plugins/cipf_plugin/php/admin_menu.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* menu plugin
|
||||
*/
|
||||
function cipf_plugin_menu_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
Plgntls::add_menu('add_plugin_content_CIPF');
|
||||
}
|
||||
add_action('admin_menu', 'cipf_plugin_menu_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function add_plugin_content_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$option_paypal_object = Cipf::OPTION_PAYPAL;
|
||||
$option_payment_object = Cipf::OPTION_PAYMENT;
|
||||
|
||||
/*
|
||||
* options
|
||||
*
|
||||
*/
|
||||
$option_paypal_name = $option_paypal_object['_name'];
|
||||
$option_paypal = Plgntls::get_option_safe($option_paypal_object);
|
||||
$option_payment_name = $option_payment_object['_name'];
|
||||
$option_payment = Plgntls::get_option_safe($option_payment_object);
|
||||
|
||||
ob_start();
|
||||
include(Plgntls::root_path() . '/html/menu/cipf_menu.html');
|
||||
$html = ob_get_clean();
|
||||
echo $html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function update_payment_messages_option_CIPF($request, $option_name, $option_data, $option_default) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
/*
|
||||
* success
|
||||
* failure
|
||||
*
|
||||
*/
|
||||
$success = '';
|
||||
$failure = '';
|
||||
if (!isset($request['message_success'])) {
|
||||
return;
|
||||
}
|
||||
if (!isset($request['message_failure'])) {
|
||||
return;
|
||||
}
|
||||
$success = $request['message_success'];
|
||||
$failure = $request['message_failure'];
|
||||
|
||||
|
||||
/*
|
||||
* update the option with new values
|
||||
*
|
||||
set_payment_messages_option_CIPF($success, $failure);
|
||||
*/
|
||||
$data = array(
|
||||
'success' => $success,
|
||||
'failure' => $failure,
|
||||
);
|
||||
Plgntls::update_option_safe($option_name, $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function update_paypal_credentials_CIPF($request, $option_name, $option_data, $option_default) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
|
||||
/*
|
||||
* is sandbox or live ?
|
||||
*
|
||||
*/
|
||||
$is_sandbox = false;
|
||||
if (!isset($request['sandbox_or_live'])) {
|
||||
return;
|
||||
}
|
||||
if ($request['sandbox_or_live'] === 'sandbox') {
|
||||
$is_sandbox = true;
|
||||
}
|
||||
else if ($request['sandbox_or_live'] === 'live') {
|
||||
$is_sandbox = false;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* client id
|
||||
*
|
||||
*/
|
||||
$client_id = '';
|
||||
if (!isset($request['client_id'])) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$client_id = $request['client_id'];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* client secret
|
||||
*
|
||||
*/
|
||||
$client_secret = '';
|
||||
if (!isset($request['client_secret'])) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$client_secret = $request['client_secret'];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update the option with new credentials
|
||||
*
|
||||
set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret);
|
||||
*/
|
||||
$data = array(
|
||||
'is_sandbox' => $is_sandbox,
|
||||
'client_id' => $client_id,
|
||||
'client_secret' => $client_secret,
|
||||
);
|
||||
Plgntls::update_option_safe($option_name, $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* menu plugin
|
||||
*/
|
||||
function cipf_plugin_menu_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$menu_page_title = 'cipf';
|
||||
$menu_title = 'cipf';
|
||||
$menu_capability = 'manage_options';
|
||||
$menu_slug = 'cipf-plugin';
|
||||
$menu_callback = 'add_plugin_content_CIPF';
|
||||
toggle_menu_CIPF($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback);
|
||||
}
|
||||
add_action('admin_menu', 'cipf_plugin_menu_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
ajax
|
||||
- https://stackoverflow.com/questions/43557755/how-to-call-ajax-in-wordpress
|
||||
- in `add_action( 'wp_ajax_get_data', 'my_ajax_handler' );`
|
||||
the 'wp_ajax_get_data' is a hooks formated as 'wp_ajax_{$action}'
|
||||
the `$action` param is passed in the data object of the ajax call
|
||||
- to access the content of the data object properties of the ajax call :
|
||||
use $_POST['property_name']
|
||||
*/
|
||||
//function cipfcard_menu_fetch_handler() {
|
||||
// Plgntls::debug_infos();
|
||||
// return new WP_REST_Response('hello', 200);
|
||||
//}
|
||||
//function cipfcard_menu_endpoint() {
|
||||
// Plgntls::debug_infos();
|
||||
// register_rest_route('plgntls', '/get_data', array(
|
||||
// 'methods' => 'POST',
|
||||
// 'callback' => 'cipfcard_menu_fetch_handler',
|
||||
// ));
|
||||
//};
|
||||
//add_action('rest_api_init', 'cipfcard_menu_endpoint');
|
||||
|
||||
?>
|
||||
@@ -1,111 +0,0 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function toggle_menu_CIPF($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback) {
|
||||
Plgntls::debug_infos();
|
||||
$toggle_menu = Plgntls::TOGGLE_ADMIN_MENU;
|
||||
|
||||
if (false === get_option($toggle_menu['_name'])) {
|
||||
add_option($toggle_menu['_name'], $toggle_menu['hide'], '', 'no');
|
||||
}
|
||||
|
||||
$toggle = get_option($toggle_menu['_name']);
|
||||
|
||||
if ($toggle === $toggle_menu['hide']) {
|
||||
remove_menu_page($menu_slug);
|
||||
}
|
||||
else if ($toggle === $toggle_menu['show']) {
|
||||
add_menu_page($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* add link under the plugin in the plugins admin page
|
||||
*
|
||||
*/
|
||||
function add_link_to_custer_plugin_CIPF($links) {
|
||||
Plgntls::debug_infos();
|
||||
$slug_toggle = Plgntls::SLUG_TOOGLE_ADMIN_MENU;
|
||||
$toggle_menu = Plgntls::TOGGLE_ADMIN_MENU;
|
||||
|
||||
$toggle = get_option($toggle_menu['_name']);
|
||||
|
||||
if ($toggle === $toggle_menu['hide']) {
|
||||
$links[] = '<a href="/'.$slug_toggle['_name'].'?'.$slug_toggle['toggle'].'='.$slug_toggle['show'].'">show menu</a>';
|
||||
}
|
||||
else if ($toggle === $toggle_menu['show']) {
|
||||
$links[] = '<a href="/'.$slug_toggle['_name'].'?'.$slug_toggle['toggle'].'='.$slug_toggle['hide'].'">hide menu</a>';
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
add_filter('plugin_action_links_cipf_plugin/cipf_plugin.php', 'add_link_to_custer_plugin_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* handle the toggle menu when url is reached
|
||||
*
|
||||
*/
|
||||
function toggle_custer_plugin_menu_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_toggle = Plgntls::SLUG_TOOGLE_ADMIN_MENU;
|
||||
$toggle_menu = Plgntls::TOGGLE_ADMIN_MENU;
|
||||
|
||||
global $wp;
|
||||
$current_slug = $wp->request;
|
||||
if ($current_slug !== $slug_toggle['_name']) {
|
||||
return;
|
||||
}
|
||||
Plgntls::debug_infos();
|
||||
|
||||
$show = null;
|
||||
if (!isset($_GET)) {
|
||||
$show = null;
|
||||
}
|
||||
else if (empty($_GET)) {
|
||||
$show = null;
|
||||
}
|
||||
if (!isset($_GET[$slug_toggle['toggle']])) {
|
||||
$show = null;
|
||||
}
|
||||
else if ($_GET[$slug_toggle['toggle']] === $slug_toggle['show']) {
|
||||
$show = true;
|
||||
}
|
||||
else if ($_GET[$slug_toggle['toggle']] === $slug_toggle['hide']) {
|
||||
$show = false;
|
||||
}
|
||||
|
||||
if ($show === true) {
|
||||
update_option($toggle_menu['_name'], $toggle_menu['show']);
|
||||
}
|
||||
else if ($show === false) {
|
||||
update_option($toggle_menu['_name'], $toggle_menu['hide']);
|
||||
}
|
||||
|
||||
$plugins_menu_url = admin_url('plugins.php');
|
||||
wp_redirect($plugins_menu_url, 301);
|
||||
exit;
|
||||
}
|
||||
add_action('template_redirect', 'toggle_custer_plugin_menu_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,73 +0,0 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function add_plugin_content_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
/*
|
||||
* paypal
|
||||
*
|
||||
*/
|
||||
$admin_post_paypal = Plgntls::ADMIN_POST_PAYPAL;
|
||||
$nonce_paypal = Plgntls::ADMIN_MENU_NONCE_PAYPAL;
|
||||
$paypal_credentials = get_paypal_options_CIPF();
|
||||
|
||||
/*
|
||||
* payment messages
|
||||
*
|
||||
*/
|
||||
$admin_post_payment_messages = Plgntls::ADMIN_POST_PAYMENT_MESSAGES;
|
||||
$nonce_payment_messages = Plgntls::ADMIN_MENU_NONCE_PAYMENT_MESSAGES;
|
||||
$payment_messages = get_payment_messages_option_CIPF();
|
||||
|
||||
ob_start();
|
||||
include(Plgntls::root_path() . '/html/menu/cipf_menu.html');
|
||||
$html = ob_get_clean();
|
||||
echo $html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* this is used to redirect when handling the reception of post form
|
||||
*
|
||||
*/
|
||||
function redirect_menu_referer_CIPF($post) {
|
||||
Plgntls::debug_infos();
|
||||
if (!isset($post)) {
|
||||
wp_redirect(admin_url(), 301);
|
||||
exit;
|
||||
}
|
||||
if (is_null($post)) {
|
||||
wp_redirect(admin_url(), 301);
|
||||
exit;
|
||||
}
|
||||
if (empty($post)) {
|
||||
wp_redirect(admin_url(), 301);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($post['_wp_http_referer'])) {
|
||||
wp_redirect(admin_url(), 301);
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_redirect(home_url($post['_wp_http_referer']), 301);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,81 +0,0 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* use this hook 'admin_post_{$action}' to receive a form post
|
||||
* https://developer.wordpress.org/reference/hooks/admin_post_action/
|
||||
*
|
||||
* add the url to the action atrtibute of form, and the value of the action in an hidden input
|
||||
* <form method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
|
||||
* <input type="hidden" name="action" value="<?php echo $admin_post_patches; ?>">
|
||||
*
|
||||
*/
|
||||
function change_payment_messages_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$nonce_payment_messages = Plgntls::ADMIN_MENU_NONCE_PAYMENT_MESSAGES;
|
||||
|
||||
if (!isset($_POST[$nonce_payment_messages['_name']])) {
|
||||
redirect_menu_referer_CIPF($_POST);
|
||||
exit;
|
||||
}
|
||||
if (!wp_verify_nonce($_POST[$nonce_payment_messages['_name']], $nonce_payment_messages['_action'])) {
|
||||
redirect_menu_referer_CIPF($_POST);
|
||||
exit;
|
||||
}
|
||||
|
||||
// do actions here
|
||||
update_payment_messages_option_CIPF($_POST);
|
||||
|
||||
redirect_menu_referer_CIPF($_POST);
|
||||
}
|
||||
add_action('admin_post_'.Plgntls::ADMIN_POST_PAYMENT_MESSAGES, 'change_payment_messages_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function update_payment_messages_option_CIPF($post) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
error_log("post: " . json_encode($post));
|
||||
|
||||
/*
|
||||
* success
|
||||
* failure
|
||||
*
|
||||
*/
|
||||
$success = '';
|
||||
$failure = '';
|
||||
if (!isset($post['message_success'])) {
|
||||
return;
|
||||
}
|
||||
if (!isset($post['message_failure'])) {
|
||||
return;
|
||||
}
|
||||
$success = $post['message_success'];
|
||||
$failure = $post['message_failure'];
|
||||
|
||||
|
||||
/*
|
||||
* update the option with new values
|
||||
*
|
||||
*/
|
||||
set_payment_messages_option_CIPF($success, $failure);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,106 +0,0 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* use this hook 'admin_post_{$action}' to receive a form post
|
||||
* https://developer.wordpress.org/reference/hooks/admin_post_action/
|
||||
*
|
||||
* add the url to the action atrtibute of form, and the value of the action in an hidden input
|
||||
* <form method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
|
||||
* <input type="hidden" name="action" value="<?php echo $admin_post_patches; ?>">
|
||||
*
|
||||
*/
|
||||
function paypal_credentials_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$nonce_paypal = Plgntls::ADMIN_MENU_NONCE_PAYPAL;
|
||||
|
||||
if (!isset($_POST[$nonce_paypal['_name']])) {
|
||||
redirect_menu_referer_CIPF($_POST);
|
||||
exit;
|
||||
}
|
||||
if (!wp_verify_nonce($_POST[$nonce_paypal['_name']], $nonce_paypal['_action'])) {
|
||||
redirect_menu_referer_CIPF($_POST);
|
||||
exit;
|
||||
}
|
||||
|
||||
// do actions here
|
||||
update_paypal_credentials_CIPF($_POST);
|
||||
|
||||
redirect_menu_referer_CIPF($_POST);
|
||||
}
|
||||
add_action('admin_post_'.Plgntls::ADMIN_POST_PAYPAL, 'paypal_credentials_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function update_paypal_credentials_CIPF($post) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
|
||||
/*
|
||||
* is sandbox or live ?
|
||||
*
|
||||
*/
|
||||
$is_sandbox = false;
|
||||
if (!isset($post['sandbox_or_live'])) {
|
||||
return;
|
||||
}
|
||||
if ($post['sandbox_or_live'] === 'sandbox') {
|
||||
$is_sandbox = true;
|
||||
}
|
||||
else if ($post['sandbox_or_live'] === 'live') {
|
||||
$is_sandbox = false;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* client id
|
||||
*
|
||||
*/
|
||||
$client_id = '';
|
||||
if (!isset($post['client_id'])) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$client_id = $post['client_id'];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* client secret
|
||||
*
|
||||
*/
|
||||
$client_secret = '';
|
||||
if (!isset($post['client_secret'])) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$client_secret = $post['client_secret'];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update the option with new credentials
|
||||
*
|
||||
*/
|
||||
set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -18,7 +18,7 @@ function admin_user_profil_css_CIPF($user_id) {
|
||||
*/
|
||||
function admin_user_profil_css_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$role_fipf = Plgntls::ROLE_FIPF;
|
||||
$role_fipf = Cipf::ROLE_FIPF;
|
||||
|
||||
if (!current_user_can($role_fipf)) {
|
||||
return;
|
||||
|
||||
@@ -18,8 +18,8 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function partner_form_creation_page_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
$role_partner = Plgntls::ROLE_PARTNER;
|
||||
$slug_partner_create_page = Plgntls::SLUG_PARTNER_CREATE_PAGE;
|
||||
$role_partner = Cipf::ROLE_PARTNER;
|
||||
$slug_partner_create_page = Cipf::SLUG_PARTNER_CREATE_PAGE;
|
||||
|
||||
/*
|
||||
* only for the partner form creation page
|
||||
|
||||
@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function is_own_partner() {
|
||||
Plgntls::debug_infos(2);
|
||||
$role_partner = Plgntls::ROLE_PARTNER;
|
||||
$role_partner = Cipf::ROLE_PARTNER;
|
||||
|
||||
if (!is_single()) {
|
||||
return false;
|
||||
@@ -88,7 +88,7 @@ add_action('wp_enqueue_scripts', 'partner_page_scripts_CIPF', 11);
|
||||
*/
|
||||
function toggle_partner_page_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$toggle_partner_page = Plgntls::QUERY_TOGGLE_PARTNER_PAGE;
|
||||
$toggle_partner_page = Cipf::QUERY_TOGGLE_PARTNER_PAGE;
|
||||
|
||||
/*
|
||||
* check if :
|
||||
|
||||
@@ -19,9 +19,9 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function add_fields_register_CIPF($args) {
|
||||
Plgntls::debug_infos();
|
||||
$role_partner = Plgntls::ROLE_PARTNER;
|
||||
$slug_partner_registration = Plgntls::SLUG_PARTNER_REGISTRATION;
|
||||
$input_hidden_role = Plgntls::INPUT_HIDDEN_ROLE;
|
||||
$role_partner = Cipf::ROLE_PARTNER;
|
||||
$slug_partner_registration = Cipf::SLUG_PARTNER_REGISTRATION;
|
||||
$input_hidden_role = Cipf::INPUT_HIDDEN_ROLE;
|
||||
|
||||
/*
|
||||
* compare current slug to partner-register slug
|
||||
@@ -47,8 +47,8 @@ add_action('xoo_el_register_add_fields', 'add_fields_register_CIPF');
|
||||
*/
|
||||
function add_role_partners_CIPF($customer_data){
|
||||
Plgntls::debug_infos();
|
||||
$role_partner = Plgntls::ROLE_PARTNER;
|
||||
$input_hidden_role = Plgntls::INPUT_HIDDEN_ROLE;
|
||||
$role_partner = Cipf::ROLE_PARTNER;
|
||||
$input_hidden_role = Cipf::INPUT_HIDDEN_ROLE;
|
||||
|
||||
/*
|
||||
* check query of form submit
|
||||
|
||||
@@ -11,33 +11,39 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
function set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret) {
|
||||
Plgntls::debug_infos();
|
||||
$option_paypal = Plgntls::OPTION_PAYPAL;
|
||||
|
||||
$option_data = array();
|
||||
$option_data['is_sandbox'] = $is_sandbox;
|
||||
$option_data['client_id'] = $client_id;
|
||||
$option_data['client_secret'] = $client_secret;
|
||||
|
||||
update_option($option_paypal['_name'], serialize($option_data), '', 'no');
|
||||
}
|
||||
//function set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret) {
|
||||
// Plgntls::debug_infos();
|
||||
// $option_paypal = Cipf::OPTION_PAYPAL;
|
||||
//
|
||||
// $option_data = array();
|
||||
// $option_data['is_sandbox'] = $is_sandbox;
|
||||
// $option_data['client_id'] = $client_id;
|
||||
// $option_data['client_secret'] = $client_secret;
|
||||
//
|
||||
// update_option($option_paypal['_name'], serialize($option_data), '', 'no');
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//function get_paypal_options_CIPF() {
|
||||
// Plgntls::debug_infos();
|
||||
// $option_paypal = Cipf::OPTION_PAYPAL;
|
||||
//
|
||||
// $paypal_credentials_serialized = get_option($option_paypal['_name']);
|
||||
// if (false === $paypal_credentials_serialized) {
|
||||
// add_option($option_paypal['_name'], serialize($option_paypal['_default']), '', 'no');
|
||||
// $paypal_credentials_serialized = get_option($option_paypal['_name']);
|
||||
// }
|
||||
//
|
||||
// return unserialize($paypal_credentials_serialized);
|
||||
//}
|
||||
function get_paypal_options_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$option_paypal = Plgntls::OPTION_PAYPAL;
|
||||
|
||||
$paypal_credentials_serialized = get_option($option_paypal['_name']);
|
||||
if (false === $paypal_credentials_serialized) {
|
||||
add_option($option_paypal['_name'], serialize($option_paypal['_default']), '', 'no');
|
||||
$paypal_credentials_serialized = get_option($option_paypal['_name']);
|
||||
}
|
||||
|
||||
return unserialize($paypal_credentials_serialized);
|
||||
$option_paypal = Cipf::OPTION_PAYPAL;
|
||||
|
||||
return Plgntls::get_option_safe($option_paypal);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,10 +68,10 @@ function get_paypal_api_base_url_CIPF() {
|
||||
$paypal_base_url = '';
|
||||
$is_sandbox = $paypal_credentials['is_sandbox'];
|
||||
if ($is_sandbox) {
|
||||
$paypal_base_url = Plgntls::PAYPAL_SBOX_API_BASE_URL;
|
||||
$paypal_base_url = Cipf::PAYPAL_SBOX_API_BASE_URL;
|
||||
}
|
||||
else {
|
||||
$paypal_base_url = Plgntls::PAYPAL_LIVE_API_BASE_URL;
|
||||
$paypal_base_url = Cipf::PAYPAL_LIVE_API_BASE_URL;
|
||||
}
|
||||
return $paypal_base_url;
|
||||
}
|
||||
@@ -78,28 +84,34 @@ function get_paypal_api_base_url_CIPF() {
|
||||
*
|
||||
*/
|
||||
|
||||
function set_payment_messages_option_CIPF($success, $failure) {
|
||||
Plgntls::debug_infos();
|
||||
$option_payment = Plgntls::OPTION_PAYMENT;
|
||||
|
||||
$option_data = array();
|
||||
$option_data['success'] = $success;
|
||||
$option_data['failure'] = $failure;
|
||||
|
||||
update_option($option_payment['_name'], serialize($option_data), '', 'no');
|
||||
}
|
||||
//function set_payment_messages_option_CIPF($success, $failure) {
|
||||
// Plgntls::debug_infos();
|
||||
// $option_payment = Cipf::OPTION_PAYMENT;
|
||||
//
|
||||
// $option_data = array();
|
||||
// $option_data['success'] = $success;
|
||||
// $option_data['failure'] = $failure;
|
||||
//
|
||||
// update_option($option_payment['_name'], serialize($option_data), '', 'no');
|
||||
//}
|
||||
|
||||
//function get_payment_messages_option_CIPF() {
|
||||
// Plgntls::debug_infos();
|
||||
// $option_payment = Cipf::OPTION_PAYMENT;
|
||||
//
|
||||
// $payment_option_serialized = get_option($option_payment['_name']);
|
||||
// if (false === $payment_option_serialized) {
|
||||
// add_option($option_payment['_name'], serialize($option_payment['_default']), '', 'no');
|
||||
// $payment_option_serialized = get_option($option_payment['_name']);
|
||||
// }
|
||||
//
|
||||
// return unserialize($payment_option_serialized);
|
||||
//}
|
||||
function get_payment_messages_option_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$option_payment = Plgntls::OPTION_PAYMENT;
|
||||
$option_payment = Cipf::OPTION_PAYMENT;
|
||||
|
||||
$payment_option_serialized = get_option($option_payment['_name']);
|
||||
if (false === $payment_option_serialized) {
|
||||
add_option($option_payment['_name'], serialize($option_payment['_default']), '', 'no');
|
||||
$payment_option_serialized = get_option($option_payment['_name']);
|
||||
}
|
||||
|
||||
return unserialize($payment_option_serialized);
|
||||
return Plgntls::get_option_safe($option_payment);
|
||||
}
|
||||
|
||||
function get_payment_message_success_CIPF() {
|
||||
|
||||
@@ -18,7 +18,7 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function payment_page_checks_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
||||
$slug_paypal_page = Cipf::SLUG_PAYPAL_PAGE;
|
||||
|
||||
// check the slug
|
||||
if (!is_page($slug_paypal_page)) {
|
||||
@@ -43,8 +43,8 @@ add_action('wp', 'payment_page_checks_CIPF');
|
||||
*/
|
||||
function payment_page_redirects_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
||||
$role_prof = Plgntls::ROLE_PROF;
|
||||
$slug_paypal_page = Cipf::SLUG_PAYPAL_PAGE;
|
||||
$role_prof = Cipf::ROLE_PROF;
|
||||
|
||||
// don't redirect if it is the divi builder mode
|
||||
if (et_fb_is_enabled()) {
|
||||
@@ -78,7 +78,7 @@ add_action('template_redirect', 'payment_page_redirects_CIPF');
|
||||
*/
|
||||
function payment_page_scripts_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
||||
$slug_paypal_page = Cipf::SLUG_PAYPAL_PAGE;
|
||||
|
||||
// check the slug
|
||||
if (!is_page($slug_paypal_page)) {
|
||||
|
||||
@@ -92,7 +92,7 @@ function handle_orders_request_CIPF($request_data) {
|
||||
function create_order_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$paypal_api_base_url = get_paypal_api_base_url_CIPF();
|
||||
$acf_card_price_total = Plgntls::ACF_CARD_PRICE_TOTAL;
|
||||
$acf_card_price_total = Cipf::ACF_CARD_PRICE_TOTAL;
|
||||
|
||||
$access_token = generate_access_token_CIPF();
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ function routes_endpoints_CIPF() {
|
||||
if (is_admin()) {
|
||||
return;
|
||||
}
|
||||
$base_rest_route = Plgntls::URL_BASE_REST_ROUTE;
|
||||
$base_rest_route = Cipf::URL_BASE_REST_ROUTE;
|
||||
register_rest_route($base_rest_route, '/orders', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'handle_orders_request_CIPF',
|
||||
|
||||
@@ -17,8 +17,8 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function paypal_shortcode_content_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$slug_paypal_redirection_success = Plgntls::SLUG_PAYPAL_REDIRECTION_SUCCESS;
|
||||
$slug_paypal_redirection_failure = Plgntls::SLUG_PAYPAL_REDIRECTION_FAILURE;
|
||||
$slug_paypal_redirection_success = Cipf::SLUG_PAYPAL_REDIRECTION_SUCCESS;
|
||||
$slug_paypal_redirection_failure = Cipf::SLUG_PAYPAL_REDIRECTION_FAILURE;
|
||||
$paypal_client_id = get_paypal_client_id_CIPF();
|
||||
$paypal_message_success = get_payment_message_success_CIPF();
|
||||
$paypal_message_failure = get_payment_message_failure_CIPF();
|
||||
|
||||
@@ -36,8 +36,8 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function update_user_pre_order_CIPF($message) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_payment_status = Plgntls::ACF_CARD_PAYMENT_STATE;
|
||||
$meta_order_id = Plgntls::META_ORDER_ID;
|
||||
$acf_payment_status = Cipf::ACF_CARD_PAYMENT_STATE;
|
||||
$meta_order_id = Cipf::META_ORDER_ID;
|
||||
|
||||
$order_id = $message->id;
|
||||
$user_id = get_current_user_id();
|
||||
@@ -128,7 +128,7 @@ function update_user_post_capture_CIPF($message) {
|
||||
*/
|
||||
function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
||||
Plgntls::debug_infos();
|
||||
$meta_order_id = Plgntls::META_ORDER_ID;
|
||||
$meta_order_id = Cipf::META_ORDER_ID;
|
||||
|
||||
$acf_id = 'user_'.$user_id;
|
||||
|
||||
@@ -150,7 +150,7 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
||||
*/
|
||||
function success_payment_for_user_CIPF($user_id, $order_id) {
|
||||
Plgntls::debug_infos();
|
||||
$meta_order_id = Plgntls::META_ORDER_ID;
|
||||
$meta_order_id = Cipf::META_ORDER_ID;
|
||||
|
||||
$acf_id = 'user_'.$user_id;
|
||||
|
||||
@@ -186,8 +186,8 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
|
||||
*/
|
||||
function find_user_with_order_id_CIPF($current_user_id, $order_id) {
|
||||
Plgntls::debug_infos();
|
||||
$meta_order_id = Plgntls::META_ORDER_ID;
|
||||
$role_prof = Plgntls::ROLE_PROF;
|
||||
$meta_order_id = Cipf::META_ORDER_ID;
|
||||
$role_prof = Cipf::ROLE_PROF;
|
||||
|
||||
$user_metas = get_user_meta($current_user_id, $meta_order_id, false);
|
||||
if (in_array($order_id, $user_metas)) {
|
||||
|
||||
@@ -43,12 +43,12 @@ function get_acf_value_CIPF($acf_field, $acf_id) {
|
||||
*/
|
||||
function check_can_pay_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_payment_method = Plgntls::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_card_price_choice = Plgntls::ACF_CARD_PRICE_CHOICE;
|
||||
$acf_card_price_delivery = Plgntls::ACF_CARD_PRICE_DELIVERY;
|
||||
$acf_card_price_total = Plgntls::ACF_CARD_PRICE_TOTAL;
|
||||
$acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
|
||||
$card_renew_period = Plgntls::CARD_RENEW_PERIOD;
|
||||
$acf_card_payment_method = Cipf::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_card_price_choice = Cipf::ACF_CARD_PRICE_CHOICE;
|
||||
$acf_card_price_delivery = Cipf::ACF_CARD_PRICE_DELIVERY;
|
||||
$acf_card_price_total = Cipf::ACF_CARD_PRICE_TOTAL;
|
||||
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
|
||||
$card_renew_period = Cipf::CARD_RENEW_PERIOD;
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
@@ -18,7 +18,7 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function get_date_limit_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
|
||||
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
|
||||
|
||||
/*
|
||||
* define ids
|
||||
@@ -132,7 +132,7 @@ function is_card_date_expired_CIPF($user_id = null) {
|
||||
*/
|
||||
function card_date_exists_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
|
||||
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
|
||||
|
||||
/*
|
||||
* define ids
|
||||
@@ -169,8 +169,8 @@ function card_date_exists_CIPF($user_id = null) {
|
||||
*/
|
||||
function update_card_expiration_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
|
||||
$card_duration = Plgntls::CARD_VALIDITY_TIME;
|
||||
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
|
||||
$card_duration = Cipf::CARD_VALIDITY_TIME;
|
||||
|
||||
/*
|
||||
* define acf id and acf date format
|
||||
|
||||
@@ -17,8 +17,8 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function prof_after_form_commande_CIPF($form_id, $post_array, $form_type) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_account_state = Plgntls::ACF_ACCOUNT_STATE;
|
||||
$form_prof_commande_id = Plgntls::FORM_PROF_COMMANDE_ID;
|
||||
$acf_account_state = Cipf::ACF_ACCOUNT_STATE;
|
||||
$form_prof_commande_id = Cipf::FORM_PROF_COMMANDE_ID;
|
||||
|
||||
if ($form_prof_commande_id !== $form_id) {
|
||||
return;
|
||||
@@ -76,8 +76,8 @@ add_action('df_after_process', 'prof_after_form_commande_CIPF', 10, 3);
|
||||
*/
|
||||
function prof_form_restrictions_CIPF(){
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_command_card = Plgntls::SLUG_COMMAND_CARD;
|
||||
$role_prof = Plgntls::ROLE_PROF;
|
||||
$slug_command_card = Cipf::SLUG_COMMAND_CARD;
|
||||
$role_prof = Cipf::ROLE_PROF;
|
||||
|
||||
// don't redirect if it is the divi builder mode
|
||||
if (et_fb_is_enabled()) {
|
||||
@@ -109,7 +109,7 @@ add_action('template_redirect', 'prof_form_restrictions_CIPF');
|
||||
*/
|
||||
function renew_page_filter_message_CIPF(){
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_command_card = Plgntls::SLUG_COMMAND_CARD;
|
||||
$slug_command_card = Cipf::SLUG_COMMAND_CARD;
|
||||
|
||||
if (!is_page($slug_command_card))
|
||||
return;
|
||||
|
||||
@@ -17,8 +17,8 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function prof_after_form_transfert_validation_CIPF($form_id, $post_array, $form_type) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_account_state = Plgntls::ACF_ACCOUNT_STATE;
|
||||
$form_prof_transfert_id = Plgntls::FORM_PROF_TRANSFERT_ID;
|
||||
$acf_account_state = Cipf::ACF_ACCOUNT_STATE;
|
||||
$form_prof_transfert_id = Cipf::FORM_PROF_TRANSFERT_ID;
|
||||
|
||||
if ($form_prof_transfert_id !== $form_id) {
|
||||
return;
|
||||
@@ -57,8 +57,6 @@ function prof_profil_check_CIPF() {
|
||||
*/
|
||||
handle_transfert_validation_CIPF($author_id);
|
||||
handle_card_expire_CIPF($author_id);
|
||||
|
||||
schedule_test_CIPF();
|
||||
}
|
||||
add_action('wp', 'prof_profil_check_CIPF', 11);
|
||||
|
||||
@@ -71,9 +69,9 @@ add_action('wp', 'prof_profil_check_CIPF', 11);
|
||||
*/
|
||||
function prof_profil_redirects_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
$role_fipf = Plgntls::ROLE_FIPF;
|
||||
$role_admin = Plgntls::ROLE_ADMIN;
|
||||
$role_partner = Plgntls::ROLE_PARTNER;
|
||||
$role_fipf = Cipf::ROLE_FIPF;
|
||||
$role_admin = Cipf::ROLE_ADMIN;
|
||||
$role_partner = Cipf::ROLE_PARTNER;
|
||||
|
||||
// is an author page
|
||||
if (!is_author())
|
||||
|
||||
@@ -33,7 +33,7 @@ function redirect_home_CIPF(){
|
||||
*/
|
||||
function redirect_command_CIPF(){
|
||||
Plgntls::debug_infos();
|
||||
$slug_command_card = Plgntls::SLUG_COMMAND_CARD;
|
||||
$slug_command_card = Cipf::SLUG_COMMAND_CARD;
|
||||
|
||||
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
|
||||
nocache_headers();
|
||||
@@ -53,9 +53,9 @@ function redirect_command_CIPF(){
|
||||
*/
|
||||
function redirection_profil_CIPF(){
|
||||
Plgntls::debug_infos();
|
||||
$role_prof = Plgntls::ROLE_PROF;
|
||||
$role_partner = Plgntls::ROLE_PARTNER;
|
||||
$slug_partner_create_page = Plgntls::SLUG_PARTNER_CREATE_PAGE;
|
||||
$role_prof = Cipf::ROLE_PROF;
|
||||
$role_partner = Cipf::ROLE_PARTNER;
|
||||
$slug_partner_create_page = Cipf::SLUG_PARTNER_CREATE_PAGE;
|
||||
|
||||
$partner_page_creation = home_url($slug_partner_create_page);
|
||||
$current_user_id = get_current_user_id();
|
||||
@@ -122,7 +122,7 @@ function redirection_profil_CIPF(){
|
||||
*/
|
||||
function redirection_page_CIPF(){
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_page_redirection = Plgntls::SLUG_PAGE_REDIRECTION;
|
||||
$slug_page_redirection = Cipf::SLUG_PAGE_REDIRECTION;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -131,7 +131,7 @@ function set_acf_state_CIPF($acf_field, $state_name, $acf_id) {
|
||||
*/
|
||||
function is_account_state_CIPF($state_name, $user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_account_state = Plgntls::ACF_ACCOUNT_STATE;
|
||||
$acf_account_state = Cipf::ACF_ACCOUNT_STATE;
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
@@ -178,7 +178,7 @@ function is_account_waiting_transfert_CIPF($user_id = null) {
|
||||
*/
|
||||
function set_account_state_CIPF($state_name, $user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_account_state = Plgntls::ACF_ACCOUNT_STATE;
|
||||
$acf_account_state = Cipf::ACF_ACCOUNT_STATE;
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
@@ -223,7 +223,7 @@ function set_account_expired_CIPF($user_id = null) {
|
||||
*/
|
||||
function is_card_state_CIPF($state, $user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_state = Plgntls::ACF_CARD_STATE;
|
||||
$acf_card_state = Cipf::ACF_CARD_STATE;
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
@@ -243,7 +243,7 @@ function is_card_renew_CIPF($user_id = null) {
|
||||
*/
|
||||
function set_card_state_CIPF($state, $user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_state = Plgntls::ACF_CARD_STATE;
|
||||
$acf_card_state = Cipf::ACF_CARD_STATE;
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
@@ -272,7 +272,7 @@ function set_card_renew_CIPF($user_id = null) {
|
||||
*/
|
||||
function is_page_state_CIPF($state, $post_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_page_state = Plgntls::ACF_PAGE_STATE;
|
||||
$acf_page_state = Cipf::ACF_PAGE_STATE;
|
||||
if (is_null($post_id)) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
@@ -292,7 +292,7 @@ function is_page_draft_CIPF($post_id = null) {
|
||||
*/
|
||||
function set_page_state_CIPF($state, $post_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_page_state = Plgntls::ACF_PAGE_STATE;
|
||||
$acf_page_state = Cipf::ACF_PAGE_STATE;
|
||||
if (is_null($post_id)) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
@@ -321,7 +321,7 @@ function set_page_draft_CIPF($post_id = null) {
|
||||
*/
|
||||
function is_card_method_CIPF($state, $user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_payment_method = Plgntls::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_card_payment_method = Cipf::ACF_CARD_PAYMENT_METHOD;
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
@@ -354,7 +354,7 @@ function is_payment_method_transfert_CIPF($user_id = null) {
|
||||
*/
|
||||
function is_payment_state_CIPF($type, $user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_payment_state = Plgntls::ACF_CARD_PAYMENT_STATE;
|
||||
$acf_card_payment_state = Cipf::ACF_CARD_PAYMENT_STATE;
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
@@ -382,7 +382,7 @@ function is_payment_nothing_CIPF($user_id = null) {
|
||||
*/
|
||||
function set_payment_state_CIPF($type, $user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_payment_state = Plgntls::ACF_CARD_PAYMENT_STATE;
|
||||
$acf_card_payment_state = Cipf::ACF_CARD_PAYMENT_STATE;
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
@@ -416,7 +416,7 @@ function set_payment_nothing_CIPF($user_id = null) {
|
||||
*/
|
||||
function set_card_number_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_number = Plgntls::ACF_CARD_NUMBER;
|
||||
$acf_card_number = Cipf::ACF_CARD_NUMBER;
|
||||
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
@@ -438,7 +438,7 @@ function set_card_number_CIPF($user_id = null) {
|
||||
*/
|
||||
function reset_acf_cgv_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_cgv = Plgntls::ACF_PROF_CGV;
|
||||
$acf_cgv = Cipf::ACF_PROF_CGV;
|
||||
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
@@ -457,7 +457,7 @@ function reset_acf_cgv_CIPF($user_id = null) {
|
||||
*/
|
||||
function is_transfert_success_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_transfert_state = Plgntls::ACF_TRANSFERT_STATE;
|
||||
$acf_transfert_state = Cipf::ACF_TRANSFERT_STATE;
|
||||
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
@@ -483,7 +483,7 @@ function is_transfert_success_CIPF($user_id = null) {
|
||||
}
|
||||
function reset_acf_transfert_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_transfert_state = Plgntls::ACF_TRANSFERT_STATE;
|
||||
$acf_transfert_state = Cipf::ACF_TRANSFERT_STATE;
|
||||
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
Reference in New Issue
Block a user