Guest User

simple-social.php

a guest
Feb 14th, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.62 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Simple Social - Sharing Widgets & Icons Updated
  4. Version: 0.3.6
  5. Description: Adds a set of social sharing widgets & icons after each post.
  6. Plugin URI: http://wordpress.org/extend/plugins/simple-social-sharing-widgets-icons-updated-updated/
  7. */
  8.  
  9. function simple_social($content) {
  10.     global $post, $simplesocial_icons_pixels;
  11.  
  12.     $simplesocial_permlink = get_permalink($post->ID);
  13.     $simplesocial_enclink = urlencode($simplesocial_permlink);
  14.     $simplesocial_title = get_the_title($post->ID);
  15.     $simplesocial_title_4url = urlencode($simplesocial_title);
  16.     $simplesocial_dir = get_option('home').'/wp-content/plugins/simple-social-sharing-widgets-icons-updated/icons_'.get_option('ss_iconsize',32).'/';
  17.     $simplesocialcontent = '';
  18.  
  19.     if (!is_feed() && !is_page() && is_single()) {
  20.         $simplesocialcontent .= '<div class="simplesocial-box">';
  21.  
  22.         // Title
  23.         $simplesocialcontent .= '<div class="simplesocial-title" style="padding-top:10px;margin-bottom:10px;font-size:10pt;font-family:arial;font-weight:bold;">'.get_option('ss_title','Did you like this? Share it:').'</div>';
  24.        
  25.         // LinkedIn widget
  26.         if (get_option('ss_linkedinwidget','1')) {
  27.             $simplesocialcontent .= '<div class=simplesocial><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="'.$simplesocial_permlink.'" data-counter="right"></script></div>';
  28.         }
  29.  
  30.         // Twitter widget
  31.         if (get_option('ss_twitterwidget','1')) {
  32.             $simplesocialcontent .= '<div class=simplesocial><a href="http://twitter.com/share" data-url="'.$simplesocial_permlink.'" data-text="'.$simplesocial_title.'" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>';
  33.         }
  34.  
  35.         // Google +1 widget
  36.         if (get_option('ss_googlepluswidget','1')) {
  37.             $simplesocialcontent .= '<div class=simplesocial><script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone></g:plusone></div>';
  38.         }
  39.  
  40.         // Facebook widget
  41.         if (get_option('ss_facebookwidget','1')) {
  42.             $simplesocialcontent .= '<div class=simplesocial><iframe src="http://www.facebook.com/plugins/like.php?href='.$simplesocial_enclink.'&layout=standard&show_faces=false&width=350&action=like&colorscheme=light&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:350px; height:25px;" allowTransparency="true"></iframe></div>';
  43.         }
  44.  
  45.         // New Line
  46.         $simplesocialcontent .= '<div style="clear:both"></div>';
  47.  
  48.         // Facebook Button
  49.         if (get_option('ss_facebook','1')) {
  50.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,500,400)" title="Share on Facebook" style="background:url('.$simplesocial_dir.'facebook.png)" href="http://www.facebook.com/share.php?u='.$simplesocial_enclink.'&t='.$simplesocial_title_4url.'"></a>';
  51.         }
  52.  
  53.         // Twitter Button
  54.         if (get_option('ss_twitter','1')) {
  55.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Twitter" style="background:url('.$simplesocial_dir.'twitter.png)" href="http://twitter.com/home?status='.$simplesocial_enclink.'"></a>';
  56.         }
  57.  
  58.         // Email Button
  59.         if (get_option('ss_email','1')) {
  60.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,435,500)" title="Email a Friend" style="background:url('.$simplesocial_dir.'email.png)" href="http://www.freetellafriend.com/tell/?heading=Share+This+Article&bg=1&option=email&url='.$simplesocial_enclink.'"></a>';
  61.         }
  62.  
  63.         // Blogger Button
  64.         if (get_option('ss_blogger','1')) {
  65.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on Blogger" style="background:url('.$simplesocial_dir.'blogger.png)" href="http://www.blogger.com/blog_this.pyra?t&u='.$simplesocial_enclink.'&n='.$simplesocial_title_4url.'&pli=1"></a>';
  66.         }
  67.  
  68.         // Delicious Button
  69.         if (get_option('ss_delicious','1')) {
  70.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,890,550)" title="Share on Delicious" style="background:url('.$simplesocial_dir.'delicious.png)" href="http://del.icio.us/post?url='.$simplesocial_enclink.'&title='.$simplesocial_title_4url.'"></a>';
  71.         }
  72.  
  73.         // Digg Button
  74.         if (get_option('ss_digg','1')) {
  75.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Digg" style="background:url('.$simplesocial_dir.'digg.png)" href="http://digg.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title_4url.'"></a>';
  76.         }
  77.  
  78.         // Google Button
  79.         if (get_option('ss_google','1')) {
  80.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on Google" style="background:url('.$simplesocial_dir.'google.png)" href="http://www.google.com/bookmarks/mark?op=add&bkmk='.$simplesocial_enclink.'&title='.$simplesocial_title_4url.'"></a>';
  81.         }
  82.  
  83.         // Myspace Button
  84.         if (get_option('ss_myspace','1')) {
  85.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Myspace" style="background:url('.$simplesocial_dir.'myspace.png)" href="http://www.myspace.com/Modules/PostTo/Pages/?u='.$simplesocial_enclink.'&t='.$simplesocial_title_4url.'&c='.$simplesocial_enclink.'"></a>';
  86.         }
  87.  
  88.         // StumbleUpon Button
  89.         if (get_option('ss_stumbleupon','1')) {
  90.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on StumbleUpon" style="background:url('.$simplesocial_dir.'stumbleupon.png)" href="http://www.stumbleupon.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title_4url.'"></a>';
  91.         }
  92.  
  93.         // Yahoo Button
  94.         if (get_option('ss_yahoo','1')) {
  95.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,900,550)" title="Share on Yahoo" style="background:url('.$simplesocial_dir.'yahoo.png)" href="http://buzz.yahoo.com/buzz?targetUrl='.$simplesocial_enclink.'&headline='.$simplesocial_title_4url.'"></a>';
  96.         }
  97.  
  98.         // Reddit Button
  99.         if (get_option('ss_reddit','1')) {
  100.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,700,500)" title="Share on Reddit" style="background:url('.$simplesocial_dir.'reddit.png)" href="http://reddit.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title_4url.'"></a>';
  101.         }
  102.  
  103.         // Technorati Button
  104.         if (get_option('ss_technorati','1')) {
  105.             $simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,500)" title="Share on Technorati" style="background:url('.$simplesocial_dir.'technorati.png)" href="http://technorati.com/faves?sub=favthis&add='.$simplesocial_enclink.'"></a>';
  106.         }
  107.  
  108.         // RSS Button
  109.         if (get_option('ss_rss','1')) {
  110.             $simplesocialcontent .= '<a class=simplesocial title="RSS Feed" style="background:url('.$simplesocial_dir.'rss.png)" href="'.get_option('home').'/?feed=rss2"></a>';
  111.         }
  112.  
  113.         // End
  114.         $simplesocialcontent.='<div style="clear:both"></div></div><div class="simplesocial-clear" style="clear:both;margin-bottom:20px"></div>';
  115.     }
  116.  
  117.     return $content.$simplesocialcontent;
  118. }
  119.  
  120.  
  121. function simple_social_css() {
  122.     if (!is_feed() && !is_page() && is_single()) {
  123.         echo '<style type="text/css">div.simplesocial,a.simplesocial{float:left;display:block;clear:both;}a.simplesocial{margin-right:5px;width:'.get_option('ss_iconsize',32).'px;height:'.get_option('ss_iconsize',32).'px; }a.simplesocial:hover{margin-top:-2px}</style>
  124.            <script language="javascript">function simplesocial(t,w,h){
  125.            window.open(t.href, \'simplesocial\', \'scrollbars=1,menubar=0,width=\'+w+\',height=\'+h+\',resizable=1,toolbar=0,location=0,status=0,left=\'+(screen.width-w)/2+\',top=\'+(screen.height-h)/3);
  126.            return false;}</script>' . "\n";
  127.     }
  128. }
  129.  
  130. function simple_social_options(){
  131.     $simple_social_icons = array('linkedinwidget','twitterwidget','facebookwidget','googlepluswidget','facebook','twitter','email','blogger','delicious','digg','google','myspace','stumbleupon','yahoo','reddit','technorati','rss');
  132.     foreach ($simple_social_icons as $item) {
  133.         $simple_social_pageoptions.='ss_'.$item.',';
  134.     }
  135.     echo '<form method="post" action="options.php"><h3>Text shown above icons:</h3><div style="padding:20px;"><input type="text" size=50 name="ss_title" value="'.get_option('ss_title','Did you like this? Share it:').'"></div><h3>Select Icon Size:</h3><div style="padding:20px;">
  136.        <input type="radio" value="16" name="ss_iconsize" id=ss_16 '.(get_option('ss_iconsize',32)==16?'checked':'unchecked').'> <label for=ss_16>Small (16x16)</label>&nbsp;&nbsp;&nbsp;<input type="radio" '.(get_option('ss_iconsize',32)==32?'checked':'unchecked').' id=ss_32 value="32" name="ss_iconsize"> <label for=ss_32>Large (32x32)</label></div>
  137.        <h3>Select icons/widgets to display:</h3><div style="padding:20px;">';
  138.  
  139.     foreach ($simple_social_icons as $item) {
  140.         if($item=='twitterwidget') {
  141.             echo '<div style="margin-bottom:10px;font-weight:bold;font-size:9pt"><input style="margin-right:10px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons-updated/img/twitterwidget.png"></label></div>';
  142.         } else if($item=='facebookwidget') {
  143.             echo '<div style="margin-bottom:10px;font-weight:bold;font-size:9pt"><input style="margin-right:10px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_option('home').'/wp-content/plugins/simple-social-sharing-widgets-icons-updated/img/facebookwidget.png"></label></div>';
  144.         } else if($item=='googlepluswidget') {
  145.             echo '<div style="margin-bottom:10px;font-weight:bold;font-size:9pt"><input style="margin-right:10px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_option('home').'/wp-content/plugins/simple-social-sharing-widgets-icons-updated/img/googlepluswidget.png"></label></div><div style="clear:both"></div>';
  146.         } else if($item=='linkedinwidget') {
  147.             echo '<div style="margin-bottom:10px;font-weight:bold;font-size:9pt"><input style="margin-right:10px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_option('home').'/wp-content/plugins/simple-social-sharing-widgets-icons-updated/img/linkedinwidget.png"></label></div><div style="clear:both"></div>';
  148.         } else{
  149.             echo '<div style="float:left;margin-right:30px;margin-bottom:10px;"><input style="margin-top:-15px;margin-right:5px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_option('home').'/wp-content/plugins/simple-social-sharing-widgets-icons-updated/icons_32/'.$item.'.png"></label></div>';
  150.         }
  151.     }
  152.  
  153.  
  154.     echo '</div><div style="clear:both"></div><p class="submit"><input type="submit" class="button-primary" value="Save Changes"/>';
  155.     wp_nonce_field('update-options');
  156.     echo '<input type="hidden" name="page_options" value="'.$simple_social_pageoptions.'ss_title,ss_iconsize"><input type="hidden" name="action" value="update" /></form>';
  157. }
  158.  
  159.  
  160. add_action('wp_head', 'simple_social_css');
  161. add_filter('the_content', 'simple_social');
  162. add_filter('plugin_action_links', 'simple_social_settinglink', 10, 2);
  163. add_action('admin_menu', 'simple_social_addmenu');
  164.  
  165. function simple_social_addmenu() {
  166.     add_options_page("Simple Social", "Simple Social Icons", "administrator", "simple_social", "simple_social_options");
  167. }
  168.  
  169. function simple_social_settinglink($links,$file) {
  170.     if ($file=='simple-social-sharing-widgets-icons-updated/simple-social.php') {
  171.         array_unshift($links,'<a href="options-general.php?page=simple_social">Settings</a>');
  172.     }
  173.  
  174.     return $links;
  175. }
  176.  
  177. ?>
Add Comment
Please, Sign In to add comment