smal fixe in history presentation
This commit is contained in:
@@ -130,6 +130,7 @@ function set_acf_field_CIPF($acf_field, $acf_value, $acf_id) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_history = Cipf::ACF_HISTORY;
|
||||
|
||||
$old_value = get_acf_field_CIPF($acf_field, $acf_id);
|
||||
/*
|
||||
* if acf_value is the name of a key in const acf_field,
|
||||
* then we want to get its value from there,
|
||||
@@ -146,16 +147,22 @@ function set_acf_field_CIPF($acf_field, $acf_value, $acf_id) {
|
||||
|
||||
/*
|
||||
* create history
|
||||
* only if value has changed. Or not ?
|
||||
* why using new_value and not $value ? -> because acf can format fields
|
||||
*
|
||||
*/
|
||||
$old_history = get_acf_field_CIPF($acf_history, $acf_id);
|
||||
$france_timezone = new DateTimeZone("Europe/Paris");
|
||||
$date_now = date_create('now', $france_timezone)->format('d/m/Y H:i:s');
|
||||
$acf_field_name = $acf_field['_name'];
|
||||
$history = "- [$date_now] '$acf_field_name' : '$value'
|
||||
$new_value = get_acf_field_CIPF($acf_field, $acf_id);
|
||||
if ($new_value !== $old_value) {
|
||||
$old_history = get_acf_field_CIPF($acf_history, $acf_id);
|
||||
$france_timezone = new DateTimeZone("Europe/Paris");
|
||||
$date_now = date_create('now', $france_timezone)->format('d/m/Y H:i:s');
|
||||
$acf_field_name = $acf_field['_name'];
|
||||
// we use the real newline, so must not tabulate
|
||||
$history = "- [$date_now] '$acf_field_name' : '$old_value' -> '$new_value'
|
||||
";
|
||||
$history .= $old_history;
|
||||
update_field($acf_history['_name'], $history, $acf_id);
|
||||
$history .= $old_history;
|
||||
update_field($acf_history['_name'], $history, $acf_id);
|
||||
}
|
||||
}
|
||||
function get_acf_field_CIPF($acf_field, $acf_id) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
Reference in New Issue
Block a user