- updated all occurences of Plgntls:: constantes for Cipf:: const

- update menu to use the new methods
This commit is contained in:
asus
2024-04-02 15:45:54 +02:00
parent 64dc0ffbc5
commit 1f5fff26d6
25 changed files with 404 additions and 549 deletions

View File

@@ -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

View 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);
}
?>

View File

@@ -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');
?>

View File

@@ -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');
?>

View File

@@ -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;
}
?>

View File

@@ -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);
}
?>

View File

@@ -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);
}
?>

View File

@@ -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;

View File

@@ -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

View File

@@ -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 :

View File

@@ -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

View File

@@ -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() {

View File

@@ -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)) {

View File

@@ -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();

View File

@@ -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',

View File

@@ -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();

View File

@@ -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)) {

View File

@@ -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();

View File

@@ -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

View File

@@ -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;

View File

@@ -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())

View File

@@ -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;
/*

View File

@@ -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();