public function __construct($args)
 {
     $defaults = array('source' => 'vimeo', 'feed' => 'search', 'query' => false, 'results' => 20, 'page' => 0, 'response' => 'json', 'order' => 'new');
     $data = wp_parse_args($args, $defaults);
     // if no query is specified, bail out
     if (!$data['query']) {
         return false;
     }
     $request_args = array('feed' => $data['feed'], 'feed_id' => $data['query'], 'page' => $data['page'], 'response' => $data['response'], 'sort' => $data['order']);
     parent::__construct($request_args);
     $content = parent::request_feed();
     if (is_wp_error($content) || 200 != $content['response']['code']) {
         if (is_wp_error($content)) {
             $this->errors = new WP_Error();
             $this->errors->add('cvm_wp_error', $content->get_error_message(), $content->get_error_data());
         }
         return false;
     }
     $result = json_decode($content['body'], true);
     // set up Vimeo query errors if any
     if (isset($result['error'])) {
         $this->errors = new WP_Error();
         $this->errors->add('cvm_vimeo_query_error', __('Query to Vimeo failed.', 'cvm_video'), $result['error_description']);
     }
     /* single video entry */
     if ('video' == $request_args['feed']) {
         if (isset($result['uri'])) {
             $this->results = $this->format_video_entry($result);
         } else {
             $this->results = array();
         }
         return;
     }
     // processign multi videos playlists
     if (isset($result['data'])) {
         $raw_entries = $result['data'];
     } else {
         $raw_entries = array();
     }
     $entries = array();
     foreach ($raw_entries as $entry) {
         $entries[] = $this->format_video_entry($entry);
     }
     $this->results = $entries;
     $this->total_items = isset($result['total']) ? $result['total'] : 0;
     $this->page = isset($result['page']) ? $result['page'] : 0;
 }
 /**
  * Output plugin settings page
  */
 public function plugin_settings()
 {
     $options = cvm_get_settings();
     $player_opt = cvm_get_player_settings();
     // fire up Vimeo class
     require_once CVM_PATH . 'includes/libs/vimeo.class.php';
     $vimeo = new CVM_Vimeo();
     if (!empty($options['vimeo_consumer_key']) && !empty($options['vimeo_secret_key'])) {
         if (empty($options['oauth_token'])) {
             // account token
             $token = $vimeo->get_unauth_token();
             if (!is_wp_error($token)) {
                 $options['oauth_token'] = $token;
                 update_option('_cvm_plugin_settings', $options);
             } else {
                 $authorize_error = $token->get_error_message();
             }
         }
     }
     include CVM_PATH . 'views/plugin_settings.php';
 }