Пример #1
0
 /**
  * Use the "new" post data with the old video data, to prevent the need for an external video
  * API call when the video hasn't changed.
  *
  * Match whether old data can be used on url rather than video id
  *
  * @param string $match_on  Array key to use in the $vid array to determine whether or not to use the old data
  *                          Defaults to 'url' for this implementation.
  *
  * @return bool  Whether or not valid old data was found (and used)
  */
 protected function maybe_use_old_video_data($match_on = 'id')
 {
     if ($this->id_regex !== '') {
         return parent::maybe_use_old_video_data($match_on);
     } else {
         return parent::maybe_use_old_video_data('url');
     }
 }
Пример #2
0
 /**
  * Instantiate the class
  *
  * @param array  $vid     The video array with all the data.
  * @param array  $old_vid The video array with all the data of the previous "fetch", if available.
  *
  * @return \WPSEO_Video_Details_Vippy
  */
 public function __construct($vid, $old_vid = array())
 {
     if (!class_exists('Vippy')) {
         // @todo [JRF -> Yoast] Why not use (merge with) oldvid data here if available ? Old data might still be better than none.
         $this->vid = $vid;
     } else {
         parent::__construct($vid, $old_vid);
     }
 }
Пример #3
0
 /**
  * Instantiate the class
  *
  * Retrieve the EVS location and only pass of to the parent constructor if we find one
  *
  * @param array  $vid     The video array with all the data.
  * @param array  $old_vid The video array with all the data of the previous "fetch", if available.
  *
  * @return \WPSEO_Video_Details_Evs
  */
 public function __construct($vid, $old_vid = array())
 {
     $this->evs_location = get_option('evs_location');
     if ($this->evs_location) {
         parent::__construct($vid, $old_vid);
     } else {
         // @todo [JRF -> Yoast] Why not use (merge with) oldvid data here if available ? The api key might be removed, but old data might still be better than none.
         $this->vid = $vid;
     }
 }
Пример #4
0
 /**
  * Deal with potentially wrong ids from short url format and instantiate the class
  *
  * @param array  $vid     The video array with all the data.
  * @param array  $old_vid The video array with all the data of the previous "fetch", if available.
  *
  * @return \WPSEO_Video_Details_Flickr
  */
 public function __construct($vid, $old_vid = array())
 {
     // Check for wrongly set short id as id
     if (!empty($vid['id']) && !preg_match('`^[0-9]+$`', $vid['id'])) {
         $vid['short_id'] = $vid['id'];
         unset($vid['id']);
     }
     // Make sure we use the short id if it's available and there's no id
     if (empty($vid['id']) && !empty($vid['short_id'])) {
         $this->remote_url['replace_key'] = 'short_id';
     }
     parent::__construct($vid, $old_vid);
 }
Пример #5
0
 /**
  * Determine whether or not the use of the fallback method is needed and set video details
  * to their new values by passing off to the parent method
  */
 protected function put_video_details()
 {
     if (!empty($this->decoded_response->html)) {
         $this->decoded_response->html = stripslashes($this->decoded_response->html);
         if (strpos($this->decoded_response->html, '<div itemprop="video"') === false && preg_match('`<iframe src=([\'"])([^\'"\\s]+)\\1`', $this->decoded_response->html, $match)) {
             $this->use_fallback = true;
             $response = $this->remote_get($match[2]);
             if (is_string($response) && $response !== '' && $response !== 'null') {
                 $this->frame_source = $response;
             }
         }
     }
     parent::put_video_details();
 }
Пример #6
0
 /**
  * Set video details to their new values
  */
 protected function put_video_details()
 {
     $this->set_subdomain();
     parent::put_video_details();
 }
Пример #7
0
 /**
  * Extends the parent method. By letting the parent set the response and get the first item afterwards
  */
 protected function decode_as_json()
 {
     parent::decode_as_json();
     if (!empty($this->decoded_response->items[0])) {
         $this->decoded_response = $this->decoded_response->items[0];
     }
 }
Пример #8
0
 /**
  * Use the "new" post data with the old video data, to prevent the need for an external video
  * API call when the video hasn't changed.
  *
  * Match whether old data can be used on video id or on video url if id is not available
  *
  * @param string $match_on  Array key to use in the $vid array to determine whether or not to use the old data
  *                          Defaults to 'url' for this implementation.
  *
  * @return bool  Whether or not valid old data was found (and used)
  */
 protected function maybe_use_old_video_data($match_on = 'url')
 {
     if (isset($this->old_vid['id']) && isset($this->vid['id']) && $this->old_vid['id'] == $this->vid['id']) {
         $match_on = 'id';
     }
     return parent::maybe_use_old_video_data($match_on);
 }
Пример #9
0
 /**
  * Retrieve information on a video via a remote API call
  *
  * @uses WPSEO_Video_Details_Vzaar::$remote_url
  * @uses WPSEO_Video_Details_Vzaar::$base_url
  * @uses WPSEO_Video_Details_Vzaar::$alternate_remote_pattern
  *
  * @return void
  */
 protected function get_remote_video_info()
 {
     parent::get_remote_video_info();
     if (!isset($this->remote_response) && !empty($this->vid['id']) && !empty($this->base_url)) {
         $url = sprintf($this->alternate_remote_pattern, $this->base_url, $this->vid['id']);
         $url = $this->url_encode($url);
         $response = $this->remote_get($url, array('referer' => get_site_url()));
         if ($response !== false) {
             $this->remote_response = $response;
         }
     }
 }
Пример #10
0
 /**
  * Set video details to their new values (mostly by passing off to the parent method)
  */
 protected function put_video_details()
 {
     $this->get_video_file_data();
     parent::put_video_details();
 }
Пример #11
0
 /**
  * Set video details to their new values
  */
 protected function put_video_details()
 {
     // Only save the determined details to the vid array if we're sure it's a video
     $this->set_file_path();
     $this->set_file_url();
     $this->set_attachment_id();
     parent::put_video_details();
 }
Пример #12
0
 /**
  * Instantiate the class
  *
  * @param array $vid     The video array with all the data.
  * @param array $old_vid The video array with all the data of the previous "fetch", if available.
  *
  * @return \WPSEO_Video_Details_Videopress
  */
 public function __construct($vid, $old_vid = array())
 {
     // Pre-adjust the remote url
     $host = parse_url(home_url(), PHP_URL_HOST);
     $this->remote_url['pattern'] = $this->remote_url['pattern'] . $host;
     parent::__construct($vid, $old_vid);
 }