From bc068280931bbda712432efb01449aacc064fdda Mon Sep 17 00:00:00 2001 From: asus Date: Tue, 2 Apr 2024 13:24:22 +0200 Subject: [PATCH] wip event schedule --- plugins/cipf_plugin/cipf_plugin.php | 1 + plugins/cipf_plugin/php/profs_profil.php | 4 +- plugins/cipf_plugin/php/scheduled_events.php | 84 ++++++++++++++++---- wordpress_docker | 2 +- 4 files changed, 74 insertions(+), 17 deletions(-) diff --git a/plugins/cipf_plugin/cipf_plugin.php b/plugins/cipf_plugin/cipf_plugin.php index 69f6aad..bbc7f45 100644 --- a/plugins/cipf_plugin/cipf_plugin.php +++ b/plugins/cipf_plugin/cipf_plugin.php @@ -52,6 +52,7 @@ 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'); // admin include_once(Plgntls::root_path() . 'php/admin_hide_bar.php'); include_once(Plgntls::root_path() . 'php/admin_user_profil.php'); diff --git a/plugins/cipf_plugin/php/profs_profil.php b/plugins/cipf_plugin/php/profs_profil.php index 1d792bc..9c3d53a 100644 --- a/plugins/cipf_plugin/php/profs_profil.php +++ b/plugins/cipf_plugin/php/profs_profil.php @@ -55,8 +55,10 @@ function prof_profil_check_CIPF() { * in case event didn't fire, handle card changes * */ - handle_transfert_validation_CIPF($user_id); + handle_transfert_validation_CIPF($author_id); handle_card_expire_CIPF($author_id); + +schedule_test_CIPF(); } add_action('wp', 'prof_profil_check_CIPF', 11); diff --git a/plugins/cipf_plugin/php/scheduled_events.php b/plugins/cipf_plugin/php/scheduled_events.php index 65e4e34..0646086 100644 --- a/plugins/cipf_plugin/php/scheduled_events.php +++ b/plugins/cipf_plugin/php/scheduled_events.php @@ -9,26 +9,80 @@ if (!defined('ABSPATH')) { + + +/* +* 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 : +* +* - payments : : suppress old order_ids +* - profs : email : validation payment prof, send email +* - profs : email : validation transfert prof, send email +* - partners : : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer +* - partners : : la gestion des offres à échéance +* - payments : email : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte +* - payments : email : schedule event pour supprimer les codes +* - payments : email : schedule event pour desactiver la carte +* - payments : email : faire rappels emails +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +*/ + + + + /* * add a schedule event to delete this order_id * after 3 days ? -* time() + 60 = one minute from now -* time() + MINUTE_IN_SECONDS = one minute from now -* -> https://codex.wordpress.org/Easier_Expression_of_Time_Constants -* -> also strtotime : https://www.php.net/manual/en/function.strtotime.php * */ -//function schedule_delete_orderid_CIPF($user_id, $order_id) { -// Plgntls::debug_infos(); -// $delay = time() + MINUTE_IN_SECONDS; -// 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', 5, 2); - +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); diff --git a/wordpress_docker b/wordpress_docker index 3c0a32e..ce6d6b4 160000 --- a/wordpress_docker +++ b/wordpress_docker @@ -1 +1 @@ -Subproject commit 3c0a32e6ac325f7983ef51be3196173297b9aa05 +Subproject commit ce6d6b442a6337df4f846414c64f54b23ba82aec