294 lines
14 KiB
PHP
294 lines
14 KiB
PHP
<?php
|
|
/*
|
|
Plugin Name: hggg_cipf
|
|
Plugin URI:
|
|
Description:
|
|
Author: hugogogo
|
|
Version: 0.5.2
|
|
Author URI:
|
|
*/
|
|
|
|
/*
|
|
* it means someone outside wp is accessing the file, in this case kill it.
|
|
*/
|
|
if (!defined('ABSPATH')) {
|
|
die('You can not access this file!');
|
|
}
|
|
|
|
|
|
|
|
include_once( plugin_dir_path(__FILE__) . '/plgntls_class.php');
|
|
|
|
|
|
|
|
/*
|
|
* general inclusions
|
|
// utils :
|
|
*/
|
|
include_once(Plgntls::root_path() . 'php/utils/globals.php');
|
|
include_once(Plgntls::root_path() . 'php/utils/console_log.php');
|
|
|
|
// paypal
|
|
include_once(Plgntls::root_path() . 'php/paypal/paypal.php');
|
|
// profs
|
|
include_once(Plgntls::root_path() . 'php/profs_profil.php');
|
|
include_once(Plgntls::root_path() . 'php/profs_form_commande.php');
|
|
include_once(Plgntls::root_path() . 'php/profs_dates.php');
|
|
include_once(Plgntls::root_path() . 'php/profs_handle_states.php');
|
|
// partners
|
|
include_once(Plgntls::root_path() . 'php/partners_register.php');
|
|
include_once(Plgntls::root_path() . 'php/partners_page.php');
|
|
include_once(Plgntls::root_path() . 'php/partners_form.php');
|
|
// utils
|
|
//include_once(Plgntls::root_path() . '/php/menus.php');
|
|
include_once(Plgntls::root_path() . 'php/states.php');
|
|
include_once(Plgntls::root_path() . 'php/redirections.php');
|
|
include_once(Plgntls::root_path() . 'php/display_css.php');
|
|
include_once(Plgntls::root_path() . 'php/payments.php');
|
|
include_once(Plgntls::root_path() . 'php/random_posts.php');
|
|
include_once(Plgntls::root_path() . 'php/scheduled_events.php');
|
|
include_once(Plgntls::root_path() . 'php/emails.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 réussi, vous allez être redirigé-es vers votre espace';
|
|
const PAYPAL_MESSAGE_PROBLEM = "Paiement réussi, mais une erreure est survenue dans le traitement de la commande, si vous voyez que votre compte n'est pas mis à jour correctement, contactez la fipf directement";
|
|
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',
|
|
'problem'=>
|
|
"Paiement réussi,
|
|
mais une erreur est survenue dans le traitement de la commande,
|
|
si vous voyez que votre compte n'est pas mis à jour correctement,
|
|
contactez la fipf directement",
|
|
],
|
|
];
|
|
const OPTION_EMAILS = [
|
|
'_name'=>'cipf_emails_option',
|
|
'_callback'=>'update_emails_settings_option_CIPF',
|
|
'_default'=>[
|
|
// 1. profs : email : payment_success : validation payment prof reussi, send email
|
|
'payment_success'=>[
|
|
'name'=>'prof - le paiement a réussi',
|
|
'notification_send'=>true,
|
|
'notification_to'=>'$$__admin_email__$$',
|
|
'notification_subject'=>"[CIPF /prof - paiement réussi]",
|
|
'notification_message'=>'paiement réussi de la part de $$user_login$$ : $$__author_page_url__$$',
|
|
'confirmation_send'=>true,
|
|
'confirmation_subject'=>"[CIPF - paiement réussi]",
|
|
'confirmation_message'=>"paiement réussi",
|
|
],
|
|
// 2. profs : email : payment_failure : validation payment prof echec, send email
|
|
'payment_echec'=>[
|
|
'name'=>'prof - le paiement a echoué',
|
|
'notification_send'=>true,
|
|
'notification_to'=>'$$__admin_email__$$',
|
|
'notification_subject'=>"[CIPF /prof - paiement echoué]",
|
|
'notification_message'=>'paiement echoué pour $$user_login$$ : $$__author_page_url__$$',
|
|
'confirmation_send'=>true,
|
|
'confirmation_subject'=>"[CIPF - paiement echoué]",
|
|
'confirmation_message'=>"votre paiement a echoué",
|
|
],
|
|
// 3. profs : email : transfert_success : validation transfert prof reussi, send email
|
|
'transfert_success'=>[
|
|
'name'=>'prof - le virement a été validé',
|
|
'notification_send'=>true,
|
|
'notification_to'=>'$$__admin_email__$$',
|
|
'notification_subject'=>"[CIPF /prof - virement validé]",
|
|
'notification_message'=>'virement validé pour $$user_login$$ : $$__author_page_url__$$',
|
|
'confirmation_send'=>true,
|
|
'confirmation_subject'=>"[CIPF - virement validé]",
|
|
'confirmation_message'=>"votre virement a été validé",
|
|
],
|
|
// 4. profs : email : transfert_failures : validation transfert prof echec, send email
|
|
// 'transfert_echec'=>[
|
|
// 'name'=>'prof - le virement a échoué',
|
|
// 'notification_send'=>true,
|
|
// 'notification_to'=>'$$__admin_email__$$',
|
|
// 'notification_subject'=>"[CIPF /prof - virement echoué]",
|
|
// 'notification_message'=>'virement echoué pour $$user_login$$ : $$__author_page_url__$$',
|
|
// 'confirmation_send'=>true,
|
|
// 'confirmation_subject'=>"[CIPF - virement echoué]",
|
|
// 'confirmation_message'=>"votre virement a echoué",
|
|
// ],
|
|
// 5. partners : email : offer_expired : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
|
|
'offer_expired'=>[
|
|
'name'=>"partenaire - l'offre partenaire a expirée",
|
|
'notification_send'=>true,
|
|
'notification_to'=>'$$__admin_email__$$',
|
|
'notification_subject'=>"[CIPF /partenaire - offre expirée]",
|
|
'notification_message'=>'offre expirée pour $$user_login$$ : $$__user_post_url__$$',
|
|
'confirmation_send'=>true,
|
|
'confirmation_subject'=>"[CIPF - offre expirée]",
|
|
'confirmation_message'=>'votre offre a expiré, pour la renouveler rendez-vous sur $$__base_url__$$',
|
|
],
|
|
// 6. partners : email : offer_will_expire : la gestion des offres à échéance
|
|
'offer_will_expire'=>[
|
|
'name'=>"partenaire - l'offre arrive bientot a expiration",
|
|
'notification_send'=>true,
|
|
'notification_to'=>'$$__admin_email__$$',
|
|
'notification_subject'=>"[CIPF /partenaire - offre va expirer]",
|
|
'notification_message'=>'offre va expirer pour $$user_login$$ : $$__user_post_url__$$',
|
|
'confirmation_send'=>true,
|
|
'confirmation_subject'=>"[CIPF - offre va expirer]",
|
|
'confirmation_message'=>'une de vos offre va expirer, rendez-vous sur $$__base_url__$$',
|
|
],
|
|
// 7. payments : email : account_deleted : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
|
|
'account_deleted'=>[
|
|
'name'=>'prof - le compte a été supprimé',
|
|
'notification_send'=>true,
|
|
'notification_to'=>'$$__admin_email__$$',
|
|
'notification_subject'=>"[CIPF /prof - compte supprimé]",
|
|
'notification_message'=>'compte supprimé pour $$user_login$$ : $$__author_page_url__$$',
|
|
'confirmation_send'=>true,
|
|
'confirmation_subject'=>"[CIPF - compte supprimé]",
|
|
'confirmation_message'=>'votre compte a été supprimé sur $$__base_url__$$',
|
|
],
|
|
// 8. payments : email : account_will_expire : faire rappels emails avant expiration
|
|
'account_will_expire'=>[
|
|
'name'=>'prof - le compte va bientot expirer',
|
|
'notification_send'=>true,
|
|
'notification_to'=>'$$__admin_email__$$',
|
|
'notification_subject'=>"[CIPF /prof - compte va expirer]",
|
|
'notification_message'=>'le compte va expirer pour $$user_login$$ : $$__author_page_url__$$',
|
|
'confirmation_send'=>true,
|
|
'confirmation_subject'=>"[CIPF - compte va expirer]",
|
|
'confirmation_message'=>'votre compte va expirer bientot, renouvellez-le sur $$__base_url__$$',
|
|
],
|
|
// 9. payments : email : account_expired : desactiver carte expiree
|
|
'account_expired'=>[
|
|
'name'=>'prof - le compte a expiré',
|
|
'notification_send'=>true,
|
|
'notification_to'=>'$$__admin_email__$$',
|
|
'notification_subject'=>"[CIPF /prof - compte expiré]",
|
|
'notification_message'=>'compte expiré pour $$user_login$$ : $$__author_page_url__$$',
|
|
'confirmation_send'=>true,
|
|
'confirmation_subject'=>"[CIPF - compte expiré]",
|
|
'confirmation_message'=>'votre compte a expiré, renouvelez-le sur $$__base_url__$$',
|
|
],
|
|
],
|
|
];
|
|
|
|
|
|
// 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';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|