null, 'plot' => 'short', ), $a )); if(empty($id)) { return 'No imdb id passed'; } $info = imdb_cache($id,$plot); if($info['Response']=='True') { $out='
'.$info['Title'].' ('.$info['Year'].')
'.$info['Title'].' poster Rating: '.$info['imdbRating'].'/10 ('.$info['imdbVotes'].' votes)
Director: '.$info['Director'].'
Writer: '.$info['Writer'].'
Stars: '.$info['Actors'].'
Runtime: '.$info['Runtime'].'
Rated: '.$info['Rated'].'
Genre: '.$info['Genre'].'
Released: '.$info['Released'].'
Plot: '.$info['Plot'].'
'; } else { $out='Error: '.$info['Error']; } return $out; } function imdb_cache($id,$plot) { $cacheage=get_option('imdbcacheage',-1); $cachedir=get_option('imdbcachedir','cache'); $imagecache=IMDBINFOABSPATH.$cachedir."/".$id.".jpg"; $textcache=IMDBINFOABSPATH.$cachedir."/".$id.".txt"; if(!file_exists($textcache) || ($cacheage>-1 && filemtime($textcache)< (time()-$cacheage))) { $raw=file_get_contents('http://www.omdbapi.com/?i='.$id.'&plot='.$plot); $info=json_decode($raw,true); file_put_contents($textcache,$raw); } else { $raw=file_get_contents($textcache); $info=json_decode($raw,true); } if(isset($info['Poster'])&&$info['Poster']!='N/A') { if(!file_exists($imagecache) || ($cacheage>-1 && filemtime($imagecache)< (time()-$cacheage))) { $img=file_get_contents($info['Poster']); file_put_contents($imagecache,$img); } $info['Poster']=IMDBINFOURL.$cachedir.'/'.$id.'.jpg'; } else { $info['Poster']=IMDBINFOURL.'default.jpg'; } return $info; } function imdb_info_stylesheet() { wp_register_style( 'imdb-info-style', site_url('/?imdbstyle=custom') ); wp_enqueue_style('imdb-info-style'); } function imdb_activate() { add_option('imdbcacheage',-1); add_option('imdbcachedir','cache'); add_option('imdbheadbg','FFCC00'); add_option('imdbheadfg','FFFFFF'); add_option('imdbbodybg','F4F3D9'); add_option('imdbbodyfg','333333'); $cachedir=get_option('imdbcachedir','cache'); $abscachedir=IMDBINFOABSPATH.$cachedir."/"; $per=substr(sprintf('%o', fileperms($abscachedir)), -3); if($per!=777) { die('Cache directory is not writable
Change Permission of '.$abscachedir.' to 777'); } } function imdb_deactivate() { delete_option('imdbcacheage'); delete_option('imdbcachedir'); delete_option('imdbheadbg'); delete_option('imdbheadfg'); delete_option('imdbbodybg'); delete_option('imdbbodyfg'); } function imdb_menu() { add_options_page('IMDB infobox Settings', 'IMDB infobox Settings', 'manage_options', 'imdb-infobox', 'imdb_admin_option'); } function imdb_admin_option(){ wp_enqueue_script('imdb-addmin-js', plugins_url('jscolor/jscolor.js', __FILE__)); $cachedir=get_option('imdbcachedir','cache'); $abscachedir=IMDBINFOABSPATH.$cachedir."/"; $files=glob($abscachedir."*"); $filecount=count($files); ?>

IMDB infobox Settings

Heading Background Color
Heading Text Color
Body Background Color
Body Text Color
Cache Age
Set cache age in seconds (eg: 3600 for 1 hour) or -1 for never expire