fixed error when retrievieng acf dates with format
This commit is contained in:
@@ -4,7 +4,7 @@ Plugin Name: hggg_cipf
|
||||
Plugin URI:
|
||||
Description:
|
||||
Author: hugogogo
|
||||
Version: 0.5.11
|
||||
Version: 0.5.11.2
|
||||
Author URI:
|
||||
*/
|
||||
|
||||
|
||||
@@ -222,10 +222,4 @@ EXPLICATIONS CLASS CSS
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2></h2>
|
||||
<ul>
|
||||
<li><strong> : </strong></li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user