@@ -196,38 +196,29 @@ public function callback_post_updated( $post_id, $posts_after, $posts_before ) {
196196 return ;
197197 }
198198
199- $ _new = maybe_unserialize ( $ posts_after ->post_content );
200- $ _old = maybe_unserialize ( $ posts_before ->post_content );
199+ $ _new = maybe_unserialize ( $ posts_after ->post_content ) ?? array () ;
200+ $ _old = maybe_unserialize ( $ posts_before ->post_content ) ?? array () ;
201201
202202 // Get updated settings.
203- // Extract "location" property it will be compare separately.
204- $ _new_location = acf_extract_var ( $ _new , 'location ' );
205- $ _old_location = acf_extract_var ( $ _old , 'location ' );
206-
207- $ updated = array_diff_assoc ( $ _new , $ _old );
208-
209- // Check if "location" changed.
210- if ( $ _new_location !== $ _old_location ) {
211- $ updated ['location ' ] = $ _new_location ;
212- $ _old ['location ' ] = $ _old_location ;
213- }
203+ $ updated_keys = $ this ->get_changed_keys ( $ _new , $ _old );
204+ $ updated_keys = empty ( $ updated_keys ) ? array_keys ( $ _new ) : $ updated_keys ;
214205
215206 // Process updated properties.
216- if ( ! empty ( $ updated ) ) {
217- foreach ( $ updated as $ prop => $ value ) {
218- $ old_value = null ;
219- if ( empty ( $ value ) && is_array ( $ _old ) && ! empty ( $ _old [ $ prop ] ) ) {
220- $ action = 'deleted ' ;
221- $ old_value = $ _old [ $ prop ];
222- } else {
223- $ action = 'updated ' ;
224- }
225-
226- $ this ->log_prop ( $ action , $ post_id , $ posts_after , $ prop , $ value , $ old_value );
207+ foreach ( $ updated_keys as $ prop ) {
208+ $ old_value = null ;
209+ $ value = $ _new [ $ prop ];
210+ if ( empty ( $ value ) && is_array ( $ _old ) && ! empty ( $ _old [ $ prop ] ) ) {
211+ $ action = 'deleted ' ;
212+ $ old_value = $ _old [ $ prop ];
213+ } else {
214+ $ action = 'updated ' ;
227215 }
216+
217+ $ this ->log_prop ( $ action , $ post_id , $ posts_after , $ prop , $ value , $ old_value );
228218 }
229219 }
230220
221+
231222 /**
232223 * Logs field/field group property changes (ACF v5 only).
233224 *
0 commit comments