changed acf field access from _name to _key

This commit is contained in:
asus
2024-03-19 15:05:33 +01:00
parent aad98c5188
commit 2f0b15dd6f
6 changed files with 80 additions and 33 deletions

View File

@@ -33,7 +33,6 @@ function get_date_limit_CIPF($user_id = null) {
* get acf date field
*
*/
$date_now = date_create('today');
$current_date_limit_object = get_field_object($acf_card_expiration['_name'], $acf_id);
if ($current_date_limit_object === false) {
return false;
@@ -87,6 +86,7 @@ function card_date_diff_CIPF($user_id = null) {
* returns diff in days
*
*/
$date_now = date_create('today');
$date_diff = date_diff($date_now, $current_date_limit);
return (int)$date_diff->format('%R%a');
}
@@ -96,6 +96,7 @@ function card_date_diff_CIPF($user_id = null) {
/*
* returns true if date is in paste or is empty
* use is_card_date_exists_CIPF to check if the field is empty
*
*/
function is_card_date_expired_CIPF($user_id = null) {
@@ -126,6 +127,42 @@ function is_card_date_expired_CIPF($user_id = null) {
/*
* returns true if date is empty
*
*/
function card_date_exists_CIPF($user_id = null) {
PLGNTLS_class::debug_infos();
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION;
/*
* define ids
*
*/
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
/*
* get acf date field
*
*/
$date_now = date_create('today');
$current_date = get_field($acf_card_expiration['_name'], $acf_id);
if (empty($current_date)) {
return false;
}
if (is_null($current_date)) {
return false;
}
return true;
}
/*
* will add card_duration to card
* card_duration is expected in a string format : https://www.php.net/manual/en/class.dateinterval.php