Plugin Directory

Changeset 544204


Ignore:
Timestamp:
05/14/2012 05:27:39 PM (14 years ago)
Author:
TIgor4eg
Message:
 
Location:
video-onclick
Files:
10 added
2 edited

Legend:

Unmodified
Added
Removed
  • video-onclick/trunk/readme.txt

    r544004 r544204  
    33Contributors: TIgor4eg
    44
    5 Donate link: http://tigor.me/donate/
     5Donate link: http://tigors.net/en/en-donate/
    66
    77Tags: youtube, video, shortcode, mce, vimeo, google analytics
     
    1111Tested up to: 3.2.1
    1212
    13 Stable tag: 0.4
     13Stable tag: 0.4.1
    1414
    1515
     
    4040
    4141== Changelog ==
     42= 0.4.1 =
     43* FIX: Error, if the video was not found
    4244
    4345= 0.4 =
  • video-onclick/trunk/video-onclick.php

    r544008 r544204  
    131131    {
    132132        // Cache is old or does not exist
    133 
    134    
    135         $url = 'http://gdata.youtube.com/feeds/api/videos/'. $videoid;
    136        
    137         $sxml = simplexml_load_file($url);
    138 
    139         $media = $sxml->children('http://search.yahoo.com/mrss/');
    140        
    141 
    142        
    143         $group = $media->group;
    144        
    145 
    146         foreach( $group->thumbnail as $thumb) {
    147 
    148             if ($temp['width'] < $thumb->attributes()->width) {
     133        $ch = curl_init();
     134        $url = 'http://gdata.youtube.com/feeds/api/videos/'. $videoid; 
     135
     136        curl_setopt($ch, CURLOPT_URL, $url);
     137        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     138        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
     139
     140        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     141   
     142        $respond = curl_exec($ch);
     143       
     144        if (200 == (int)curl_getinfo($ch, CURLINFO_HTTP_CODE))
     145        {
     146
     147       
     148            $sxml = new SimpleXMLElement($respond);
     149
     150            $media = $sxml->children('http://search.yahoo.com/mrss/');
     151       
     152
     153       
     154            $group = $media->group;
     155       
     156
     157            foreach( $group->thumbnail as $thumb) {
     158
     159                if ($temp['width'] < $thumb->attributes()->width) {
    149160                $temp['url'] =  (string)$thumb->attributes()->url;
    150161                $temp['width'] = $thumb->attributes()->width;
     162                }
     163
    151164            }
    152 
    153         }
    154         if ('' == $temp['url'])
    155         {
    156 
     165            if ('' == $temp['url'])
     166            {
     167
     168                $return = plugins_url().'/video-onclick/play_youtube.jpg';
     169            } else {
     170
     171                $cache[$videoid]['time'] = time();
     172                $cache[$videoid]['url'] = $temp['url'];
     173
     174           
     175                update_option('video_onclick_cache', $cache);
     176           
     177                $return = $temp['url'];
     178            }
     179        } else {
    157180            $return = plugins_url().'/video-onclick/play_youtube.jpg';
    158         } else {
    159 
    160             $cache[$videoid]['time'] = time();
    161             $cache[$videoid]['url'] = $temp['url'];
    162 
    163            
    164             update_option('video_onclick_cache', $cache);
    165            
    166             $return = $temp['url'];
    167181        }
    168182       
Note: See TracChangeset for help on using the changeset viewer.