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