예제 #1
0
 /**
  * Catch exception and display error message
  *
  * @access public
  */
 public function catchException()
 {
     if (is_admin()) {
         echo $this->displayAdminNotice();
     } else {
         echo Message::alert($this->getMessage(), 'alert-error');
         if (WP_DEBUG) {
             \SilverWp\Debug::dumpPrint($this->getTrace());
         }
     }
 }
예제 #2
0
 /**
  * Get video data
  *
  * @param integer $post_id
  * @param string  $key_name field key name
  *
  * @return array
  */
 public function getMedia($post_id, $key_name = 'video')
 {
     $file_data = array();
     $meta_box = $this->get($post_id, $key_name);
     $video_url = false;
     if (isset($meta_box['video_url']) && $meta_box['video_url']) {
         $video_url = $meta_box['video_url'];
     }
     if ($video_url) {
         try {
             $oEmbed = new Oembed($video_url);
             $file_data['provider_name'] = $oEmbed->provider_name;
             $file_data['file_url'] = $video_url;
             $file_data['thumbnail_url'] = $oEmbed->getThumbnailUrl();
         } catch (Exception $ex) {
             echo Message::alert($ex->getMessage(), 'alert-danger');
             if (WP_DEBUG) {
                 Debug::dumpPrint($ex->getTraceAsString(), 'Stack trace:');
                 Debug::dumpPrint($ex->getTrace(), 'Full stack:');
             }
         }
     }
     return $file_data;
 }