Social Sharing Toolkit - Version 1.3.0

Version Description

Please update to version 1.3.0 for several bug fixes and enhancements.

Download this release

Release Info

Developer MarijnRongen
Plugin Icon wp plugin Social Sharing Toolkit
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.5 to 1.3.0

Files changed (4) hide show
  1. readme.txt +20 -5
  2. screenshot-1.png +0 -0
  3. social_sharing_toolkit.php +52 -23
  4. style.css +33 -20
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Social Sharing Toolkit ===
2
  Contributors: MarijnRongen
3
  Donate link: http://www.marijnrongen.com/wordpress-plugins/
4
- Tags: Facebook, Like, LinkedIn, Share, Google, Plus, +1, Twitter, Tweet, StumbleUpon, Stumble, Tumblr, Digg, Reddit, MySpace, Hyves, recommend, social, sharing, widget
5
  Requires at least: 3.0
6
  Tested up to: 3.2.1
7
- Stable tag: 1.2.5
8
  License: GPLv2 or later
9
 
10
  This plugin enables sharing of your content via popular social networks and can convert Twitter names and hashtags to links. Easy & configurable.
@@ -41,13 +41,17 @@ You can however choose a different button layout for the widget. For example you
41
 
42
  The plugin uses a list to position the buttons. You can easily change the css to match your blog style by changing the css file in the plugin directory.
43
 
 
 
 
 
44
  = Using it somewhere else =
45
 
46
  If you want to display the buttons outside of your content you can use the following code where you want the buttons to appear:
47
- `<?php
48
  $social_sharing_toolkit = new MR_Social_Sharing_Toolkit();
49
  echo $social_sharing_toolkit->create_bookmarks();
50
- ?>`
51
 
52
  = Automatic Twitter links =
53
 
@@ -60,13 +64,17 @@ Upload the Social Sharing Toolkit plugin to the wp-content/plugins/ folder on yo
60
 
61
  == Screenshots ==
62
 
63
- 1. Plugin configuration page (before 1.2.5)
64
  2. Without counters (Facebook demands some space)
65
  3. Several wide buttons
66
  4. Several high buttons
67
 
68
  == Upgrade Notice ==
69
 
 
 
 
 
70
  = 1.2.5 =
71
 
72
  Please update to version 1.2.5 for several bug fixes and enhancements.
@@ -80,6 +88,13 @@ Please update to version 1.0.1 to prevent an unexpected printing of the page tit
80
 
81
  == Changelog ==
82
 
 
 
 
 
 
 
 
83
  = 1.2.5 =
84
  * Added title field to widget
85
  * Added field for Twitter handle to attribute tweets to
1
  === Social Sharing Toolkit ===
2
  Contributors: MarijnRongen
3
  Donate link: http://www.marijnrongen.com/wordpress-plugins/
4
+ Tags: Facebook, Like, LinkedIn, Share, Google, Plus, +1, Twitter, Tweet, StumbleUpon, Stumble, Tumblr, Digg, Reddit, MySpace, Hyves, recommend, social, sharing, widget, page, post
5
  Requires at least: 3.0
6
  Tested up to: 3.2.1
7
+ Stable tag: 1.3.0
8
  License: GPLv2 or later
9
 
10
  This plugin enables sharing of your content via popular social networks and can convert Twitter names and hashtags to links. Easy & configurable.
41
 
42
  The plugin uses a list to position the buttons. You can easily change the css to match your blog style by changing the css file in the plugin directory.
43
 
44
+ = Posts, pages or both =
45
+
46
+ Since version 1.3.0 it is possible to choose if the buttons should be displayed on posts, pages or both. The shortcode will work on both regardless of this choice.
47
+
48
  = Using it somewhere else =
49
 
50
  If you want to display the buttons outside of your content you can use the following code where you want the buttons to appear:
51
+ '<?php
52
  $social_sharing_toolkit = new MR_Social_Sharing_Toolkit();
53
  echo $social_sharing_toolkit->create_bookmarks();
54
+ ?>'
55
 
56
  = Automatic Twitter links =
57
 
64
 
65
  == Screenshots ==
66
 
67
+ 1. Plugin configuration page
68
  2. Without counters (Facebook demands some space)
69
  3. Several wide buttons
70
  4. Several high buttons
71
 
72
  == Upgrade Notice ==
73
 
74
+ = 1.3.0 =
75
+
76
+ Please update to version 1.3.0 for several bug fixes and enhancements.
77
+
78
  = 1.2.5 =
79
 
80
  Please update to version 1.2.5 for several bug fixes and enhancements.
88
 
89
  == Changelog ==
90
 
91
+ = 1.3.0 =
92
+ * Added feature to display buttons only on posts, only on pages or on posts and pages
93
+ * Improved hashtag to link conversion
94
+ * Fixed Facebook language to en_US to prevent width issues
95
+ * Fixed excerpt issue
96
+ * Fixed some css issues
97
+
98
  = 1.2.5 =
99
  * Added title field to widget
100
  * Added field for Twitter handle to attribute tweets to
screenshot-1.png CHANGED
Binary file
social_sharing_toolkit.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Social Sharing Toolkit
4
  Plugin URI: http://www.marijnrongen.com/wordpress-plugins/social_sharing_toolkit/
5
  Description: This plugin enables sharing of your content via popular social networks and can also convert Twitter names and hashtags to links. Easy & configurable.
6
- Version: 1.2.5
7
  Author: Marijn Rongen
8
  Author URI: http://www.marijnrongen.com
9
  */
@@ -16,7 +16,7 @@ class MR_Social_Sharing_Toolkit {
16
  }
17
 
18
  function get_options() {
19
- $this->options = array('share' => 1, 'like' => 1, 'tweet' => 1, 'tumblr' => 1, 'stumble' => 1, 'plus' => 1, 'digg' => 1, 'reddit' => 1, 'myspace' => 1, 'hyves' => 1, 'twitter_handle' => '', 'position' => 'none', 'layout' => 'none', 'linkify_content' => 0, 'linkify_comments' => 0, 'twitter_handles' => 0, 'twitter_hashtags' => 0);
20
  foreach ($this->options as $key => $val) {
21
  $this->options[$key] = get_option( $key, $val );
22
  }
@@ -80,6 +80,28 @@ class MR_Social_Sharing_Toolkit {
80
  if ($this->options['position'] == 'shortcode') {
81
  echo '<span class="description"> '.__("Use the shortcode [social_share/] where you want the buttons to appear", 'mr_social_sharing').'</span>';
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  echo '
84
  </td>
85
  </tr>
@@ -205,22 +227,25 @@ class MR_Social_Sharing_Toolkit {
205
  }
206
  if ($this->options['position'] == 'none' || $this->options['position'] == 'shortcode') {
207
  return false;
208
- }
209
  return true;
210
  }
211
 
212
  function create_bookmarks($url = '', $title = '', $layout = '') {
 
 
213
  if ($url == '') {
214
  $url = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
215
  }
216
  $layout = ($layout != '') ? $layout : $this->options['layout'];
217
  $class = 'mr_social_sharing_'.$layout;
218
- $bookmarks = '<ul class="mr_social_sharing">
219
- <!-- Social Sharing Toolkit v1.2.5 | http://www.marijnrongen.com/wordpress-plugins/social_sharing_toolkit/ -->';
 
220
  if ($this->options['like'] == 1) {
221
  $bookmarks .= '
222
  <li class="'.$class.'">
223
- <iframe src="http://www.facebook.com/plugins/like.php?href='.$url.'&amp;layout=';
224
  switch ($layout) {
225
  case 'horizontal':
226
  $bookmarks .= 'button_count';
@@ -331,7 +356,7 @@ class MR_Social_Sharing_Toolkit {
331
  $bookmarks .= '4';
332
  break;
333
  }
334
- $bookmarks .= '&r='.$url.'"></script>
335
  </li>';
336
  }
337
  if ($this->options['digg'] == 1) {
@@ -349,7 +374,7 @@ class MR_Social_Sharing_Toolkit {
349
  $bookmarks .= 'DiggIcon';
350
  break;
351
  }
352
- $bookmarks .= '" href="http://digg.com/submit?url='.$url.'&amp;title='.$title.'"></a>
353
  </li>';
354
  }
355
  if ($this->options['reddit'] == 1) {
@@ -374,7 +399,7 @@ class MR_Social_Sharing_Toolkit {
374
  break;
375
  default:
376
  $bookmarks .= '
377
- <a href="http://www.reddit.com/submit" onclick="window.location = \'http://www.reddit.com/submit?url='.$url.'\'; return false"><img src="http://www.reddit.com/static/spreddit1.gif" alt="submit to reddit" border="0" /></a>';
378
  break;
379
  }
380
  $bookmarks .= '
@@ -383,7 +408,7 @@ class MR_Social_Sharing_Toolkit {
383
  if ($this->options['myspace'] == 1) {
384
  $bookmarks .= '
385
  <li class="'.$class.'">
386
- <a href="javascript:void(window.open(\'http://www.myspace.com/Modules/PostTo/Pages/?u='.$url.'\',\'ptm\',\'height=450,width=550\').focus())">
387
  <img src="http://cms.myspacecdn.com/cms//ShareOnMySpace/Myspace_btn_';
388
  switch ($layout) {
389
  case 'horizontal':
@@ -400,30 +425,34 @@ class MR_Social_Sharing_Toolkit {
400
  if ($this->options['hyves'] == 1) {
401
  $bookmarks .= '
402
  <li class="'.$class.'">
403
- <iframe src="http://www.hyves.nl/respect/button?url='.$url.'&amp;title='.$title.'" style="border: medium none; overflow:hidden; width:150px; height:21px;" scrolling="no" frameborder="0" allowTransparency="true" ></iframe>
404
  </li>';
405
  }
406
  $bookmarks .= '
407
- </ul>';
 
408
  return $bookmarks;
409
  }
410
 
411
  function share($content) {
412
- if ($this->options['position'] == 'top') {
413
- $bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false));
414
- $content = $bookmarks.$content;
415
- }
416
- if ($this->options['position'] == 'bottom') {
417
- $bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false));
418
- $content .= $bookmarks;
 
 
 
419
  }
420
  return $content;
421
  }
422
 
423
  function share_shortcode() {
424
  $bookmarks = '';
425
- if ($this->options['position'] == 'shortcode') {
426
- $bookmarks = $this->create_bookmarks();
427
  }
428
  return $bookmarks;
429
  }
@@ -447,7 +476,7 @@ class MR_Social_Sharing_Toolkit {
447
  $content = preg_replace("/(^|\s)*(@([a-zA-Z0-9-_]{1,15}))(\.*[^|\n|\r|\t|\s|\<|\&]*)/i", "$1<a href=\"http://twitter.com/$3\">$2</a>$4", $content);
448
  }
449
  if ($this->options['twitter_hashtags'] == 1) {
450
- $content = preg_replace("/(^|\s)*((?:(?<!&))#([a-zA-Z0-9]+))([^|\n|\r|\t|\s|\.|\<|\&]*)/i", "$1<a href=\"http://twitter.com/search/$3\">$2</a>$4", $content);
451
  }
452
  return $content;
453
  }
@@ -464,7 +493,7 @@ class MR_Social_Sharing_Toolkit_Widget extends WP_Widget {
464
  $MR_Social_Sharing_Toolkit = new MR_Social_Sharing_Toolkit();
465
  $widget_layout = empty($instance['widget_layout']) ? 'none' : $instance['widget_layout'];
466
  $widget_title = empty($instance['widget_title']) ? '' : $instance['widget_title'];
467
- $bookmarks = $MR_Social_Sharing_Toolkit->create_bookmarks('', '', $widget_layout);
468
  echo $before_widget;
469
  if ($widget_title != '') {
470
  echo $before_title . $widget_title . $after_title;
3
  Plugin Name: Social Sharing Toolkit
4
  Plugin URI: http://www.marijnrongen.com/wordpress-plugins/social_sharing_toolkit/
5
  Description: This plugin enables sharing of your content via popular social networks and can also convert Twitter names and hashtags to links. Easy & configurable.
6
+ Version: 1.3.0
7
  Author: Marijn Rongen
8
  Author URI: http://www.marijnrongen.com
9
  */
16
  }
17
 
18
  function get_options() {
19
+ $this->options = array('share' => 1, 'like' => 1, 'tweet' => 1, 'tumblr' => 1, 'stumble' => 1, 'plus' => 1, 'digg' => 1, 'reddit' => 1, 'myspace' => 1, 'hyves' => 1, 'twitter_handle' => '', 'position' => 'none', 'types' => 'both', 'layout' => 'none', 'linkify_content' => 0, 'linkify_comments' => 0, 'twitter_handles' => 0, 'twitter_hashtags' => 0);
20
  foreach ($this->options as $key => $val) {
21
  $this->options[$key] = get_option( $key, $val );
22
  }
80
  if ($this->options['position'] == 'shortcode') {
81
  echo '<span class="description"> '.__("Use the shortcode [social_share/] where you want the buttons to appear", 'mr_social_sharing').'</span>';
82
  }
83
+ echo '
84
+ </td>
85
+ </tr>
86
+ <tr valign="top">
87
+ <th scope="row">
88
+ <label for="types">Place buttons on</label>
89
+ </th>
90
+ <td>
91
+ <select name="types" id="types">
92
+ <option value="both"';
93
+ if ($this->options['types'] == 'both') { echo ' selected="selected"';}
94
+ echo '>On posts and pages</option>
95
+ <option value="posts"';
96
+ if ($this->options['types'] == 'posts') { echo ' selected="selected"';}
97
+ echo '>Only on posts</option>
98
+ <option value="pages"';
99
+ if ($this->options['types'] == 'pages') { echo ' selected="selected"';}
100
+ echo '>Only on pages</option>
101
+ </select>';
102
+ if ($this->options['position'] == 'shortcode') {
103
+ echo '<span class="description"> '.__("The shortcode [social_share/] can always be used on posts and pages", 'mr_social_sharing').'</span>';
104
+ }
105
  echo '
106
  </td>
107
  </tr>
227
  }
228
  if ($this->options['position'] == 'none' || $this->options['position'] == 'shortcode') {
229
  return false;
230
+ }
231
  return true;
232
  }
233
 
234
  function create_bookmarks($url = '', $title = '', $layout = '') {
235
+ $url = trim($url);
236
+ $title = trim($title);
237
  if ($url == '') {
238
  $url = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
239
  }
240
  $layout = ($layout != '') ? $layout : $this->options['layout'];
241
  $class = 'mr_social_sharing_'.$layout;
242
+ $bookmarks = '<div class="mr_social_sharing">
243
+ <ul class="mr_social_sharing">
244
+ <!-- Social Sharing Toolkit v1.3.0 | http://www.marijnrongen.com/wordpress-plugins/social_sharing_toolkit/ -->';
245
  if ($this->options['like'] == 1) {
246
  $bookmarks .= '
247
  <li class="'.$class.'">
248
+ <iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&amp;href='.urlencode($url).'&amp;layout=';
249
  switch ($layout) {
250
  case 'horizontal':
251
  $bookmarks .= 'button_count';
356
  $bookmarks .= '4';
357
  break;
358
  }
359
+ $bookmarks .= '&amp;r='.urlencode($url).'"></script>
360
  </li>';
361
  }
362
  if ($this->options['digg'] == 1) {
374
  $bookmarks .= 'DiggIcon';
375
  break;
376
  }
377
+ $bookmarks .= '" href="http://digg.com/submit?url='.urlencode($url).'&amp;title='.urlencode($title).'"></a>
378
  </li>';
379
  }
380
  if ($this->options['reddit'] == 1) {
399
  break;
400
  default:
401
  $bookmarks .= '
402
+ <a href="http://www.reddit.com/submit" onclick="window.location = \'http://www.reddit.com/submit?url='.urlencode($url).'\'; return false"><img src="http://www.reddit.com/static/spreddit1.gif" alt="submit to reddit" border="0" /></a>';
403
  break;
404
  }
405
  $bookmarks .= '
408
  if ($this->options['myspace'] == 1) {
409
  $bookmarks .= '
410
  <li class="'.$class.'">
411
+ <a href="javascript:void(window.open(\'http://www.myspace.com/Modules/PostTo/Pages/?u='.urlencode($url).'\',\'ptm\',\'height=450,width=550\').focus())">
412
  <img src="http://cms.myspacecdn.com/cms//ShareOnMySpace/Myspace_btn_';
413
  switch ($layout) {
414
  case 'horizontal':
425
  if ($this->options['hyves'] == 1) {
426
  $bookmarks .= '
427
  <li class="'.$class.'">
428
+ <iframe src="http://www.hyves.nl/respect/button?url='.urlencode($url).'&amp;title='.urlencode($title).'" style="border: medium none; overflow:hidden; width:150px; height:21px;" scrolling="no" frameborder="0" allowTransparency="true" ></iframe>
429
  </li>';
430
  }
431
  $bookmarks .= '
432
+ </ul>
433
+ </div>';
434
  return $bookmarks;
435
  }
436
 
437
  function share($content) {
438
+ $type = get_post_type().'s';
439
+ if (($this->options['types'] == $type || $this->options['types'] == 'both') && ($type != 'pages' && is_single() || $type == 'pages' && !is_single())) {
440
+ if ($this->options['position'] == 'top') {
441
+ $bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false));
442
+ $content = $bookmarks.$content;
443
+ }
444
+ if ($this->options['position'] == 'bottom') {
445
+ $bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false));
446
+ $content .= $bookmarks;
447
+ }
448
  }
449
  return $content;
450
  }
451
 
452
  function share_shortcode() {
453
  $bookmarks = '';
454
+ if ($this->options['position'] == 'shortcode' && is_single()) {
455
+ $bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false));
456
  }
457
  return $bookmarks;
458
  }
476
  $content = preg_replace("/(^|\s)*(@([a-zA-Z0-9-_]{1,15}))(\.*[^|\n|\r|\t|\s|\<|\&]*)/i", "$1<a href=\"http://twitter.com/$3\">$2</a>$4", $content);
477
  }
478
  if ($this->options['twitter_hashtags'] == 1) {
479
+ $content = preg_replace("/(^|\s)*((?:(?<!&))#([a-zA-Z0-9]+^[-|;]))([^|\n|\r|\t|\s|\.|\<|\&]*)/i", "$1<a href=\"http://twitter.com/search/$3\">$2</a>$4", $content);
480
  }
481
  return $content;
482
  }
493
  $MR_Social_Sharing_Toolkit = new MR_Social_Sharing_Toolkit();
494
  $widget_layout = empty($instance['widget_layout']) ? 'none' : $instance['widget_layout'];
495
  $widget_title = empty($instance['widget_title']) ? '' : $instance['widget_title'];
496
+ $bookmarks = $MR_Social_Sharing_Toolkit->create_bookmarks('', wp_title('', false), $widget_layout);
497
  echo $before_widget;
498
  if ($widget_title != '') {
499
  echo $before_title . $widget_title . $after_title;
style.css CHANGED
@@ -1,50 +1,63 @@
1
- ul.mr_social_sharing, ul.mr_social_sharing_widget {
2
- list-style-type: none;
 
 
 
 
 
 
 
 
 
3
  float: left;
4
  clear: both;
5
  display: block;
6
  width: 100%;
7
- margin: 0;
8
- padding: 0;
9
- border: 0;
 
 
10
  }
11
 
12
  li.mr_social_sharing_none, li.mr_social_sharing_widget_none {
 
13
  float: left;
14
  width: auto;
15
  height: 24px;
16
- margin: 0;
17
- padding: 4px;
18
- border: 0;
19
  }
20
 
21
  li.mr_social_sharing_horizontal, li.mr_social_sharing_widget_horizontal {
 
22
  float: left;
23
  width: 150px;
24
  height: 24px;
25
- margin: 0;
26
- padding: 0;
27
- text-align: left;
28
- border: 0;
29
  }
30
 
31
  li.mr_social_sharing_vertical, li.mr_social_sharing_widget_vertical {
 
32
  float: left;
33
  width: 64px;
34
  height: 70px;
35
- margin: 0;
36
- padding: 0;
37
  text-align: center;
38
- border: 0;
 
 
39
  }
40
 
41
  li.mr_social_sharing_none img, li.mr_social_sharing_horizontal img, li.mr_social_sharing_vertical img, li.mr_social_sharing_widget_none img, li.mr_social_sharing_widget_horizontal img, li.mr_social_sharing_widget_vertical img {
42
- margin: 0;
43
- padding: 0;
44
- border: 0;
45
  }
46
 
47
- li.mr_social_sharing_none a, li.mr_social_sharing_horizontal a, li.mr_social_sharing_vertical a, li.mr_social_sharing_widget_none a, li.mr_social_sharing_widget_horizontal a, li.mr_social_sharing_widget_vertical a {
48
  background: none;
49
- border: 0;
50
  }
1
+ div.mr_social_sharing, div.mr_social_sharing {
2
+ height: auto;
3
+ width: 100%;
4
+ overflow: hidden;
5
+ margin: 0 !important;
6
+ padding: 0 !important;
7
+ border: 0 !important;
8
+ }
9
+
10
+ ul.mr_social_sharing, ul.mr_social_sharing {
11
+ list-style-type: none !important;
12
  float: left;
13
  clear: both;
14
  display: block;
15
  width: 100%;
16
+ height: auto;
17
+ text-align: left;
18
+ margin: 0 !important;
19
+ padding: 0 !important;
20
+ border: 0 !important;
21
  }
22
 
23
  li.mr_social_sharing_none, li.mr_social_sharing_widget_none {
24
+ list-style-type: none !important;
25
  float: left;
26
  width: auto;
27
  height: 24px;
28
+ margin: 0 !important;
29
+ padding: 4px !important;
30
+ border: 0 !important;
31
  }
32
 
33
  li.mr_social_sharing_horizontal, li.mr_social_sharing_widget_horizontal {
34
+ list-style-type: none !important;
35
  float: left;
36
  width: 150px;
37
  height: 24px;
38
+ margin: 0 !important;
39
+ padding: 0 !important;
40
+ border: 0 !important;
 
41
  }
42
 
43
  li.mr_social_sharing_vertical, li.mr_social_sharing_widget_vertical {
44
+ list-style-type: none !important;
45
  float: left;
46
  width: 64px;
47
  height: 70px;
 
 
48
  text-align: center;
49
+ margin: 0 !important;
50
+ padding: 0 !important;
51
+ border: 0 !important;
52
  }
53
 
54
  li.mr_social_sharing_none img, li.mr_social_sharing_horizontal img, li.mr_social_sharing_vertical img, li.mr_social_sharing_widget_none img, li.mr_social_sharing_widget_horizontal img, li.mr_social_sharing_widget_vertical img {
55
+ margin: 0 !important;
56
+ padding: 0 !important;
57
+ border: 0 !important;
58
  }
59
 
60
+ li.mr_social_sharing_none a, li.mr_social_sharing_horizontal a, li.mr_social_sharing_vertical a, li.mr_social_sharing_widget_none a, li.mr_social_sharing_widget_horizontal a, li.mr_social_sharing_widget_vertical a, li.mr_social_sharing_none a:HOVER, li.mr_social_sharing_horizontal a:HOVER, li.mr_social_sharing_vertical a:HOVER, li.mr_social_sharing_widget_none a:HOVER, li.mr_social_sharing_widget_horizontal a:HOVER, li.mr_social_sharing_widget_vertical a:HOVER {
61
  background: none;
62
+ border: 0 !important;
63
  }