Advertisement
Guest User

Untitled

a guest
Sep 18th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 39.34 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Tweet, Like, Google +1 and Share
  4. Plugin URI: http://letusbuzz.com/tweet-share-like-plusone
  5. Author: Sudipto Pratap Mahato
  6. Version: 1.5.1
  7. Description: Most simple social share icons. 99% of your any blog post is share by these Social share icons.
  8. Requires at least: 3.0
  9. Tested up to: 3.3.1
  10. */
  11.  
  12. global $s4pexcerpt;
  13. function disp_social($content) {
  14. global $post,$s4pexcerpt;
  15. if (get_option('s4dmob', false )==true && social4i_check_mobile())return $content;
  16. $plink = get_permalink($post->ID);
  17. $eplink = urlencode($plink);
  18. $ptitle = get_the_title($post->ID);
  19. $disps4=0;
  20. $abvcnt=0;
  21. $belcnt=0;
  22. $expostid=str_replace(' ','',get_option('s4excludeid',''));
  23. $expostcat=str_replace(' ','',get_option('s4excludecat',''));
  24. $clang=get_option( 's4fblikelang', 'en_US' );
  25. if($expostid!=''){
  26.     $pids=explode(",",$expostid);
  27.     if (in_array($post->ID, $pids)) {
  28.             return $content;
  29.     }
  30.     $psttype=get_post_type($post->ID);
  31.     if (in_array($psttype, $pids)&&$psttype!==flase) {
  32.             return $content;
  33.     }
  34.     $pstfrmt=get_post_format($post->ID);
  35.     if (in_array($pstfrmt, $pids)&&$pstfrmt!==false) {
  36.             return $content;
  37.     }
  38. }
  39. if($expostcat!=''){
  40.     $pcat=explode(",",$expostcat);
  41.     if (in_category($pcat)) {
  42.             return $content;
  43.     }
  44. }
  45. $twsc='<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>';
  46. $flsc='<script type="text/javascript" src="https://connect.facebook.net/'.$clang.'/all.js#xfbml=1"></script>';
  47. $gpsc='<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>';
  48. $fssc='<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>';
  49. if (get_option( 's4optimize', true ) == true){
  50. $twsc='';
  51. $flsc='';
  52. $gpsc='';
  53. $fssc='';
  54. }
  55. if(is_single()&&get_option( 's4onpost', true ) == true){
  56.     $disps4=1;
  57.     if (get_option( 's4pabovepost', true ) == true)$abvcnt=1;
  58.     if (get_option( 's4pbelowpost', false ) == true)$belcnt=1;
  59. }
  60. if(is_page()&&get_option( 's4onpage', true ) == true){
  61.     $disps4=1;
  62.     if (get_option( 's4pgabovepost', true ) == true)$abvcnt=1;
  63.     if (get_option( 's4pgbelowpost', false ) == true)$belcnt=1;
  64. }
  65. if(is_home()&&get_option( 's4onhome', false ) == true){
  66.     $disps4=1;
  67.     if (get_option( 's4habovepost', true ) == true)$abvcnt=1;
  68.     if (get_option( 's4hbelowpost', false ) == true)$belcnt=1;
  69. }
  70. if((is_archive()||is_search())&&get_option( 's4onarchi', false ) == true){
  71.     $disps4=1;
  72.     if (get_option( 's4aabovepost', true ) == true)$abvcnt=1;
  73.     if (get_option( 's4abelowpost', false ) == true)$belcnt=1;
  74. }
  75.  
  76. if ($disps4==1){
  77.     $size=get_option( 's4iconsize', 'large' );
  78.     $align=get_option( 's4iconalign', 'left' );
  79.     if($align=="left")$align="align-left";
  80.     if($align=="right")$align="align-right";
  81.     if($align=="floatl")$align="float-left";
  82.     if($align=="floatr")$align="float-right";
  83.     $sharelinks=display_social4i($size,$align);
  84.     if ($abvcnt==1)$content=$sharelinks.$content;
  85.     if ($belcnt==1)$content=$content.$sharelinks;
  86. }
  87. return $content;
  88. }
  89. function s4load_script()
  90. {
  91.     $clang=get_option( 's4fblikelang', 'en_US' );
  92.     $flsc='';
  93.     if(get_option('s4nofbjava',false)==false)$flsc='<script type="text/javascript" src="https://connect.facebook.net/'.$clang.'/all.js#xfbml=1"></script>';
  94.     $r='';
  95.     if(get_option('s4allscripts',true)== true){
  96.     $r='<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>'.$flsc.'<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script><script type="text/javascript" src="https://platform.linkedin.com/in.js"></script>';
  97.     }
  98.     else
  99.     {
  100.             if(get_option('s4_twitter','1'))$r.='<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>';
  101.             if(get_option('s4_fblike','1'))$r.=$flsc;
  102.             if(get_option('s4_plusone','1'))$r.='<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>';
  103.             if(get_option('s4_linkedin',false))$r.='<script type="text/javascript" src="https://platform.linkedin.com/in.js"></script>';
  104.             if(get_option('s4_fbshare','1'))$r.='<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>';
  105.            
  106.     }
  107.     return $r;
  108. }
  109.  
  110. function social4i_css() {
  111. echo "<!-- This site is powered by Tweet, Like, Plusone and Share Plugin - http://letusbuzz.com/tweet-share-like-plusone/ -->\n";
  112. s4_fb_share_thumb();
  113. if (get_option('s4dmob', false )==true && social4i_check_mobile())return;
  114. echo '<style type="text/css">div.socialicons{float:left;display:block;margin-right: 10px;}div.socialicons p{margin-bottom: 0px !important;margin-top: 0px !important;padding-bottom: 0px !important;padding-top: 0px !important;}</style>'."\n";
  115. if(get_option('s4optimize',true)==true&&get_option( 's4scripthead', 'head' ) == "head" )
  116. echo s4load_script();
  117. $ccss=get_option('s4ccss','');
  118. if(trim($ccss!=''))echo '<style type="text/css">'.$ccss.'</style>';
  119.  
  120. }
  121. function social4i_foot()
  122. {
  123. if (get_option('s4dmob', false )==true && social4i_check_mobile())return;
  124.     if(get_option('s4optimize',true)==true&&get_option( 's4scripthead', 'head' ) == "foot" )
  125.         echo s4load_script();
  126.  
  127. if(get_option('s4analytics',false)==false)return;      
  128. ?>
  129.     <script src="http://analytics-api-samples.googlecode.com/svn/trunk/src/tracking/javascript/v5/social/ga_social_tracking.js"></script>
  130.     <script>
  131.          _ga.trackSocial();
  132.     </script>
  133.    
  134. <?php
  135. }
  136. function s4_get_first_image() {
  137. global $post, $posts;
  138. $first_img = '';
  139. ob_start();
  140. ob_end_clean();
  141. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  142. $first_img = $matches[1][0];
  143. return $first_img;
  144. }
  145. function s4_fb_share_thumb()
  146. {
  147. global $post, $posts;
  148. if(get_option('s4nometa',false)==true)return;
  149. $thumb = false;
  150. if(function_exists('get_post_thumbnail_id')&&function_exists('wp_get_attachment_image_src'))
  151. {
  152.     $image_id = get_post_thumbnail_id();
  153.     $image_url = wp_get_attachment_image_src($image_id,'large');
  154.     $thumb = $image_url[0];
  155. }
  156. if($thumb=='')$thumb=s4_get_first_image();
  157. $default_img = get_option('s4defthumb','');
  158. if ( $thumb == false || $thumb=='')
  159.     $thumb=$default_img;
  160.  
  161. if(is_single() || is_page()) {
  162. $desc = "";
  163. if (has_excerpt($post->ID)) {
  164.     $desc = esc_attr(strip_tags(get_the_excerpt($post->ID)));
  165. }else{
  166.     $desc = esc_attr(str_replace("\r\n",' ',substr(strip_tags(strip_shortcodes($post->post_content)), 0, 160)));
  167. }
  168. ?>
  169.     <meta property="og:type" content="article" />
  170.     <meta property="og:title" content="<?php single_post_title(''); ?>" />
  171.     <meta property="og:url" content="<?php the_permalink(); ?>"/>
  172.     <meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
  173.     <meta property="og:description" content="<?php echo $desc; ?> "/>
  174.     <?php if(trim($thumb)!=''){ ?>
  175.         <meta property="og:image" content="<?php echo $thumb; ?>" />
  176.     <?php } ?>
  177. <?php  } else { ?>
  178.     <meta property="og:type" content="article" />
  179.     <meta property="og:title" content="<?php bloginfo('name'); ?>" />
  180.     <meta property="og:url" content="<?php bloginfo('url'); ?>"/>
  181.     <meta property="og:description" content="<?php bloginfo('description'); ?>" />
  182.     <meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
  183.     <?php if(trim($default_img)!=''){ ?>
  184.         <meta property="og:image" content="<?php echo $default_img; ?>" />
  185.     <?php } ?>
  186. <?php  }
  187.  
  188. }
  189.  
  190. function disp_social_on_optionpage()
  191. {
  192. $fblplink = "http://wordpress.org/extend/plugins/only-tweet-like-share-and-google-1/";
  193. $plink = "http://letusbuzz.com/tweet-share-like-plusone/";
  194. $eplink = urlencode($plink);
  195. $ptitle = "Check out this cool Social Share Plugin for Wordpress";
  196. $sharelinks='<div id="social4i" style="position: relative; display: block;">';
  197. $clang=get_option( 's4fblikelang', 'en_US' );
  198. if(get_option('s4_twitter','1')){
  199. if (get_option( 's4iconsize', 'large' ) == "large" )$tp="vertical"; else $tp="horizontal";
  200. $sharelinks.= '<div class=socialicons style="float:left;margin-right: 10px;"><a href="https://twitter.com/share" data-url="'.$plink.'" data-counturl="'.$plink.'" data-text="'.$ptitle.'" class="twitter-share-button" data-count="'.$tp.'">Tweet</a><script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script></div>';
  201. }
  202. if(get_option('s4_fblike','1')){
  203. if(get_option('s4_fbsend',false)==true)$snd="true"; else $snd="false";
  204. if (get_option( 's4iconsize', 'large' ) == "large" )
  205.     $tp=' layout="box_count" width="55" height="62" ';
  206. else
  207.     $tp=' layout="button_count" width="100" height="21" ';
  208.    
  209. $sharelinks.= '<div class=socialicons style="float:left;margin-right: 10px;"><div id="fb-root"></div><script src="https://connect.facebook.net/'.$clang.'/all.js#xfbml=1"></script><fb:like href="'.$fblplink.'" send="'.$snd.'"'.$tp.'show_faces="false" font=""></fb:like></div>';
  210. }
  211. if(get_option('s4_plusone','1')){
  212. if (get_option( 's4iconsize', 'large' ) == "large" )$tp="tall"; else $tp="medium";
  213. $sharelinks.='<div class="socialicons" style="float:left;margin-right: 10px;"><script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="'.$tp.'" href="'.$fblplink.'" count="true"></g:plusone></div>';
  214. }
  215. if(get_option( 's4_linkedin', false )){
  216. if (get_option( 's4iconsize', 'large' ) == "large" )$tp="top"; else $tp="right";
  217. $sharelinks.='<div class="socialicons" style="float:left;margin-right: 10px;"><script type="text/javascript" src="https://platform.linkedin.com/in.js"></script><script type="in/share" data-url="'.$eplink.'" data-counter="'.$tp.'"></script></div>';
  218. }
  219. if(get_option('s4_fbshare','1')){
  220. if (get_option( 's4iconsize', 'large' ) == "large" )
  221. {
  222.     $tp="box_count";
  223.     $cs1="height:60px;";
  224.     $cs2='style="position: absolute; bottom: 0pt;"';
  225. } else $tp="button_count";
  226. $sharelinks.= '<div class=socialicons style="position: relative;'.$cs1.'float:left;margin-right: 10px;"><div '.$cs2.'><a name="fb_share" type="'.$tp.'" share_url="'.$eplink.'" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div></div>';
  227. }
  228. $sharelinks.= '<div style="clear:both"></div></div><div style="float: right; width: 255px; margin-top: -37px; margin-right: 10px;"><b>If you need a Scrolling share plugin then try out my other two plugins</b><br/> 1. <a href="http://wordpress.org/extend/plugins/scrolling-social-sharebar/" target="_blank">Scrolling Social Sharebar</a><br/> 2. <a href="http://wordpress.org/extend/plugins/scrolling-twitter-like-google-plusone-linkedin-and-stumbleupon/" target="_blank">Scrolling Twitter Like Google +1</a></div>';
  229. echo $sharelinks;
  230. }
  231. function s4_order_check($ord)
  232. {
  233.     $ord=str_replace(' ','',$ord);
  234.     $orddefa= array(1,2,3,4,5,6);
  235.     $ordarr=array_unique(explode(",",$ord));
  236.     if(!is_array($ordarr))$ordarr=$orddefa;
  237.     foreach($ordarr as $key=>&$value)
  238.     {
  239.             if($value!=1&&$value!=2&&$value!=3&&$value!=4&&$value!=5&&$value!=6)
  240.             {
  241.               unset($ordarr[$key]);
  242.             }
  243.         }
  244.         $ordarr=array_unique(array_merge($ordarr, $orddefa));
  245.     $ord=implode(",",$ordarr);
  246. return $ord;
  247. }
  248. function social4ioptions(){
  249. ?>
  250. <h2>Tweet, Like, Share and Google +1 Option Page</h2>
  251. Like this Plugin then why not hit the like button. Your like will motivate me to enhance the features of the Plugin :)<br />
  252. <iframe style="overflow: hidden; width: 450px; height: 35px;" src="http://www.facebook.com/plugins/like.php?app_id=199883273397074&amp;href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FTech-XT%2F223482634358279&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=35" frameborder="0" scrolling="no" width="320" height="35"></iframe><br />And if you are too generous then you can always <b>DONATE</b> by clicking the donation button.<br/>If you like the plugin then <b>write a review</b> of it pointing out the plus and minus points.<br /><a href="http://letusbuzz.com/tweet-share-like-plusone" TARGET='_blank'>Click here</a> for <b>Reference on using shortcode/Function</b> or if you want to <b>report a bug</b>.
  253. <table class="form-ta">
  254. <tr valign="top">
  255. <td width="78%">
  256. <form method="post" action="options.php">
  257. <h3>Test Buttons</h3>
  258. <?php disp_social_on_optionpage(); ?>
  259.  
  260. <h3 style="color: #cc0000;">Increase Page Load Speed</h3>
  261. <p>Note: After using this option if the buttons do not get displayed properly then uncheck it</p>
  262. <p><input type="checkbox" name="s4optimize" id="s4optimize" value="true"<?php if (get_option( 's4optimize', true ) == true) echo ' checked'; ?>>Optimize the script for faster loading</p>
  263.  
  264. &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="s4scripthead" value="head" id="s4scripthead1"<?php if (get_option( 's4scripthead', 'head' ) == "head" ) echo ' checked'; ?>></input><label for="s4scripthead">Place Script in the Header&nbsp;&nbsp;&nbsp;&nbsp;</label>
  265. <input type="radio" name="s4scripthead" value="foot" id="s4scripthead2"<?php if (get_option( 's4scripthead', 'head' ) == "foot" ) echo ' checked'; ?>></input><label for="s4scripthead">Place Script in the Footer</label>
  266.  
  267. <p>Keep this option checked if you are using Shortcode or PHP function to display the buttons<br/><input type="checkbox" name="s4allscripts" id="s4allscripts" value="true"<?php if (get_option( 's4allscripts', true ) == true) echo ' checked'; ?>>Load all scripts</p>
  268.  
  269. <h3 style="color: #cc0000;">Select Icons to display</h3>
  270. <p><b>1 </b><input type="checkbox" name="s4_twitter" id="s4-twitter" value="true"<?php if (get_option( 's4_twitter', true ) == true) echo ' checked'; ?>> Display Twitter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;via @<input type="text" name="s4twtvia" style="width: 150px;" value="<?php echo get_option('s4twtvia',''); ?>" /></p>
  271. <p><b>2 </b><input type="checkbox" name="s4_fblike" id="s4-fblike" value="true"<?php if (get_option( 's4_fblike', true ) == true) echo ' checked'; ?>> Display Facebook Like&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="s4_fbsend" id="s4-fbsend" value="true"<?php if (get_option( 's4_fbsend', false ) == true) echo ' checked'; ?>> Display Facebook Send </p>
  272. <p>&nbsp;&nbsp;&nbsp;&nbsp;Select Facebook Like Language <?php s4_lang_disp(); ?> </p>
  273. <p><b>3 </b><input type="checkbox" name="s4_plusone" id="s4-plusone" value="true"<?php if (get_option( 's4_plusone', true ) == true) echo ' checked'; ?>> Display Google +1 </p>
  274. <p><b>4 </b><input type="checkbox" name="s4_fbshare" id="s4-fbshare" value="true"<?php if (get_option( 's4_fbshare', true ) == true) echo ' checked'; ?>> Display Facebook Share </p>
  275. <p><b>5 </b><input type="checkbox" name="s4_linkedin" id="s4_linkedin" value="true"<?php if (get_option( 's4_linkedin', false ) == true) echo ' checked'; ?>> Display Linkedin </p>
  276. <p><b>6 </b><input type="checkbox" name="s4_cbtn" id="s4_cbtn" value="true"<?php if (get_option( 's4_cbtn', false ) == true) echo ' checked'; ?>> Display Custom Buttons </p>
  277. <p><b>Display order</b> <input type="text" name="s4dispord" style="width: 300px;" value="<?php echo s4_order_check(get_option('s4dispord','1,2,3,4,5,6')); ?>" /> <br/>To arrange icons reorder the ID associated with the buttons here separated with comma</p>
  278. <p><b>Default Thumbnail URL</b> <input type="text" name="s4defthumb" style="width: 300px;" value="<?php echo get_option('s4defthumb',''); ?>" /></p>
  279.  
  280. <h3 style="color: #cc0000;">Size of Icons</h3>
  281. <input type="radio" name="s4iconsize" value="large" id="s4iconsize1"<?php if (get_option( 's4iconsize', 'large' ) == "large" ) echo ' checked'; ?>></input><label for="s4iconsize">Large&nbsp;&nbsp;&nbsp;&nbsp;</label>
  282. <input type="radio" name="s4iconsize" value="small" id="s4iconsize2"<?php if (get_option( 's4iconsize', 'large' ) == "small" ) echo ' checked'; ?>></input><label for="s4iconsize">Small</label>
  283.  
  284. <h3 style="color: #cc0000;">Alignment</h3>
  285. <input type="radio" name="s4iconalign" value="left" id="s4iconalign1"<?php if (get_option( 's4iconalign', 'left' ) == "left" ) echo ' checked'; ?>></input><label for="s4iconsize">Left Aligned&nbsp;&nbsp;&nbsp;&nbsp;</label>
  286. <input type="radio" name="s4iconalign" value="right" id="s4iconalign2"<?php if (get_option( 's4iconalign', 'left' ) == "right" ) echo ' checked'; ?>></input><label for="s4iconsize">Right Aligned&nbsp;&nbsp;&nbsp;&nbsp;</label>
  287. <input type="radio" name="s4iconalign" value="floatl" id="s4iconalign3"<?php if (get_option( 's4iconalign', 'left' ) == "floatl" ) echo ' checked'; ?>></input><label for="s4iconsize">Float Left&nbsp;&nbsp;&nbsp;&nbsp;</label>
  288. <input type="radio" name="s4iconalign" value="floatr" id="s4iconalign3"<?php if (get_option( 's4iconalign', 'left' ) == "floatr" ) echo ' checked'; ?>></input><label for="s4iconsize">Float Right&nbsp;&nbsp;&nbsp;&nbsp;</label>
  289.        
  290. <h3 style="color: #cc0000;">Where to Display</h3>
  291. <p><input type="checkbox" name="s4onpost" id="s4onpost" value="true"<?php if (get_option( 's4onpost', true ) == true) echo ' checked'; ?>> <b>Display on Posts</b> </p>
  292. <div style="margin-left: 30px;">
  293. <p><input type="checkbox" name="s4pabovepost" id="s4abovepost" value="true"<?php if (get_option( 's4pabovepost', true ) == true) echo ' checked'; ?>> Display Above Content </p>
  294. <p><input type="checkbox" name="s4pbelowpost" id="s4belowpost" value="true"<?php if (get_option( 's4pbelowpost', false ) == true) echo ' checked'; ?>>Display Below Content</p>
  295. </div>
  296. <p><input type="checkbox" name="s4onpage" id="s4onpage" value="true"<?php if (get_option( 's4onpage', true ) == true) echo ' checked'; ?>><b>Display on Pages</b></p>
  297. <div style="margin-left: 30px;">
  298. <p><input type="checkbox" name="s4pgabovepost" id="s4abovepost" value="true"<?php if (get_option( 's4pgabovepost', true ) == true) echo ' checked'; ?>> Display Above Content </p>
  299. <p><input type="checkbox" name="s4pgbelowpost" id="s4belowpost" value="true"<?php if (get_option( 's4pgbelowpost', false ) == true) echo ' checked'; ?>>Display Below Content</p>
  300. </div>
  301. <p><input type="checkbox" name="s4onhome" id="s4onhome" value="true"<?php if (get_option( 's4onhome', false ) == true) echo ' checked'; ?>><b>Display on Home Page</b> </p>
  302. <div style="margin-left: 30px;">
  303. <p><input type="checkbox" name="s4habovepost" id="s4abovepost" value="true"<?php if (get_option( 's4habovepost', true ) == true) echo ' checked'; ?>> Display Above Content </p>
  304. <p><input type="checkbox" name="s4hbelowpost" id="s4belowpost" value="true"<?php if (get_option( 's4hbelowpost', false ) == true) echo ' checked'; ?>>Display Below Content</p>
  305. </div>
  306. <p><input type="checkbox" name="s4onarchi" id="s4onarchi" value="true"<?php if (get_option( 's4onarchi', false ) == true) echo ' checked'; ?>><b>Display on Archive Pages(Categories, Tages, Author etc.)</b></p>
  307. <div style="margin-left: 30px;">
  308. <p><input type="checkbox" name="s4aabovepost" id="s4abovepost" value="true"<?php if (get_option( 's4aabovepost', true ) == true) echo ' checked'; ?>> Display Above Content </p>
  309. <p><input type="checkbox" name="s4abelowpost" id="s4belowpost" value="true"<?php if (get_option( 's4abelowpost', false ) == true) echo ' checked'; ?>>Display Below Content</p>
  310. </div>
  311. <p><input type="checkbox" name="s4onexcer" id="s4onexcer" value="true"<?php if (get_option( 's4onexcer', true ) == true) echo ' checked'; ?>><b>Display on Excerpts</b></p>
  312. <p><input type="checkbox" name="s4onexcererr" id="s4onexcererr" value="true"<?php if (get_option( 's4onexcererr', false ) == true) echo ' checked'; ?>><b>Rectify display error on Excerpts</b> (check this only if the buttons are not getting displayed properly on excerpts)</p>
  313.  
  314. <h3 style="color: #cc0000;">Mobile browsers</h3>
  315. <p><input type="checkbox" name="s4dmob" id="s4dmob" value="true"<?php if (get_option( 's4dmob', false ) == true) echo ' checked'; ?>><b>Disable on Mobile Browser</b><br /> Check this option if you have installed a mobile theme plugin like Wptouch, WordPress Mobile Pack etc.</p>
  316.  
  317. <h3 style="color: #cc0000;">Don't display on Posts/Pages</h3>
  318. <p>Enter the <b>ID's</b> of those Pages/Posts separated by comma. e.g 13,5,87<br/>You can also include a <b>custom post types</b> or <b>custom post format</b> (all separated by comma)<br />
  319. <input type="text" name="s4excludeid" style="width: 300px;" value="<?php echo get_option('s4excludeid',''); ?>" /></p>
  320.  
  321. <h3 style="color: #cc0000;">Don't display on Category</h3>
  322. <p>Enter the ID's of those Categories separated by comma. e.g 131,45,817<br/>
  323. <input type="text" name="s4excludecat" style="width: 300px;" value="<?php echo get_option('s4excludecat',''); ?>" /></p>
  324.  
  325. <h3 style="color: #cc0000;">Insert Custom CSS</h3>
  326. <small>Your theme should have Call to wp_head() function</small><br />
  327. <p><textarea name="s4ccss" rows="10" cols="50" style="width:600px;"><?php echo stripslashes(htmlspecialchars(get_option('s4ccss',''))); ?></textarea></p>
  328.  
  329. <h3 style="color: #cc0000;">Add your own Custom Buttons</h3>
  330. <table>
  331. <tr><td>
  332. <p>
  333. To add more than one custom button, separate the buttons codes with the word <b>[BUTTON]</b><br />
  334. e.g {code of first button} [BUTTON] {code of second button}
  335. </p>
  336. <p>
  337. Following <b>Tags</b> that will be replace by actual codes when the buttons are displayed<br/>
  338. <b>%%URL%%</b> - The URL of the Post/Page<br/>
  339. <b>%%EURL%%</b> - The HTML encoded URL of the Post/Page<br/>
  340. <b>%%TITLE%%</b> - The Title of the Post/Page<br/>
  341. <b>%%DESC%%</b> - Description or Post Excerpts<br/>
  342. <b>%%PIMAGE%%</b> - Link to the Featured Image of the post or the first image if featured image not set.<br/>
  343.  
  344. </p>
  345. </td></tr>
  346. <tr><td>
  347. Place <b>Large button Code</b> in this box
  348. </td><td>
  349. Place <b>Small button Code</b> in this box
  350. </td></tr>
  351. <tr><td>
  352. <textarea name="s4cblarge" rows="10" cols="50" style="width:350px;"><?php echo stripslashes(htmlspecialchars(get_option('s4cblarge',''))); ?></textarea>
  353. </td><td>
  354. <textarea name="s4cbsmall" rows="10" cols="50" style="width:350px;"><?php echo stripslashes(htmlspecialchars(get_option('s4cbsmall',''))); ?></textarea>
  355. </td></tr>
  356. <tr><td>
  357. If you have successfully added a custom button to your site then please help others by posting the custom code in the <a target="_blank" href="http://techxt.com/plugin-support-forum/tweet-like-plusone-and-share-plugin/">Plugin Forum</a>.
  358. </td></tr>
  359. <tr><td>
  360. <h3 style="color: #cc0000;">Other options</h3>
  361. <p><input type="checkbox" name="s4nometa" id="s4nometa" value="true"<?php if (get_option( 's4nometa', false ) == true) echo ' checked'; ?>><b>Do not add Facebook OG META tags</b><br/>If some other plugin is adding the Facebook Meta tags</p>
  362. <p><input type="checkbox" name="s4nofbjava" id="s4nofbjava" value="true"<?php if (get_option( 's4nofbjava', false ) == true) echo ' checked'; ?>><b>Do not add Facebook Javascript</b><br/>If some other plugin is adding the javascript</p>
  363. <p><input type="checkbox" name="s4analytics" id="s4analytics" value="true"<?php if (get_option( 's4analytics', false ) == true) echo ' checked'; ?>><b>Add Google analytics button Tracking code</b><br/>Adds tracking code to track Facebook Like and Linkedin button clicks (under beta testing)</p>
  364. </td></tr>
  365. </table>
  366.  
  367.  
  368. <div style="clear:both"></div>
  369. <div id="btnsubmit">
  370. <input type="submit" class="button-primary" value="Save Changes"/>
  371. </div>
  372. <style>
  373. div#btnsubmit {
  374.      background: none repeat scroll 0 0 #444444;
  375.     border-radius: 10px 10px 0 0;
  376.     bottom: 0;
  377.     left: 800px;
  378.     padding: 7px 30px;
  379.     position: fixed;
  380.     z-index: 9999;
  381. }
  382. </style>
  383. <?php wp_nonce_field('update-options'); ?>
  384. <input type="hidden" name="page_options" value="s4pabovepost,s4pbelowpost,s4pgabovepost,s4pgbelowpost,s4habovepost,s4hbelowpost,s4aabovepost,s4abelowpost,s4_twitter,s4_fblike,s4_plusone,s4_fbshare,s4onpost,s4onpage,s4onhome,s4onarchi,s4iconsize,s4iconalign,s4excludeid,s4_fbsend,s4optimize,s4twtvia,s4excludecat,s4defthumb,s4onexcer,s4fblikelang,s4ccss,s4_linkedin,s4scripthead,s4allscripts,s4dmob,s4cblarge,s4cbsmall,s4_cbtn,s4dispord,s4onexcererr,s4nofbjava,s4nometa,s4analytics">
  385. <input type="hidden" name="action" value="update" />
  386. </form>
  387. </td><td width="2%">&nbsp;</td><td width="20%"><b>Follow us on</b><br/><a href="http://twitter.com/letusbuzz" target="_blank"><img src="http://a0.twimg.com/a/1303316982/images/twitter_logo_header.png" /></a><br/><a href="http://facebook.com/letusbuzzz" target="_blank"><img src="https://secure-media-sf2p.facebook.com/ads3/creative/pressroom/jpg/b_1234209334_facebook_logo.jpg" height="38px" width="118px"/></a><p></p><b>Feeds and News</b><br /><?php get_feeds_s4() ?>
  388. <p></p>
  389. <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  390. <input type="hidden" name="cmd" value="_donations">
  391. <input type="hidden" name="business" value="isudipto@gmail.com">
  392. <input type="hidden" name="lc" value="US">
  393. <input type="hidden" name="item_name" value="Tweet Like Share Plusone Plugin">
  394. <input type="hidden" name="no_note" value="0">
  395. <input type="hidden" name="currency_code" value="USD">
  396. <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
  397. <input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
  398. <img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/scr/pixel.gif" width="1" height="1">
  399. </form>
  400. <br />Consider a Donation and remember $X is always better than $0
  401. </td></tr></table>
  402. <?php
  403. }
  404.  
  405. add_action('wp_footer', 'social4i_foot');
  406. add_action('wp_head', 'social4i_css');
  407. add_filter('the_content', 'disp_social',1);
  408. if (get_option( 's4onexcer', true ) == true)
  409.     add_filter('the_excerpt', 'disp_social');
  410. if (get_option( 's4onexcererr', false ) == true)
  411.     add_filter('wp_trim_excerpt', 's4_wp_trim_excerpt');
  412. add_action('admin_menu', 'socialicons_addmenu');
  413. add_filter( 'wp_dashboard_widgets', 's4_widget_order');
  414. function social4i_admin_widget(){
  415.     get_feeds_s4_dash();
  416. }
  417. function social4i_add_admin_widget(){
  418.     wp_add_dashboard_widget('social4i_admin_widget', 'News and Updates', 'social4i_admin_widget');
  419. }
  420. add_action('wp_dashboard_setup','social4i_add_admin_widget',5);
  421.  
  422. function s4_wp_trim_excerpt($content, $text = '')
  423. {
  424.  
  425.  
  426.     $raw_excerpt = $text;
  427.     if ( '' == $text ) {
  428.  
  429.         $text = get_the_content('');
  430.         $text = strip_shortcodes( $text );
  431.  
  432.         remove_filter('the_content', 'disp_social', 1);
  433.        
  434.         $text = apply_filters('the_content', $text);
  435.  
  436.         add_filter('the_content', 'disp_social', 1);
  437.  
  438.         $text = str_replace(']]>', ']]&gt;', $text);
  439.         $text = strip_tags($text);
  440.         $excerpt_length = apply_filters('excerpt_length', 55);
  441.         $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
  442.         $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
  443.         if ( count($words) > $excerpt_length ) {
  444.             array_pop($words);
  445.             $text = implode(' ', $words);
  446.             $text = $text . $excerpt_more;
  447.         } else {
  448.             $text = implode(' ', $words);
  449.         }
  450.          return $text;
  451.     }
  452.     else
  453.     {
  454.         return $content;
  455.     }
  456. }
  457. //original code by Yoast.com
  458. function s4_widget_order( $arr ) {
  459.     global $wp_meta_boxes;
  460.    
  461.     if ( is_admin() ) {
  462.         if ( isset($wp_meta_boxes['dashboard']['normal']['core']['social4i_admin_widget']) ) {
  463.             $social4i_admin_widget = $wp_meta_boxes['dashboard']['normal']['core']['social4i_admin_widget'];
  464.             unset($wp_meta_boxes['dashboard']['normal']['core']['social4i_admin_widget']);
  465.             if ( isset($wp_meta_boxes['dashboard']['side']['core']) ) {
  466.                 $begin = array_slice($wp_meta_boxes['dashboard']['side']['core'], 0, 1);
  467.                 $end = array_slice($wp_meta_boxes['dashboard']['side']['core'], 1, 5);
  468.                 $wp_meta_boxes['dashboard']['side']['core'] = $begin;
  469.                 $wp_meta_boxes['dashboard']['side']['core'][] = $social4i_admin_widget;
  470.                 $wp_meta_boxes['dashboard']['side']['core'] += $end;
  471.             } else {
  472.                 $wp_meta_boxes['dashboard']['side']['core'] = array();
  473.                 $wp_meta_boxes['dashboard']['side']['core'][] = $social4i_admin_widget;
  474.             }
  475.         }
  476.     }
  477. return $arr;
  478. }
  479. function get_feeds_s4() {
  480.     include_once(ABSPATH . WPINC . '/feed.php');
  481.     $rss = fetch_feed('http://feeds.feedburner.com/letusbuzz');
  482.     if (!is_wp_error( $rss ) ){
  483.         $rss5 = $rss->get_item_quantity(5);
  484.         $rss1 = $rss->get_items(0, $rss5);
  485.     }
  486. ?>
  487. <ul>
  488. <?php if (!$rss5 == 0)foreach ( $rss1 as $item ){?>
  489. <li style="list-style-type:circle">
  490. <a target="_blank" href='<?php echo $item->get_permalink(); ?>'><?php echo $item->get_title(); ?></a>
  491. </li>
  492. <?php } ?>
  493. </ul>
  494. <?php
  495. }
  496. function get_feeds_s4_dash() {
  497.     include_once(ABSPATH . WPINC . '/feed.php');
  498.     $rss = fetch_feed('http://feeds.feedburner.com/techxtrack');
  499.     if (!is_wp_error( $rss ) ){
  500.         $rss5 = $rss->get_item_quantity(5);
  501.         $rss1 = $rss->get_items(0, $rss5);
  502.     }
  503. ?>
  504. <ol>
  505. <?php if (!$rss5 == 0)foreach ( $rss1 as $item ){?>
  506. <li>
  507. <a target="_blank" href='<?php echo $item->get_permalink(); ?>'><?php echo $item->get_title(); ?></a>
  508. </li>
  509. <?php } ?>
  510. </ol>
  511. <?php
  512. }
  513. function socialicons_addmenu(){
  514.     add_options_page("Tweet Like Share Plusone", "Tweet Like Plusone", "administrator", "social4i", "social4ioptions");
  515. }
  516. //===================================================================================//
  517. function display_social4i($size,$align, $type = FALSE)
  518. {
  519. global $post;
  520. $btnarr=array(1=>'',2=>'',3=>'',4=>'',5=>'',6=>'');
  521. if($size=='')$size="large";
  522. if($align=='')$align="align-left";
  523. $plink = get_permalink($post->ID);
  524. $eplink = urlencode($plink);
  525. $ptitle = get_the_title($post->ID);
  526. $eptitle=str_replace(array(">","<"),"",$ptitle);
  527. $via=get_option('s4twtvia','');
  528. $clang=get_option( 's4fblikelang', 'en_US' );
  529. $twsc='<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>';
  530. $flsc='';
  531. if(get_option('s4nofbjava',false)==false)$flsc='<script type="text/javascript" src="https://connect.facebook.net/'.$clang.'/all.js#xfbml=1"></script>';
  532. $gpsc='<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>';
  533. $fssc='<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>';
  534. $lnsc='<script type="text/javascript" src="https://platform.linkedin.com/in.js"></script>';
  535. if (get_option( 's4optimize', true ) == true){
  536. $twsc='';
  537. $flsc='';
  538. $gpsc='';
  539. $fssc='';
  540. $lnsc='';
  541. }
  542.  
  543. if ($size == "large" ){
  544.     if(get_option('s4_fbsend',false)==true)
  545.         $css1="height:82px;";
  546.     else
  547.         $css1="height:69px;";
  548. }
  549. else $css1="height:29px;";
  550. $css2=$css1;
  551. if ($align == "float-right" ){$css2.="float: right;";$css1.="float: right;";}
  552. if ($align == "float-left" ){$css2.="float: left;";$css1.="float: left;";}
  553. if ($align == "align-left" )$css1.="float: left;";
  554. if ($align == "align-right" )$css1.="float: right;";
  555. $sharelinks='<div class="social4i" style="'.$css2.'"><div class="social4in" style="'.$css1.'">';
  556. if(get_option('s4_twitter','1') && $type === FALSE || $type == "s4_twitter"){
  557. if ($size == "large" )$tp="vertical"; else $tp="horizontal";
  558. $s4link= '<div class="socialicons s4twitter" style="float:left;margin-right: 10px;"><a href="https://twitter.com/share" data-url="'.$plink.'" data-counturl="'.$plink.'" data-text="'.$eptitle.'" class="twitter-share-button" data-count="'.$tp.'" data-via="'.$via.'"></a>'.$twsc.'</div>';
  559. $sharelinks.=$s4link;
  560. $btnarr[1]=$s4link;
  561. }
  562. if(get_option('s4_fblike','1') && $type === FALSE || $type == "s4_fblike" || $type == "s4_fbsend"){
  563. if(get_option('s4_fbsend',false)==true || $type == "s4_fbsend")$snd="true"; else $snd="false";
  564. if ($size == "large" )
  565.     $tp=' layout="box_count" width="55" height="62" ';
  566. else
  567.     $tp=' layout="button_count" width="100" height="21" ';
  568.    
  569. $s4link= '<div class="socialicons s4fblike" style="float:left;margin-right: 10px;"><div id="fb-root"></div>'.$flsc.'<fb:like href="'.$eplink.'" send="'.$snd.'"'.$tp.'show_faces="false" font=""></fb:like></div>';
  570. $sharelinks.=$s4link;
  571. $btnarr[2]=$s4link;
  572. }
  573. if(get_option('s4_plusone','1') && $type === FALSE || $type == "s4_plusone"){
  574. if ($size == "large" )$tp="tall"; else $tp="medium";
  575. $s4link='<div class="socialicons s4plusone" style="float:left;margin-right: 10px;">'.$gpsc.'<g:plusone size="'.$tp.'" href="'.$plink.'" count="true"></g:plusone></div>';
  576. $sharelinks.=$s4link;
  577. $btnarr[3]=$s4link;
  578. }
  579. if(get_option( 's4_linkedin', false )&& $type === FALSE || $type == "s4_linkedin"){
  580. if ($size == "large" )$tp="top"; else $tp="right";
  581. $s4link='<div class="socialicons s4linkedin" style="float:left;margin-right: 10px;">'.$lnsc.'<script type="in/share" data-url="'.$plink.'" data-counter="'.$tp.'"></script></div>';
  582. $sharelinks.=$s4link;
  583. $btnarr[4]=$s4link;
  584. }
  585. if(get_option('s4_fbshare','1') && $type === FALSE || $type == "s4_fbshare"){
  586. if ($size == "large" )
  587. {
  588.     $tp="box_count";
  589.     $cs1="height: 61px;width:61px;background:url(&quot;http://goo.gl/qt6Vu&quot;) no-repeat;";
  590.     $cs2='style="position: absolute; bottom: 0pt;"';
  591. } else $tp="button_count";
  592. $s4link= '<div class="socialicons s4fbshare" style="position: relative;'.$cs1.'float:left;margin-right: 10px;"><div class="s4ifbshare" '.$cs2.'><a name="fb_share" type="'.$tp.'" share_url="'.$eplink.'" href="http://www.facebook.com/sharer.php"></a>'.$fssc.'</div></div>';
  593. $sharelinks.=$s4link;
  594. $btnarr[5]=$s4link;
  595. }
  596. if(get_option('s4_cbtn', false )==true && $type === FALSE)
  597. {
  598.     $s4link=s4_get_custom_button($size);
  599.     $sharelinks.=$s4link;
  600.     $btnarr[6]=$s4link;
  601. }
  602. if($type === FALSE)
  603. {
  604.     $sharelinks='<div class="social4i" style="'.$css2.'"><div class="social4in" style="'.$css1.'">'.s4_arrange_btns($btnarr).'</div><div style="clear:both"></div></div>';
  605. }
  606. else $sharelinks.= '</div><div style="clear:both"></div></div>';
  607.  
  608. return $sharelinks;
  609. }
  610.  
  611. function s4_arrange_btns($btnarr)
  612. {
  613.     if(!is_array($btnarr))return '';
  614.     $ord=s4_order_check(get_option('s4dispord','1,2,3,4,5,6'));
  615.     $btnord=explode(",",$ord);
  616.     $btnarr2=array();
  617.     for($i=0;$i<=5;$i++)
  618.     {
  619.         $btnarr2[]=$btnarr[$btnord[$i]];
  620.     }
  621.     return implode('',$btnarr2);
  622. }
  623. function s4_post_img_link()
  624. {
  625. $thumb = false;
  626. if(function_exists('get_post_thumbnail_id')&&function_exists('wp_get_attachment_image_src'))
  627. {
  628.     $image_id = get_post_thumbnail_id();
  629.     $image_url = wp_get_attachment_image_src($image_id,'large');
  630.     $thumb = $image_url[0];
  631. }
  632. if($thumb=='')$thumb=s4_get_first_image();
  633. $default_img = get_option('s4defthumb','');
  634. if ( $thumb == false || $thumb=='')
  635.     $thumb=$default_img;
  636. return $thumb;
  637. }
  638. function s4_get_custom_button($size)
  639. {
  640.     global $post;
  641.     $plink = get_permalink($post->ID);
  642.     $eplink = urlencode($plink);
  643.     $ptitle = get_the_title($post->ID);
  644.     $pimg = s4_post_img_link();
  645.     $desc = "";
  646.     if (has_excerpt($post->ID)) {
  647.         $desc = esc_attr(strip_tags(get_the_excerpt($post->ID)));
  648.     }else{
  649.         $desc = esc_attr(str_replace("\r\n",' ',substr(strip_tags(strip_shortcodes($post->post_content)), 0, 160)));
  650.     }  
  651.     if($size=='large')$cbtn=get_option('s4cblarge','');
  652.     else $cbtn=get_option('s4cbsmall','');
  653.     if(trim($cbtn==''))return '';
  654.    
  655.     $cbtn=str_replace("%%URL%%", $plink, $cbtn);
  656.     $cbtn=str_replace("%%EURL%%", $eplink, $cbtn);
  657.     $cbtn=str_replace("%%TITLE%%", $ptitle, $cbtn);
  658.     $cbtn=str_replace("%%PIMAGE%%", $pimg, $cbtn);
  659.     $cbtn=str_replace("%%DESC%%", $desc, $cbtn);
  660.        
  661.     $allbtns=explode("[BUTTON]",$cbtn);
  662.     $cnt=1;
  663.     $buttoncode='';
  664.     foreach($allbtns as $btn)
  665.     {
  666.         if(trim($btn==''))continue;
  667.         $buttoncode.='<div class="socialicons s4custombtn-'.$cnt.'" style="float:left;margin-right: 10px;">'.$btn.'</div>';
  668.         $cnt=$cnt+1;
  669.     }
  670.     return $buttoncode;
  671.  
  672. }
  673. //Geilt - Alexander Conroy geilt@esotech.org http://www.esotech.org and http://www.geilt.com
  674. //Added: $type:
  675. //s4_plusone s4_fbshare,s4_fblike, s4_twitter, s4_fbsend
  676. function social4i_shortcode($atts){
  677.     extract(shortcode_atts( array('size' => 'large','align'=>'align-left', 'type' => FALSE), $atts ));
  678.     $ss=display_social4i($size,$align, $type);
  679.     return $ss;
  680. }
  681. add_shortcode( 'social4i', 'social4i_shortcode' );
  682. function s4_lang_disp()
  683. {
  684. $alllang=array("Catalan|ca_ES","Czech|cs_CZ","Welsh|cy_GB","Danish|da_DK","German|de_DE","Basque|eu_ES","English (Pirate)|en_PI","English (Upside Down)|en_UD","Cherokee|ck_US","English (US)|en_US","Spanish|es_LA","Spanish (Chile)|es_CL","Spanish (Colombia)|es_CO","Spanish (Spain)|es_ES","Spanish (Mexico)|es_MX","Spanish (Venezuela)|es_VE","Finnish (test)|fb_FI","Finnish|fi_FI","French (France)|fr_FR","Galician|gl_ES","Hungarian|hu_HU","Italian|it_IT","Japanese|ja_JP","Korean|ko_KR","Norwegian (bokmal)|nb_NO","Norwegian (nynorsk)|nn_NO","Dutch|nl_NL","Polish|pl_PL","Portuguese (Brazil)|pt_BR","Portuguese (Portugal)|pt_PT","Romanian|ro_RO","Russian|ru_RU","Slovak|sk_SK","Slovenian|sl_SI","Swedish|sv_SE","Thai|th_TH","Turkish|tr_TR","Kurdish|ku_TR","Simplified Chinese (China)|zh_CN","Traditional Chinese (Hong Kong)|zh_HK","Traditional Chinese (Taiwan)|zh_TW","Leet Speak|fb_LT","Afrikaans|af_ZA","Albanian|sq_AL","Armenian|hy_AM","Azeri|az_AZ","Belarusian|be_BY","Bengali|bn_IN","Bosnian|bs_BA","Bulgarian|bg_BG","Croatian|hr_HR","Dutch (Belgie)|nl_BE","English (UK)|en_GB","Esperanto|eo_EO","Estonian|et_EE","Faroese|fo_FO","French (Canada)|fr_CA","Georgian|ka_GE","Greek|el_GR","Gujarati|gu_IN","Hindi|hi_IN","Icelandic|is_IS","Indonesian|id_ID","Irish|ga_IE","Javanese|jv_ID","Kannada|kn_IN","Kazakh|kk_KZ","Latin|la_VA","Latvian|lv_LV","Limburgish|li_NL","Lithuanian|lt_LT","Macedonian|mk_MK","Malagasy|mg_MG","Malay|ms_MY","Maltese|mt_MT","Marathi|mr_IN","Mongolian|mn_MN","Nepali|ne_NP","Punjabi|pa_IN","Romansh|rm_CH","Sanskrit|sa_IN","Serbian|sr_RS","Somali|so_SO","Swahili|sw_KE","Filipino|tl_PH","Tamil|ta_IN","Tatar|tt_RU","Telugu|te_IN","Malayalam|ml_IN","Ukrainian|uk_UA","Uzbek|uz_UZ","Vietnamese|vi_VN","Xhosa|xh_ZA","Zulu|zu_ZA","Khmer|km_KH","Tajik|tg_TJ","Arabic|ar_AR","Hebrew|he_IL","Urdu|ur_PK","Persian|fa_IR","Syriac|sy_SY","Yiddish|yi_DE","Guarani|gn_PY","Quechua|qu_PE","Aymara|ay_BO","Northern Sami|se_NO","Pashto|ps_AF","Klingon|tl_ST");
  685. echo '<select name="s4fblikelang">';
  686. $clang=get_option( 's4fblikelang', 'en_US' );
  687. foreach($alllang as $lang)
  688. {
  689.     $l1=explode("|",$lang);
  690.     if($l1[1]==$clang)$l2=' selected="selected"';else $l2='';
  691.     echo '<option value="'.$l1[1].'"'.$l2.'>'.$l1[0].'</option>';
  692. }
  693. echo '</select>';
  694. }
  695. function social4i_check_mobile()
  696. {
  697. //This mobile browser check code is taken from Mobilepress plugin
  698. $ismob=false;
  699. switch(TRUE)
  700. {  
  701.     case (preg_match('/(iphone|ipod)/i', $_SERVER['HTTP_USER_AGENT']) && preg_match('/mobile/i', $_SERVER['HTTP_USER_AGENT'])):
  702.         $ismob="true";
  703.         break;
  704.     case (preg_match('/ipad/i', $_SERVER['HTTP_USER_AGENT']) && preg_match('/mobile/i', $_SERVER['HTTP_USER_AGENT'])):
  705.         $ismob=false;
  706.         break; 
  707.     case (preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])):
  708.         $ismob=true;
  709.         break;
  710.     case (((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'text/vnd.wap.wml') > 0) || (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0)) || ((isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])))):
  711.         $ismob=true;
  712.         break;
  713.     case (in_array(strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,3)),array('lg '=>'lg ','lg-'=>'lg-','lg_'=>'lg_','lge'=>'lge'))):
  714.         $ismob=true;
  715.         break;
  716.     case (in_array(strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4)),array('acs-'=>'acs-','amoi'=>'amoi','doco'=>'doco','eric'=>'eric','huaw'=>'huaw','lct_'=>'lct_','leno'=>'leno','mobi'=>'mobi','mot-'=>'mot-','moto'=>'moto','nec-'=>'nec-','phil'=>'phil','sams'=>'sams','sch-'=>'sch-','shar'=>'shar','sie-'=>'sie-','wap_'=>'wap_','zte-'=>'zte-'))):
  717.         $ismob=true;
  718.         break;
  719.     case (preg_match('/Googlebot-Mobile/i', $_SERVER['HTTP_USER_AGENT']) || preg_match('/YahooSeeker\/M1A1-R2D2/i', $_SERVER['HTTP_USER_AGENT'])):
  720.         $ismob=true;
  721.         break;
  722. }
  723. return $ismob;
  724. }
  725. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement