/**
  * @param string $url
  * @param string $format
  * @param int    $maxwidth
  * @param int    $maxheight
  * @param string $callback
  *
  * @return array|WP_JSON_Response|WP_Error
  */
 public function get_oembed_response($url, $format = 'json', $maxwidth = 640, $maxheight = 420, $callback = '')
 {
     if ('json' !== $format) {
         return new WP_Error('json_oembed_invalid_format', __('Format not supported.'), array('status' => 501));
     }
     $id = Helper::url_to_postid($url);
     if (0 === $id || !in_array(get_post_type($id), $this->type)) {
         return new WP_Error('json_oembed_invalid_url', __('Invalid URL.'), array('status' => 404));
     }
     if (320 > $maxwidth || 180 > $maxheight) {
         return new WP_Error('json_oembed_invalid_dimensions', __('Not implemented.'), array('status' => 501));
     }
     /** @var array $post */
     $post = get_post($id, ARRAY_A);
     // Link headers (see RFC 5988)
     $response = new WP_JSON_Response();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', $post['post_modified_gmt']) . 'GMT');
     $post = $this->prepare_response($post, $maxwidth, $maxheight);
     if (is_wp_error($post)) {
         return $post;
     }
     $response->link_header('alternate', get_permalink($id), array('type' => 'text/html'));
     $response->set_data($post);
     if ('' !== $callback) {
         $_GET['_jsonp'] = $callback;
     }
     return $response;
 }