$query; /* * try to extract a string * */ while (is_array($output) && count($output) === 1) $output = reset($output); /* * if is not acf * check if is a date * and format it * to create a DateTime from a time stamp : https://stackoverflow.com/a/12039058/9497573 * */ if (!$is_acf) { $timestamp = false; if (is_string($output)) { $timestamp = strtotime($output); } if ($timestamp !== false) { $date = new DateTime('@' . $timestamp); $output = $date->format($output_date_format); } } /* * return the result * */ if (is_array($output) && count($output) === 0) $output = ''; if (!is_string($output)) $output = json_encode($output, JSON_UNESCAPED_SLASHES); return esc_html($output); } ?>