$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); $date = date_create('@' . $timestamp); $output = $date->format($output_date_format); } } /* * check options to format the result * */ return \CUSTER\return_result($output, $if_empty); } /* * find the posts of the user and return the first one * */ function find_user_post_url($user_id) { $user_post_url = ''; $args = array( 'post_type' => 'post', 'author' => $user_id, 'posts_per_page' => 1, ); $posts = get_posts($args); if (empty($posts)) { $user_post_url = ''; } else { $query = reset($posts); $user_post_url = get_permalink($query->ID); } return $user_post_url; } ?>