/**
  * Format the value of the property before it's returned
  * to WordPress admin or the site.
  *
  * @param  mixed  $values
  * @param  string $slug
  * @param  int    $post_id
  *
  * @return array
  */
 public function format_value($values, $slug, $post_id)
 {
     if (is_array($values) || is_object($values)) {
         $items = $this->get_settings()->items;
         $result = [];
         foreach ($values as $key => $id) {
             // Backwards compatibility with array `id` and `id`.
             $id = is_object($id) ? $id->id : $id;
             if (empty($id)) {
                 continue;
             }
             if (papi_is_empty($items)) {
                 $post = get_post($id);
                 if (empty($post)) {
                     continue;
                 }
                 $result[] = $post;
             } else {
                 $item = array_filter($items, function ($item) use($id) {
                     return wp_list_pluck([$item], 'id')[0] === (int) $id;
                 });
                 $result[] = papi_maybe_convert_to_object(array_values($item)[0]);
             }
         }
         return $this->sort_value($result, $slug, $post_id);
     }
     return $this->default_value;
 }
 /**
  * Format the value of the property before it's returned
  * to WordPress admin or the site.
  *
  * @param  mixed  $values
  * @param  string $slug
  * @param  int    $post_id
  *
  * @return array
  */
 public function format_value($values, $slug, $post_id)
 {
     if (is_array($values) || is_object($values)) {
         $items = $this->get_settings()->items;
         $result = [];
         foreach ($values as $id) {
             // Backwards compatibility with array `id` and `id`.
             $id = is_object($id) ? $id->id : $id;
             $id = is_array($id) ? $id['id'] : $id;
             if (empty($id)) {
                 continue;
             }
             if (papi_is_empty($items)) {
                 $post = get_post($id);
                 if (empty($post)) {
                     continue;
                 }
                 $result[] = $post;
             } else {
                 $id = (int) $id;
                 $item = null;
                 foreach ((array) $items as $value) {
                     $ids = wp_list_pluck([$value], 'id');
                     $ids = count($ids) > 0 ? strval($ids[0]) : '';
                     if ($ids === (string) $id) {
                         $item = $value;
                         break;
                     }
                 }
                 if (is_array($item) || is_object($item)) {
                     $result[] = papi_maybe_convert_to_object($item);
                 }
             }
         }
         return $this->sort_value($result, $slug, $post_id);
     }
     return $this->default_value;
 }