diff --git a/plugins/cipf_plugin/cipf_plugin.php b/plugins/cipf_plugin/cipf_plugin.php
index f2299f9..d4d2b6c 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.11
+Version: 0.5.11.2
Author URI:
*/
diff --git a/plugins/cipf_plugin/html/menu/cipf_menu.html b/plugins/cipf_plugin/html/menu/cipf_menu.html
index 35fea1a..1f69436 100644
--- a/plugins/cipf_plugin/html/menu/cipf_menu.html
+++ b/plugins/cipf_plugin/html/menu/cipf_menu.html
@@ -222,10 +222,4 @@ EXPLICATIONS CLASS CSS
-
-
-
-
diff --git a/plugins/cipf_plugin/php/_utils_acf_dates.php b/plugins/cipf_plugin/php/_utils_acf_dates.php
index 73e5cc6..ec9e596 100644
--- a/plugins/cipf_plugin/php/_utils_acf_dates.php
+++ b/plugins/cipf_plugin/php/_utils_acf_dates.php
@@ -21,13 +21,11 @@ function get_date_CIPF($acf_date, $acf_id) {
/*
* get acf date field
+ * 3d parameter is false to not format the date and get it as 'Ymd'
*
*/
- $current_date_object = get_field_object($acf_date['_name'], $acf_id);
- if ($current_date_object === false) {
- return false;
- }
- else if (empty($current_date_object['value'])) {
+ $current_date_string = get_field($acf_date['_name'], $acf_id, false);
+ if (empty($current_date_string)) {
return false;
}
@@ -35,12 +33,10 @@ function get_date_CIPF($acf_date, $acf_id) {
* create date object from acf date
*
*/
- $current_date_string = $current_date_object['value'];
- $current_format_field = $current_date_object['return_format'];
// compare 2 dates : https://stackoverflow.com/q/8722806/9497573
// also I dont use strtotime to compare 2 ints,
// because i don't know if it will fail one day (2000y bug style)
- $current_date = date_create_immutable_from_format($current_format_field, $current_date_string);
+ $current_date = date_create_immutable_from_format('Ymd', $current_date_string);
if ($current_date === false) {
return false;
}
@@ -225,8 +221,9 @@ function is_prof_account_deletion_date_exceeded_CIPF($user_id = null) {
function get_offer_date_expiration_CIPF($offer_number, $page_id) {
Plgntls::debug_infos();
- $offer_expiration = get_post_meta($page_id, 'fin_offre_'.$offer_number);
- $date_expiration = date_create_immutable_from_format('Ymd', $offer_expiration[0]);
+ // last parameter is false to not format the date, and get the 'Ymd' format
+ $offer_expiration = get_field('fin_offre_'.$offer_number, $page_id, false);
+ $date_expiration = date_create_immutable_from_format('Ymd', $offer_expiration);
return $date_expiration;
}
function is_offer_date_exceeded_CIPF($offer_number, $page_id) {
diff --git a/plugins/cipf_plugin/php/partners_handle_offers.php b/plugins/cipf_plugin/php/partners_handle_offers.php
index 54f1b87..36ebd4c 100644
--- a/plugins/cipf_plugin/php/partners_handle_offers.php
+++ b/plugins/cipf_plugin/php/partners_handle_offers.php
@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) {
function handle_partner_offers_expire_CIPF($page_id) {
Plgntls::debug_infos();
-$post = get_post($page_id);
+//$post = get_post($page_id);
$i = 1;
while ($i <= 3) {
@@ -30,8 +30,8 @@ $post = get_post($page_id);
continue;
}
-$offer_title = get_field_init_CIPF('offre_'.$i.'_titre', $page_id);
-error_log("- post: ".$post->post_title." - titre offre: ".$offer_title);
+//$offer_title = get_field_init_CIPF('offre_'.$i.'_titre', $page_id);
+//error_log("- post: ".$post->post_title." - titre offre: ".$offer_title);
handle_offer_will_expire_CIPF($i, $page_id);
handle_offer_is_expired_CIPF($i, $page_id);
diff --git a/plugins/fbpatch/php/patches/dates.php b/plugins/fbpatch/php/patches/dates.php
index af7ff5a..67dd163 100644
--- a/plugins/fbpatch/php/patches/dates.php
+++ b/plugins/fbpatch/php/patches/dates.php
@@ -40,8 +40,22 @@ if (!defined('ABSPATH')) {
*
* 118 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/advanced-custom-fields/includes/acf-value-functions.php
*
+* we can either use filter 'acf/load_value' or 'acf/pre_load_value'
+* - 'acf/pre_load_value' :
+* it fires first, and will short-circuit the function to get the value
+* it is useful to force the acf_date value to be always the same,
+* otherwise acf uses some kind of cach system,
+* so the value would be evaluated once then it would always be the same on the page : maybe it's alright ?
+* - 'acf/load_value' :
+* using this filter, the value is cached, as explained above
+* - note : the first argument '$value' is actually a little misleading :
+* - in case of the second filter,
+* it is indeed tha value that has already been retrieve and that we can override
+* - but for the first filter, it is actually 'null',
+* and if returned it will let the function go on to try to retrieve the value
+*
*/
-function try_format_acf_date($value, $post_id, $field) {
+function try_get_acf_date($value, $post_id, $field) {
$acf_date_class = Fbpatch::ACF_DATE_CLASS;
if ($field['type'] !== 'date_picker') {
return $value;
@@ -51,13 +65,18 @@ function try_format_acf_date($value, $post_id, $field) {
}
$acf_date = Fbpatch::get_acf_date($post_id, $field['key']);
+//error_log("acf_date: " . json_encode($acf_date));
if ($acf_date === false) {
return $value;
}
return $acf_date;
}
-add_filter('acf/load_value', __NAMESPACE__.'\try_format_acf_date', 10, 3);
+add_filter('acf/load_value', __NAMESPACE__.'\try_get_acf_date', 10, 3);
+//add_filter('acf/pre_load_value', __NAMESPACE__.'\try_get_acf_date', 10, 3);
+
+
+