diff --git a/plugins/cipf_plugin/cipf_plugin.php b/plugins/cipf_plugin/cipf_plugin.php index bbc7f45..2b48db8 100644 --- a/plugins/cipf_plugin/cipf_plugin.php +++ b/plugins/cipf_plugin/cipf_plugin.php @@ -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'; + + +} + + + + ?> diff --git a/plugins/cipf_plugin/html/menu/cipf_menu.html b/plugins/cipf_plugin/html/menu/cipf_menu.html index 982570d..6ee99bf 100644 --- a/plugins/cipf_plugin/html/menu/cipf_menu.html +++ b/plugins/cipf_plugin/html/menu/cipf_menu.html @@ -27,27 +27,24 @@

paypal credentials

-
- - - +
- +
- +
- /> + />
- /> + />
@@ -59,18 +56,15 @@

messages apres paiement, avant redirection

- - - - +
- +
- +
diff --git a/plugins/cipf_plugin/php/admin_hide_bar.php b/plugins/cipf_plugin/php/admin_hide_bar.php index 4447b10..8ec846f 100644 --- a/plugins/cipf_plugin/php/admin_hide_bar.php +++ b/plugins/cipf_plugin/php/admin_hide_bar.php @@ -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 diff --git a/plugins/cipf_plugin/php/admin_menu.php b/plugins/cipf_plugin/php/admin_menu.php new file mode 100644 index 0000000..8f53350 --- /dev/null +++ b/plugins/cipf_plugin/php/admin_menu.php @@ -0,0 +1,155 @@ + $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); +} + + + + + +?> diff --git a/plugins/cipf_plugin/php/admin_menu/admin_menu.php b/plugins/cipf_plugin/php/admin_menu/admin_menu.php deleted file mode 100644 index 9a24e5d..0000000 --- a/plugins/cipf_plugin/php/admin_menu/admin_menu.php +++ /dev/null @@ -1,55 +0,0 @@ - 'POST', -// 'callback' => 'cipfcard_menu_fetch_handler', -// )); -//}; -//add_action('rest_api_init', 'cipfcard_menu_endpoint'); - -?> diff --git a/plugins/cipf_plugin/php/admin_menu/admin_menu_toggle.php b/plugins/cipf_plugin/php/admin_menu/admin_menu_toggle.php deleted file mode 100644 index 6428f9c..0000000 --- a/plugins/cipf_plugin/php/admin_menu/admin_menu_toggle.php +++ /dev/null @@ -1,111 +0,0 @@ -show menu'; - } - else if ($toggle === $toggle_menu['show']) { - $links[] = 'hide menu'; - } - 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'); - - - - - -?> diff --git a/plugins/cipf_plugin/php/admin_menu/menu_content.php b/plugins/cipf_plugin/php/admin_menu/menu_content.php deleted file mode 100644 index 815b0eb..0000000 --- a/plugins/cipf_plugin/php/admin_menu/menu_content.php +++ /dev/null @@ -1,73 +0,0 @@ - diff --git a/plugins/cipf_plugin/php/admin_menu/post_payment_messages.php b/plugins/cipf_plugin/php/admin_menu/post_payment_messages.php deleted file mode 100644 index 52e1ed2..0000000 --- a/plugins/cipf_plugin/php/admin_menu/post_payment_messages.php +++ /dev/null @@ -1,81 +0,0 @@ -"> -* -* -*/ -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); -} - - - - - -?> diff --git a/plugins/cipf_plugin/php/admin_menu/post_paypal.php b/plugins/cipf_plugin/php/admin_menu/post_paypal.php deleted file mode 100644 index 294236f..0000000 --- a/plugins/cipf_plugin/php/admin_menu/post_paypal.php +++ /dev/null @@ -1,106 +0,0 @@ -"> -* -* -*/ -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); -} - - - - -?> diff --git a/plugins/cipf_plugin/php/admin_user_profil.php b/plugins/cipf_plugin/php/admin_user_profil.php index 17d4f15..1cd7172 100644 --- a/plugins/cipf_plugin/php/admin_user_profil.php +++ b/plugins/cipf_plugin/php/admin_user_profil.php @@ -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; diff --git a/plugins/cipf_plugin/php/partners_form.php b/plugins/cipf_plugin/php/partners_form.php index 9ace344..9fb0b8a 100644 --- a/plugins/cipf_plugin/php/partners_form.php +++ b/plugins/cipf_plugin/php/partners_form.php @@ -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 diff --git a/plugins/cipf_plugin/php/partners_page.php b/plugins/cipf_plugin/php/partners_page.php index 0605608..2489d31 100644 --- a/plugins/cipf_plugin/php/partners_page.php +++ b/plugins/cipf_plugin/php/partners_page.php @@ -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 : diff --git a/plugins/cipf_plugin/php/partners_register.php b/plugins/cipf_plugin/php/partners_register.php index b3ddd9f..727d853 100644 --- a/plugins/cipf_plugin/php/partners_register.php +++ b/plugins/cipf_plugin/php/partners_register.php @@ -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 diff --git a/plugins/cipf_plugin/php/payments.php b/plugins/cipf_plugin/php/payments.php index 3549009..6892abe 100644 --- a/plugins/cipf_plugin/php/payments.php +++ b/plugins/cipf_plugin/php/payments.php @@ -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() { diff --git a/plugins/cipf_plugin/php/paypal/payment_page.php b/plugins/cipf_plugin/php/paypal/payment_page.php index 69076a9..c3e7157 100644 --- a/plugins/cipf_plugin/php/paypal/payment_page.php +++ b/plugins/cipf_plugin/php/paypal/payment_page.php @@ -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)) { diff --git a/plugins/cipf_plugin/php/paypal/route_api_orders.php b/plugins/cipf_plugin/php/paypal/route_api_orders.php index ab10bba..a41740b 100644 --- a/plugins/cipf_plugin/php/paypal/route_api_orders.php +++ b/plugins/cipf_plugin/php/paypal/route_api_orders.php @@ -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(); diff --git a/plugins/cipf_plugin/php/paypal/routes.php b/plugins/cipf_plugin/php/paypal/routes.php index 6252055..9d83780 100644 --- a/plugins/cipf_plugin/php/paypal/routes.php +++ b/plugins/cipf_plugin/php/paypal/routes.php @@ -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', diff --git a/plugins/cipf_plugin/php/paypal/shortcode.php b/plugins/cipf_plugin/php/paypal/shortcode.php index 54915c5..bdf403b 100644 --- a/plugins/cipf_plugin/php/paypal/shortcode.php +++ b/plugins/cipf_plugin/php/paypal/shortcode.php @@ -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(); diff --git a/plugins/cipf_plugin/php/paypal/update_user_payment.php b/plugins/cipf_plugin/php/paypal/update_user_payment.php index 0d3f78c..d174195 100644 --- a/plugins/cipf_plugin/php/paypal/update_user_payment.php +++ b/plugins/cipf_plugin/php/paypal/update_user_payment.php @@ -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)) { diff --git a/plugins/cipf_plugin/php/paypal/user_can_pay.php b/plugins/cipf_plugin/php/paypal/user_can_pay.php index fceaec7..c77b807 100644 --- a/plugins/cipf_plugin/php/paypal/user_can_pay.php +++ b/plugins/cipf_plugin/php/paypal/user_can_pay.php @@ -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(); diff --git a/plugins/cipf_plugin/php/profs_dates.php b/plugins/cipf_plugin/php/profs_dates.php index 7804218..eff408d 100644 --- a/plugins/cipf_plugin/php/profs_dates.php +++ b/plugins/cipf_plugin/php/profs_dates.php @@ -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 diff --git a/plugins/cipf_plugin/php/profs_form_commande.php b/plugins/cipf_plugin/php/profs_form_commande.php index b128eb5..49c5ece 100644 --- a/plugins/cipf_plugin/php/profs_form_commande.php +++ b/plugins/cipf_plugin/php/profs_form_commande.php @@ -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; diff --git a/plugins/cipf_plugin/php/profs_profil.php b/plugins/cipf_plugin/php/profs_profil.php index 9c3d53a..54aeab1 100644 --- a/plugins/cipf_plugin/php/profs_profil.php +++ b/plugins/cipf_plugin/php/profs_profil.php @@ -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()) diff --git a/plugins/cipf_plugin/php/redirections.php b/plugins/cipf_plugin/php/redirections.php index 9a52206..c8ff758 100644 --- a/plugins/cipf_plugin/php/redirections.php +++ b/plugins/cipf_plugin/php/redirections.php @@ -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; /* diff --git a/plugins/cipf_plugin/php/states.php b/plugins/cipf_plugin/php/states.php index 48927ca..edd4173 100644 --- a/plugins/cipf_plugin/php/states.php +++ b/plugins/cipf_plugin/php/states.php @@ -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();