$update_options['order']['delivery']['minimum_total']['deliverycharges_below_total'] = $defaultOptions['order']['delivery']['minimum_total']['deliverycharges_below_total']; } /**************************************************************************** $update_options now holds the old options plus the added new defaults options *****************************************************************************/ /********************************************** [now lets remove obsolete options] ***********************************************/ $removed_options = wppizza_compare_options($options, $defaultOptions); /*get obsolete options**/ /*ini array*/ $arr1_flat = array(); $arr2_flat = array(); /*flatten*/ $arr1_flat = wppizza_flatten($update_options); $arr2_flat = wppizza_flatten($removed_options); /*get difference*/ $ret = array_diff_assoc($arr1_flat, $arr2_flat); /**unflatten->final options**/ $update_options = wppizza_inflate($ret); /****************************************************************************************************** * * $update_options now holds old options plus the added new defaults options minus the removed options * ******************************************************************************************************/ /**override some options as we do NOT want to remove them*/ /*although these arrays are set in defaultOptions, the default values are empty, as the dimensions of it are user generated and we do not want to loose these values when comparing / updating**/ /*if we however ever not use any of these options above, we can delete the relevant one here**/ if (isset($options['times_closed_standard'])) { $update_options['times_closed_standard'] = $options['times_closed_standard']; }
function wppizza_flatten($arr, $base = "", $divider_char = "/") { $ret = array(); if (is_array($arr)) { foreach ($arr as $k => $v) { if (is_array($v)) { $tmp_array = wppizza_flatten($v, $base . $k . $divider_char, $divider_char); $ret = array_merge($ret, $tmp_array); } else { $ret[$base . $k] = $v; } } } return $ret; }