YOUTUBE PRESS

Posted: 5 Decembrie 2010 in VIDEO

function tube_add_admin(){ add_options_page(‘EasyTube’, ‘EasyTube’, 8, ‘easytube’, ‘tube_options’);}

// 0.8235 = the magic YouTube video ratio! H = (W * 0.8235)$tube_sizes = array( 1 =>array( „name” =>”Default – 425 x 355″, „w” =>”425″, „h” =>”355″ ), 2 =>array( „name” =>”Large – 700 x 576″, „w”=>”700”, „h”=>”576” ), 3 =>array( „name” =>”Medium – 350 x 288″, „w”=>”350”, „h”=>”228” ), 4 =>array( „name” =>”Small – 250 x 206″, „w”=>”250”, „h”=>”206” ), 5 =>array( „name” =>”Massive Widescreen – 640 x 385″, „w”=>”640”, „h”=>”385” ), 6 =>array( „name” =>”Large Widescreen – 540 x 345″, „w”=>”560”, „h”=>”345” ), 7 =>array( „name” =>”Medium Widescreen – 480 x 295″, „w”=>”480”, „h”=>”295” ), 8 => array( „name” =>”Small Widescreen – 425 x 264″, „w”=>”425”, „h”=>”264” ) ); $tube_colors = array( 1=>array( „a”=>”666666”, „b”=>”d3d3d3” ), 2=>array( „a”=>”3A3A3A”, „b”=>”999999” ), 3=>array( „a”=>”2B405B”, „b”=>”6B8AB6” ), 4=>array( „a”=>”006699”, „b”=>”54ABD6” ), 5=>array( „a”=>”234900”, „b”=>”4E9400” ), 6=>array( „a”=>”E1600F”, „b”=>”FEBD01” ), 7=>array( „a”=>”CC2550”, „b”=>”E87A9F” ), 8=>array( „a”=>”402061”, „b”=>”9461CA” ), 9=>array( „a”=>”5D1719”, „b”=>”CD311B” ) );

/* * The YouTube code  */function tube_content($content) { global $tube_sizes, $tube_colors; $global = intval(get_option(‘easytube_global’)); $size = intval(get_option(‘easytube_size’)); $border = intval(get_option(‘easytube_border’)); $rel = intval(get_option(‘easytube_rel’)); $auto = intval(get_option(‘easytube_auto’)); $color = intval(get_option(‘easytube_color’));     $regex = ‘/\/i’; preg_match_all( $regex, $content, $matches ); for($x=0; $x<count($matches[0]); $x++) { $parts = explode(” „, $matches[1][$x]); $vid= explode(‘=’,$parts[0],2); $vid = $vid[1]; if(is_feed()){ $replace = „<a href=\”http://www.youtube.com/watch?v=$vid\”><img src=\”http://img.youtube.com/vi/$vid/default.jpg\” width=\”130\” height=\”97\” border=0></a>”; } else { if($global) { $replace = ‘[‘a’].’&color2=’.$tube_colors[$color][‘b’].’&rel=’.$rel.’&border=’.$border.’]’; } else { if(count($parts) > 1) { $width = $parts[1]; if(count($parts) > 2){ $height = $parts[2]; } else { $height = ($width * 0.8235); } $replace = ‘<object width=”‘.$width.'” height=”‘.$height.'” type=”application/x-shockwave-flash” data=”http://www.youtube.com/v/&#8217;.$vid.’?fs=1″><param name=”movie” value=”http://www.youtube.com/v/&#8217;.$vid.’?fs=1″ /><param name=”wmode” value=”transparent” /><em>You need to a flashplayer enabled browser to view this YouTube video</em></object>’; } else { $vid= explode(‘=’,$matches[1][$x]); $vid = $vid[1]; $replace = ‘<object width=”425″ height=”355″ type=”application/x-shockwave-flash” data=”http://www.youtube.com/v/&#8217;.$vid.’?fs=1″><param name=”wmode” value=”transparent” /><param name=”movie” value=”http://www.youtube.com/v/&#8217;.$vid.’?fs=1″ /><em>You need to a flashplayer enabled browser to view this YouTube video</em></object>’; } } } $content = str_replace($matches[0][$x], $replace, $content); } return $content;}

/* * Vimeo Code * Settings in options do not work for these… well maybe height will… */function vimeo_content($content){    $regex = ‘/\[vimeo:(.*?)]/i’; preg_match_all( $regex, $content, $matches ); for($x=0; $x<count($matches[0]); $x++){ $parts = explode(” „, $matches[1][$x]); if(count($parts) > 1){ $vid= explode(‘=’,$parts[0]); $vid = $vid[1]; $width = $parts[1]; if(count($parts) > 2){ $height = $parts[2]; } else { $height = „”; } $replace = ‘<object width=”‘.$width.'” height=”‘.$height.'” type=”application/x-shockwave-flash” data=”http://video.google.com/googleplayer.swf?docId=&#8217;.$vid.'”><param name=”movie” value=”http://video.google.com/googleplayer.swf?docId=&#8217;.$vid.'” /><em>You need to have flashplayer enabled to watch this Google video</em></object>’; } else { $vid= explode(‘=’,$matches[1][$x]); $vid = $vid[1]; $replace = ‘<object width=”425″ height=”350″ type=”application/x-shockwave-flash” data=”http://video.google.com/googleplayer.swf?docId=&#8217;.$vid.'”><param name=”wmode” value=”transparent” /><param name=”movie” value=”http://video.google.com/googleplayer.swf?docId=&#8217;.$vid.'” /><em>You need to have flashplayer enabled to watch this Google video</em></object>’; } $content = str_replace($matches[0][$x], $replace, $content); } return $content;}

/* * Google Video Code * Settings in options do not work for these… well maybe height will… */function googlevideo_content($content){    $regex = ‘/\[googlevideo:(.*?)]/i’; preg_match_all( $regex, $content, $matches ); for($x=0; $x<count($matches[0]); $x++){ $parts = explode(” „, $matches[1][$x]); if(count($parts) > 1){ $vid= explode(‘=’,$parts[0]); $vid = $vid[1]; $width = $parts[1]; if(count($parts) > 2){ $height = $parts[2]; } else { $height = „”; } $replace = ‘<object width=”‘.$width.'” height=”‘.$height.'” type=”application/x-shockwave-flash” data=”http://video.google.com/googleplayer.swf?docId=&#8217;.$vid.'”><param name=”movie” value=”http://video.google.com/googleplayer.swf?docId=&#8217;.$vid.'” /><em>You need to have flashplayer enabled to watch this Google video</em></object>’; } else { $vid= explode(‘=’,$matches[1][$x]); $vid = $vid[1]; $replace = ‘<object width=”425″ height=”350″ type=”application/x-shockwave-flash” data=”http://video.google.com/googleplayer.swf?docId=&#8217;.$vid.'”><param name=”wmode” value=”transparent” /><param name=”movie” value=”http://video.google.com/googleplayer.swf?docId=&#8217;.$vid.'” /><em>You need to have flashplayer enabled to watch this Google video</em></object>’; } $content = str_replace($matches[0][$x], $replace, $content); } return $content;}
/* * The Options page for EasyTube. We rock… thanks. */function tube_options(){ global $tube_sizes,$tube_colors; $options = array(„easytube_global”,”easytube_border”,”easytube_rel”,”easytube_auto”); if($_POST[‘action’] == ‘save’) { update_option(‘easytube_size’, $_POST[‘easytube_size’]); update_option(‘easytube_color’, $_POST[‘easytube_color’]); foreach($options as $o) { $val = !empty($_POST[$o]); update_option($o, $val); } } $global = get_option(‘easytube_global’); $size = get_option(‘easytube_size’); $border = get_option(‘easytube_border’); $rel = get_option(‘easytube_rel’); $auto = get_option(‘easytube_auto’); $color = get_option(‘easytube_color’); ?><!– EasyTube – its the way forward –> <div>  <h2>EasyTube Options</h2> <div style=”float: right; width: 300px; padding: 10px; text-align:center; background-color: #FFFFCC; border: 1px solid #000″> <h3 style=”text-align:center”>Like this plugin? <br />Want to make it better?</h3> <p>Then why not show your appreciation by donating to the project?</p> <form action=”https://www.paypal.com/cgi-bin/webscr&#8221; method=”post” style=”text-align: center”> <input type=”hidden” name=”cmd” value=”_s-xclick”><input type=”hidden” name=”hosted_button_id” value=”9469586″><input type=”image” src=”https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif&#8221; border=”0″ name=”submit” alt=”PayPal – The safer, easier way to pay online.”><img alt=”” border=”0″ src=”https://www.paypal.com/en_GB/i/scr/pixel.gif&#8221; width=”1″ height=”1″></form> <p>Thanks for using my plugin!<br />Paul</p> </div> <?if(!$global){ ?> <div > <b style=”color: red”>Warning!</b><br />The following options will not take effect if the global checkbox is not checked. </div> <?} ?> <form action=”?page=easytube” method=”POST”> <input type=”hidden” name=”action” value=”save”/> <p><input name=”Submit” value=”Update Options &raquo;” type=”submit”></p> <table> <tr> <th scope=”row”> <b>Enable Global Options</b> </th> <td> <input type=”checkbox” name=”easytube_global” <?if($global){echo”checked=\”yes\””;}?> value=”1″ /> </td> </tr> <tr> <th scope=”row”> Video Dimension </th> <td> <select name=”easytube_size”> <?foreach($tube_sizes as $key=>$s){ ?> <option value=”<?=$key ?>” <?if($key == $size){ echo „selected=\”selected\””;} ?>><?=$s[‘name’]; ?></option> <? } ?> </select> </td> </tr> <tr> <th scope=”row”> Enable Relevant Videos </th> <td> <input type=”checkbox” name=”easytube_rel” <?if($rel){echo”checked=\”yes\””;}?> value=”1″ /> </td> </tr> <tr> <th scope=”row”> Autoplay Videos </th> <td> <input type=”checkbox” name=”easytube_auto” <?if($auto){echo”checked=\”yes\””;}?> value=”1″ /> </td> </tr> <tr> <th scope=”row”> Enable Embed Border </th> <td> <input type=”checkbox” name=”easytube_border” <?if($border){echo”checked=\”yes\””;}?> value=”1″ /> </td> </tr> <tr> <th scope=”row”> Border Style: </th> <td> </td> </tr> <? foreach($tube_colors as $key=>$c){?> <tr> <th scope=”row”> </th> <td> <INPUT TYPE=RADIO NAME=”easytube_color” VALUE=”<?=$key ?>” style=”float: left;” <?if($color == $key) echo „CHECKED”; ?>><div style=”float: left;border: 1px solid #<?=$c[‘a’]; ?>;height: 20px; width: 40px;”><div style=”float:left;width: 20px; height: 20px; background-color: #<?=$c[‘a’] ?>;”></div><div style=”float:left;width: 20px; height: 20px; background-color: #<?=$c[‘b’] ?>;”></div></div> </td> </tr> <?} ?> </table> <p><input name=”Submit” value=”Update Options &raquo;” type=”submit”></p> </form></div><? }
/* * Install EasyTube options. We like options, they give us variety in life. */function tube_install(){  add_option(‘easytube_global’, 0, „Use global settings for easytube”); add_option(‘easytube_size’, 1, „Defines video size”); add_option(‘easytube_color’, 1, „Defines border color”); add_option(‘easytube_border’, 0, „Defines if we use a border”); add_option(‘easytube_rel’, 0, „Show relevant videos”); add_option(‘easytube_auto’, 0, „Autoplay videos”);}

add_filter(‘the_content’,’tube_content’);add_filter(‘the_content’,’googlevideo_content’);add_filter(‘the_excerpt’,’tube_content’);add_filter(‘the_excerpt’,’googlevideo_content’);add_action(‘admin_menu’, ‘tube_add_admin’);
register_activation_hook(__FILE__,”tube_install”);
?>

Lasă un răspuns

Completează mai jos detaliile despre tine sau dă clic pe un icon pentru autentificare:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s