cipf v 0.5.8 handle partner events
This commit is contained in:
71
plugins/cipf_plugin/php/partners_handle_offers.php
Normal file
71
plugins/cipf_plugin/php/partners_handle_offers.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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 handle_partner_offers_expire_CIPF($page_id) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
$i = 1;
|
||||
while ($i <= 3) {
|
||||
$offer_duration = get_field_init_CIPF('duree_offre_'.$i, $page_id);
|
||||
if ($offer_duration !== 'Temporaire') {
|
||||
++$i;
|
||||
continue;
|
||||
}
|
||||
$offer_output = get_field_init_CIPF('afficher_offre_'.$i, $page_id);
|
||||
if ($offer_output === 'Masquer') {
|
||||
++$i;
|
||||
continue;
|
||||
}
|
||||
handle_offer_is_expired_CIPF($i, $page_id);
|
||||
handle_offer_will_expire_CIPF($i, $page_id);
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handle_offer_will_expire_CIPF($i, $page_id) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
if (is_offer_date_exceeded_CIPF($i, $page_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$date_limit = get_offer_date_expiration_CIPF($i, $page_id);
|
||||
if (false === $date_limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post = get_post($page_id);
|
||||
$user_id = $post->post_author;
|
||||
handle_send_reminders_CIPF($page_id, $user_id, $date_limit, 'offer_expiration', 'offer_will_expire');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function handle_offer_is_expired_CIPF($i, $page_id) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
if (!is_offer_date_exceeded_CIPF($i, $page_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_field('afficher_offre_'.$i, 'Masquer', $page_id);
|
||||
set_email_reminder_choice_CIPF('offer_expired', $acf_id);
|
||||
send_emails_CIPF('offer_expired', $user_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user