コード例 #1
0
ファイル: rewrite.php プロジェクト: raulmontejo/vimeography
 /**
  * [vimeography_parse_request description]
  * @param  [type] $wp [description]
  * @return [type]     [description]
  */
 public function vimeography_parse_request($wp)
 {
     if (array_key_exists('vimeography_action', $wp->query_vars) and $wp->query_vars['vimeography_action'] == 'refresh') {
         require_once VIMEOGRAPHY_PATH . 'lib/cache.php';
         $cache = new Vimeography_Cache($wp->query_vars['vimeography_gallery_id']);
         if ($cache->exists()) {
             $cache->delete();
         }
         die('Thanks, Vimeo. Cache busted.');
     }
 }
コード例 #2
0
ファイル: core.php プロジェクト: raulmontejo/vimeography
 /**
  * Gets the videos for the gallery.
  *
  * @param  int $expiration Length that the cache is valid, in seconds
  * @param  int $gallery_id
  * @return [type]             [description]
  */
 public function get_videos($expiration, $gallery_id)
 {
     require_once VIMEOGRAPHY_PATH . 'lib/cache.php';
     $cache = new Vimeography_Cache($gallery_id, $expiration);
     // If the cache file exists,
     if ($cache->exists()) {
         // and the cache file is expired,
         if (($last_modified = $cache->expired()) !== FALSE) {
             // make the request with a last modified header.
             $result = $this->fetch($last_modified);
             // Here is where we need to check if $video_set exists, or if it
             // returned a 304, in which case, we can safely update the
             // cache's last modified and return it.
             if ($result == NULL) {
                 $result = $cache->renew()->get();
             } else {
                 // Cache the updated results.
                 if (intval($expiration) !== 0) {
                     $cache->set($result);
                 }
             }
         } else {
             // If it isn't expired, return it.
             $result = $cache->get();
         }
     } else {
         // If a cache doesn't exist, go get the videos, dude.
         $result = $this->fetch();
         // Cache the results.
         if (intval($expiration) !== 0 && !empty($result->video_set)) {
             $result = apply_filters('vimeography/cache-videos', $result, $gallery_id);
             $cache->set($result);
         }
     }
     return $result;
 }
コード例 #3
0
ファイル: list.php プロジェクト: raulmontejo/vimeography
 /**
  * Deletes the gallery of the given ID in the database.
  *
  * @access public
  * @param array $params
  * @return void
  */
 public function delete_gallery($params)
 {
     try {
         $id = intval($params['gallery_id']);
         global $wpdb;
         $result = $wpdb->query('DELETE gallery, meta FROM ' . VIMEOGRAPHY_GALLERY_TABLE . ' gallery, ' . VIMEOGRAPHY_GALLERY_META_TABLE . ' meta WHERE gallery.id = ' . $id . ' AND meta.gallery_id = ' . $id . ';');
         if ($result === FALSE) {
             throw new Exception(__('Your gallery could not be deleted.', 'vimeography'));
         }
         do_action('vimeography-pro/delete-gallery', $id);
         require_once VIMEOGRAPHY_PATH . 'lib/cache.php';
         $cache = new Vimeography_Cache($id);
         if ($cache->exists()) {
             $cache->delete();
         }
         do_action('vimeography/reload-galleries');
         $this->messages[] = array('type' => 'updated', 'heading' => __('Gallery deleted.', 'vimeography'), 'message' => __('See you later, sucker.', 'vimeography'));
     } catch (Exception $e) {
         $this->messages[] = array('type' => 'error', 'heading' => __('Ruh Roh.', 'vimeography'), 'message' => $e->getMessage());
     }
 }