Files
2024_WEBSITE_fipf/ç

198 lines
5.5 KiB
Plaintext

<?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!');
}
/*
* schedule events :
* - first use a function to add the event :
* - function launch_schedule_my_evet() {
* wp_schedule_single_event($delay, 'hook_event_name');
* }
* - this will enqueue an action hook when the time will come, that you must define :
* - add_action('hook_event_name', 'callback_function');
* - and finally, define the function 'callback_function()'
*
* to define the delay, you can use the strtotime notation
* - strtotime('+1 month');
* -> https://www.php.net/manual/en/function.strtotime.php
* or the time constants in seconds :
* - time() + 3 * MINUTE_IN_SECONDS
* -> https://codex.wordpress.org/Easier_Expression_of_Time_Constants
*
*/
/*
* events and emails :
*
* 1. [/] payments : TIME_OLD_ORDER_ID - suppress old order_ids
* 2. [ ] prof (email) : TIME_ACCOUNT_DELETE_AFTER_EXPIRE - schedule event to suppress the account xx time (6 month ?) after end of validity of the card, and supress the codes
* 3. [ ] prof (email) : - schedule event to deactivate the card
* 4. [ ] prof (email) : TIME_REMINDER_BEFORE_ACCOUNT_EXPIRE_FIRST - send emails reminder before account deactivate
* 5. [ ] prof (email) : TIME_REMINDER_BEFORE_ACCOUNT_EXPIRE_LAST - send emails reminder before account deactivate
* 6. [ ] prof (email) : TIME_REMINDER_BEFORE_ACCOUNT_DELETE_FIRST - send emails reminder before account delete
* 7. [ ] prof (email) : TIME_REMINDER_BEFORE_ACCOUNT_DELETE_LAST - send emails reminder before account delete
* 8. [ ] partner (email) : TIME_REMINDER_BEFORE_OFFER_EXPIRE - send emails reminder before offer ends
* 9. [ ] partners (email) : - temp offers -> make them disappeay after end card validity -> put them in hidden
*
*/
/*
* 1. prof, add a schedule event to delete this order_id
* after 3 days ?
*
*/
function schedule_delete_orderid_CIPF($user_id, $order_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'orderid_deletion_event_CIPF', array($user_id, $order_id));
}
function delete_order_id_later_CIPF($user_id, $order_id) {
Plgntls::debug_infos();
delete_user_meta($user_id, 'cipf_order_id', $order_id);
}
add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 10, 2);
/*
* 2. prof, suppress account XX time after expiration, also email
*
*/
function schedule_prof_account_suppression_CIPF($user_id) {
Plgntls::debug_infos();
$duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
$date_limit = get_date_limit_CIPF($user_id);
$time_limit = $date_limit->getTimestamp();
//$date_interval = date_interval_create_from_date_string($duration_deletion);
//$date_deletion = $date_limit->add($date_interval);
$date_deletion = $date_limit->modify($duration_deletion);
$time_deletion = $date_deletion->getTimestamp();
error_log("duration_deletion: " . json_encode($duration_deletion));
error_log("date_limit : " . json_encode($date_limit));
//error_log("date_interval: " . json_encode($date_interval));
error_log("date_deletion: " . json_encode($date_deletion));
error_log("time_deletion: " . json_encode($time_deletion));
/*
duration_deletion: "6 months"
date_limit : {"date":"2094-09-19 15:30:29.000000","timezone_type":3,"timezone":"UTC"}
date_deletion: {"date":"2094-09-19 15:30:29.000000","timezone_type":3,"timezone":"UTC"}
time_deletion: 3935748629
*/
//$delay = strtotime('+3 days');
// wp_schedule_single_event($delay, 'scedule_event_CIPF', array($user_id));
}
//function event_CIPF($user_id) {
// Plgntls::debug_infos();
//}
//add_action('schedule_event_CIPF', 'event_CIPF', 10, 2);
/*
* 3. prof, deactivate card at expiration time, also email
*
function schedule__CIPF($user_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'scedule_event_CIPF', array($user_id));
}
function event_CIPF($user_id) {
Plgntls::debug_infos();
}
add_action('schedule_event_CIPF', 'event_CIPF', 10, 2);
*/
/*
* 4. && 5. prof, send email reminder before account expire
*
function schedule__CIPF($user_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'scedule_event_CIPF', array($user_id));
}
function event_CIPF($user_id) {
Plgntls::debug_infos();
}
add_action('schedule_event_CIPF', 'event_CIPF', 10, 2);
*/
/*
* 6. && 7. prof, send email reminder account deletion
*
function schedule__CIPF($user_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'scedule_event_CIPF', array($user_id));
}
function event_CIPF($user_id) {
Plgntls::debug_infos();
}
add_action('schedule_event_CIPF', 'event_CIPF', 10, 2);
*/
/*
* 8. partner, send email before offer expire
*
function schedule__CIPF($user_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'scedule_event_CIPF', array($user_id));
}
function event_CIPF($user_id) {
Plgntls::debug_infos();
}
add_action('schedule_event_CIPF', 'event_CIPF', 10, 2);
*/
/*
* 9. partner, handle offer expire, also sens email
*
function schedule__CIPF($user_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'scedule_event_CIPF', array($user_id));
}
function event_CIPF($user_id) {
Plgntls::debug_infos();
}
add_action('schedule_event_CIPF', 'event_CIPF', 10, 2);
*/
?>