Esempio n. 1
0
 public function __construct($settings)
 {
     parent::__construct($settings);
     $this->_auth = VIMEOGRAPHY_CLIENT_ID;
     $this->_vimeo = new Vimeography_Vimeo($this->_auth);
     $this->_vimeo->set_user_agent(sprintf('Vimeography loves you (%s)', home_url()));
 }
Esempio n. 2
0
 public function __construct($settings)
 {
     parent::__construct($settings);
 }
Esempio n. 3
0
 /**
  * Read the shortcode and return the output.
  * example:
  * [vimeography id="1" theme='apple']
  * 
  * @access public
  * @param mixed $atts
  * @return void
  */
 public function vimeography_shortcode($atts, $content = NULL)
 {
     // Let's get the data for this gallery from the db
     if (intval($atts['id'])) {
         global $wpdb;
         $gallery_info = $wpdb->get_results('SELECT * from ' . VIMEOGRAPHY_GALLERY_META_TABLE . ' AS meta JOIN ' . VIMEOGRAPHY_GALLERY_TABLE . ' AS gallery ON meta.gallery_id = gallery.id WHERE meta.gallery_id = ' . $atts['id'] . ' LIMIT 1;');
     }
     // Get admin panel options
     $default_settings = get_option('vimeography_default_settings');
     $gallery_settings['theme'] = isset($gallery_info[0]->theme_name) ? $gallery_info[0]->theme_name : $default_settings['theme_name'];
     $gallery_settings['featured'] = isset($gallery_info[0]->featured_video) ? $gallery_info[0]->featured_video : $default_settings['featured_video'];
     $gallery_settings['source'] = isset($gallery_info[0]->source_url) ? $gallery_info[0]->source_url : $default_settings['source_url'];
     $gallery_settings['limit'] = isset($gallery_info[0]->video_limit) ? $gallery_info[0]->video_limit : $default_settings['video_limit'];
     $gallery_settings['cache'] = isset($gallery_info[0]->cache_timeout) ? $gallery_info[0]->cache_timeout : $default_settings['cache_timeout'];
     $gallery_settings['width'] = isset($gallery_info[0]->gallery_width) ? $gallery_info[0]->gallery_width : '';
     // Get shortcode attributes
     $settings = shortcode_atts(array('id' => '', 'theme' => $gallery_settings['theme'], 'featured' => $gallery_settings['featured'], 'source' => $gallery_settings['source'], 'limit' => $gallery_settings['limit'], 'cache' => $gallery_settings['cache'], 'width' => $gallery_settings['width']), $atts);
     if (!empty($settings['width'])) {
         preg_match('/(\\d*)(px|%?)/', $settings['width'], $matches);
         // If a number value is set...
         if (!empty($matches[1])) {
             // If a '%' or 'px' is set...
             if (!empty($matches[2])) {
                 // Accept the valid matching string
                 $settings['width'] = $matches[0];
             } else {
                 // Append a 'px' value to the matching number
                 $settings['width'] = $matches[1] . 'px';
             }
         } else {
             // Not a valid width
             $settings['width'] = '';
         }
     }
     try {
         require_once VIMEOGRAPHY_PATH . 'lib/core.php';
         $vimeography = Vimeography_Core::factory('videos', $settings);
         $settings_check = $settings;
         $unused_id = array_shift($settings_check);
         // If the shortcode settings are equal to the DB settings, the
         // gallery isn't being overloaded by shortcode, so proceed to render
         // the standard cache.
         if ($settings_check == $gallery_settings) {
             // if cache is set, render it. otherwise, get the json, set the
             // cache, and render it
             if (($vimeography_data = $this->get_vimeography_cache($settings['id'])) === FALSE) {
                 // cache not set, let's do a new request to the vimeo API
                 // and cache it if the cache settings aren't zero seconds
                 $vimeography_data = $vimeography->get('videos');
                 if ($settings['cache'] != 0) {
                     $transient = $this->set_vimeography_cache($settings['id'], $vimeography_data, $settings['cache']);
                 }
             }
         } else {
             $cache_hash = $settings['id'] . '_' . md5(serialize($settings_check));
             // if cache is set, render it. otherwise, get the json, set the
             // cache, and render it
             if (($vimeography_data = $this->get_vimeography_cache($cache_hash)) === FALSE) {
                 // cache not set, let's do a new request to the vimeo API
                 // and cache it if the cache settings aren't zero seconds
                 $vimeography_data = $vimeography->get('videos');
                 if ($settings['cache'] != 0) {
                     $transient = $this->set_vimeography_cache($cache_hash, $vimeography_data, $settings['cache']);
                 }
             }
         }
         return $vimeography->render($vimeography_data);
     } catch (Vimeography_Exception $e) {
         return "Vimeography error: " . $e->getMessage();
     }
 }