Social Sharing Toolkit - Version 1.0.0

Version Description

  • First version
Download this release

Release Info

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

Version 1.0.0

readme.txt ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Social Sharing Toolkit ===
2
+ Contributors: MarijnRongen
3
+ Tags: Facebook, Like, LinkedIn, Share, Google, Plus, +1, Twitter, Tweet, StumbleUpon, Stumble, Tumblr, Digg, Reddit, MySpace, Hyves, recommend, social, sharing
4
+ Requires at least: 3.0
5
+ Tested up to: 3.2.1
6
+ Stable tag: 1.0.0
7
+ License: GPLv2 or later
8
+
9
+ This plugin enables sharing of your content via popular social networks and can convert Twitter names and hashtags to links. Easy & configurable.
10
+
11
+ == Description ==
12
+
13
+ The plugin currently supports the following networks:
14
+
15
+ * Facebook
16
+ * Twitter
17
+ * Google +1
18
+ * LinkedIn
19
+ * Tumblr
20
+ * StumbleUpon
21
+ * Digg
22
+ * Reddit
23
+ * MySpace
24
+ * Hyves (a social network especially popular in the Netherlands).
25
+
26
+ You can decide which networks to support on your blog and where the buttons will appear (either above or below the content). You can also choose between different layouts; small without counters, wide with counters or high with counters. Be aware that not every network has a dedicated button for every layout.
27
+
28
+ = Shortcode =
29
+
30
+ It is also possible to only let the buttons appear where you want by using shortcode. To do this you need to set the button position to the shortcode option and use the shortcode [social_share/] in the content where you would like to display the buttons.
31
+
32
+ = Styling =
33
+
34
+ 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.
35
+
36
+ = Automatic Twitter links =
37
+
38
+ This plugin also includes a configurable & improved version of my earlier Automatic Twitter Links plugin. You can decide if you want to convert Twitter names and/or hashtags to links.
39
+ Twitter names will link to their Twitter profile and hashtags will link to the Twitter search page.
40
+
41
+ == Installation ==
42
+
43
+ Upload the Social Sharing Toolkit plugin to your blog, activate it and use the Social Sharing Toolkit page under Settings to configure your toolkit.
44
+
45
+ == Screenshots ==
46
+
47
+ 1. Plugin configuration page
48
+ 2. Without counters (Facebook demands some space)
49
+ 3. Several wide buttons
50
+ 4. Several high buttons
51
+
52
+ == Changelog ==
53
+
54
+ = 1.0.0 =
55
+ * First version
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
social_sharing_toolkit.php ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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.0.0
7
+ Author: Marijn Rongen
8
+ Author URI: http://www.marijnrongen.com
9
+ */
10
+
11
+ class MR_Social_Sharing_Toolkit {
12
+ var $options;
13
+
14
+ function MR_Social_Sharing_Toolkit() {
15
+ $this->get_options();
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, '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
+ }
23
+ return $this->options;
24
+ }
25
+
26
+ /* Admin functions */
27
+
28
+ function save_options($new_options) {
29
+ foreach ($this->options as $key => $val) {
30
+ if (array_key_exists($key, $new_options)) {
31
+ update_option( $key, $new_options[$key] );
32
+ $this->options[$key] = $new_options[$key] ;
33
+ } else {
34
+ update_option( $key, 0 );
35
+ $this->options[$key] = 0;
36
+ }
37
+ }
38
+ }
39
+
40
+ function plugin_menu() {
41
+ add_options_page('Social Sharing', 'Social Sharing Toolkit', 'manage_options', 'mr_social_sharing', array($this, 'plugin_admin_page'));
42
+ }
43
+
44
+ function plugin_admin_page() {
45
+ if (!current_user_can('manage_options')) {
46
+ wp_die( __('You do not have sufficient permissions to access this page.') );
47
+ }
48
+ if( isset($_POST['mr_save_options']) && $_POST['mr_save_options'] == 'Y' ) {
49
+ $this->save_options($_POST);
50
+ echo '
51
+ <div class="updated"><p><strong>'.__('settings saved.', 'mr_social_sharing' ).'</strong></p></div>';
52
+ }
53
+ echo '
54
+ <div class="wrap">
55
+ <form method="post" action="">
56
+ <input type="hidden" name="mr_save_options" value="Y"/>
57
+ <h2>Social Sharing Toolkit</h2>
58
+ <h3>Configure buttons</h3>
59
+ <table class="form-table">
60
+ <tbody>
61
+ <tr valign="top">
62
+ <th scope="row">
63
+ <label for="position">Button location</label>
64
+ </th>
65
+ <td>
66
+ <select name="position" id="position">
67
+ <option value="none"';
68
+ if ($this->options['position'] == 'none') { echo ' selected="selected"';}
69
+ echo '>Do not display social bookmarks</option>
70
+ <option value="top"';
71
+ if ($this->options['position'] == 'top') { echo ' selected="selected"';}
72
+ echo '>Display above content</option>
73
+ <option value="bottom"';
74
+ if ($this->options['position'] == 'bottom') { echo ' selected="selected"';}
75
+ echo '>Display below content</option>
76
+ <option value="shortcode"';
77
+ if ($this->options['position'] == 'shortcode') { echo ' selected="selected"';}
78
+ echo '>Let me decide by using shortcode</option>
79
+ </select>';
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="layout">Choose a layout</label>
89
+ </th>
90
+ <td>
91
+ <select name="layout" id="layout">
92
+ <option value="none"';
93
+ if ($this->options['layout'] == 'none') { echo ' selected="selected"';}
94
+ echo '>Small buttons without counters</option>
95
+ <option value="horizontal"';
96
+ if ($this->options['layout'] == 'horizontal') { echo ' selected="selected"';}
97
+ echo '>Wider buttons with counters</option>
98
+ <option value="vertical"';
99
+ if ($this->options['layout'] == 'vertical') { echo ' selected="selected"';}
100
+ echo '>Higher buttons with counters</option>
101
+ </select>';
102
+ if ($this->options['layout'] != 'none') {
103
+ echo '<span class="description"> '.__("Counters may not be available for every network", 'mr_social_sharing').'</span>';
104
+ }
105
+ echo '
106
+ </td>
107
+ </tr>
108
+ <tr valign="top">
109
+ <th scope="row">
110
+ <label>Select networks to use</label>
111
+ </th>
112
+ <td>
113
+ <label for="like"><input type="checkbox" name="like" id="like"';
114
+ if ($this->options['like'] == 1) { echo ' checked="checked"';}
115
+ echo ' value="1" /> Facebook</label><br/>
116
+ <label for="tweet"><input type="checkbox" name="tweet" id="tweet"';
117
+ if ($this->options['tweet'] == 1) { echo ' checked="checked"';}
118
+ echo ' value="1" /> Twitter</label><br/>
119
+ <label for="plus"><input type="checkbox" name="plus" id="plus"';
120
+ if ($this->options['plus'] == 1) { echo ' checked="checked"';}
121
+ echo ' value="1" /> Google +1</label><br/>
122
+ <label for="share"><input type="checkbox" name="share" id="share"';
123
+ if ($this->options['share'] == 1) { echo ' checked="checked"';}
124
+ echo ' value="1" /> LinkedIn</label><br/>
125
+ <label for="tumblr"><input type="checkbox" name="tumblr" id="tumblr"';
126
+ if ($this->options['tumblr'] == 1) { echo ' checked="checked"';}
127
+ echo ' value="1" /> Tumblr</label><span class="description"> '.__("Only available without counters", 'mr_social_sharing').'</span><br/>
128
+ <label for="stumble"><input type="checkbox" name="stumble" id="stumble"';
129
+ if ($this->options['stumble'] == 1) { echo ' checked="checked"';}
130
+ echo ' value="1" /> StumbleUpon</label><br/>
131
+ <label for="digg"><input type="checkbox" name="digg" id="digg"';
132
+ if ($this->options['digg'] == 1) { echo ' checked="checked"';}
133
+ echo ' value="1" /> Digg</label><br/>
134
+ <label for="reddit"><input type="checkbox" name="reddit" id="reddit"';
135
+ if ($this->options['reddit'] == 1) { echo ' checked="checked"';}
136
+ echo ' value="1" /> Reddit</label><br/>
137
+ <label for="myspace"><input type="checkbox" name="myspace" id="myspace"';
138
+ if ($this->options['myspace'] == 1) { echo ' checked="checked"';}
139
+ echo ' value="1" /> MySpace</label><span class="description"> '.__("Only available without counters", 'mr_social_sharing').'</span><br/>
140
+ <label for="hyves"><input type="checkbox" name="hyves" id="hyves"';
141
+ if ($this->options['hyves'] == 1) { echo ' checked="checked"';}
142
+ echo ' value="1" /> Hyves</label><span class="description"> '.__("Only available with horizontal counters", 'mr_social_sharing').'</span>
143
+ </td>
144
+ </tr>
145
+ </tbody>
146
+ </table>
147
+ <h3>Automatic Twitter links</h3>
148
+ <table class="form-table">
149
+ <tbody>
150
+ <tr valign="top">
151
+ <th scope="row">
152
+ <label>Select what you want to convert...</label>
153
+ </th>
154
+ <td>
155
+ <label><input type="checkbox" name="twitter_handles" id="twitter_handles"';
156
+ if ($this->options['twitter_handles'] == 1) { echo ' checked="checked"';}
157
+ echo ' value="1" /> '.__("Convert Twitter usernames", 'mr_social_sharing').'</label><br/>
158
+ <label><input type="checkbox" name="twitter_hashtags" id="twitter_hashtags"';
159
+ if ($this->options['twitter_hashtags'] == 1) { echo ' checked="checked"';}
160
+ echo ' value="1" /> '.__("Convert hashtags", 'mr_social_sharing').'</label>
161
+ </td>
162
+ </tr>
163
+ <tr valign="top">
164
+ <th scope="row">
165
+ <label>... and where it should be converted</label>
166
+ </th>
167
+ <td>
168
+ <label><input type="checkbox" name="linkify_content" id="linkify_content"';
169
+ if ($this->options['linkify_content'] == 1) { echo ' checked="checked"';}
170
+ echo ' value="1" /> '.__("Convert in posts and pages", 'mr_social_sharing').'</label><br/>
171
+ <label><input type="checkbox" name="linkify_comments" id="linkify_comments"';
172
+ if ($this->options['linkify_comments'] == 1) { echo ' checked="checked"';}
173
+ echo ' value="1" /> '.__("Convert in comments", 'mr_social_sharing').'</label>
174
+ </td>
175
+ </tr>
176
+ </tbody>
177
+ </table>
178
+ <p class="submit">
179
+ <input type="submit" name="Submit" class="button-primary" value="'.esc_attr__('Save Changes').'" />
180
+ </p>
181
+ </form>
182
+ </div>';
183
+ }
184
+
185
+ /* Output functions */
186
+
187
+ function should_share_content() {
188
+ if ($this->options['position'] == 'none') {
189
+ return false;
190
+ }
191
+ wp_enqueue_style('mr_social_sharing', plugins_url('/style.css', __FILE__));
192
+ if ($this->options['plus'] == 1) {
193
+ wp_enqueue_script('GooglePlus', 'https://apis.google.com/js/plusone.js');
194
+ }
195
+ if ($this->options['tumblr'] == 1) {
196
+ wp_enqueue_script('Tumblr', 'http://platform.tumblr.com/v1/share.js', array(), false, true);
197
+ }
198
+ if ($this->options['digg'] == 1) {
199
+ wp_enqueue_script('digg', 'http://widgets.digg.com/buttons.js');
200
+ }
201
+ if ($this->options['position'] == 'shortcode') {
202
+ return false;
203
+ }
204
+ return true;
205
+ }
206
+
207
+ function create_bookmarks() {
208
+ $title = the_title();
209
+ $url = get_permalink();
210
+ $class = 'mr_social_sharing_'.$this->options['layout'];
211
+ $bookmarks = '<ul class="mr_social_sharing">
212
+ <!-- Social Sharing Toolkit v1.0.0 | http://www.marijnrongen.com/wordpress-plugins/social_sharing_toolkit/ -->';
213
+ if ($this->options['like'] == 1) {
214
+ $bookmarks .= '
215
+ <li class="'.$class.'">
216
+ <iframe src="http://www.facebook.com/plugins/like.php?href='.$url.'&amp;layout=';
217
+ switch ($this->options['layout']) {
218
+ case 'horizontal':
219
+ $bookmarks .= 'button_count';
220
+ $width = '90px';
221
+ $height = '20px';
222
+ break;
223
+ case 'vertical':
224
+ $bookmarks .= 'box_count';
225
+ $width = '55px';
226
+ $height = '65px';
227
+ break;
228
+ default:
229
+ $bookmarks .= 'standard';
230
+ $width = '225%';
231
+ $height = '35px';
232
+ break;
233
+ }
234
+ $bookmarks .= '&amp;show_faces=false&amp;width='.$width.'&amp;height='.$height.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$width.'; height:'.$height.';" allowTransparency="true"></iframe>
235
+ </li>';
236
+ }
237
+ if ($this->options['tweet'] == 1) {
238
+ $bookmarks .= '
239
+ <li class="'.$class.'">
240
+ <a href="http://twitter.com/share" class="twitter-share-button" data-url="'.$url.'" data-count="';
241
+ switch ($this->options['layout']) {
242
+ case 'horizontal':
243
+ $bookmarks .= 'horizontal';
244
+ break;
245
+ case 'vertical':
246
+ $bookmarks .= 'vertical';
247
+ break;
248
+ default:
249
+ $bookmarks .= 'none';
250
+ break;
251
+ }
252
+ $bookmarks .= '">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
253
+ </li>';
254
+ }
255
+ if ($this->options['plus'] == 1) {
256
+ $bookmarks .= '
257
+ <li class="'.$class.'">
258
+ <g:plusone';
259
+ switch ($this->options['layout']) {
260
+ case 'horizontal':
261
+ $bookmarks .= ' size="medium"';
262
+ break;
263
+ case 'vertical':
264
+ $bookmarks .= ' size="tall"';
265
+ break;
266
+ default:
267
+ $bookmarks .= ' size="medium" count="false"';
268
+ break;
269
+ }
270
+ $bookmarks .= ' href="'.$url.'"></g:plusone>
271
+ </li>';
272
+ }
273
+ if ($this->options['share'] == 1) {
274
+ $bookmarks .= '
275
+ <li class="'.$class.'">
276
+ <script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="'.$url.'"';
277
+ switch ($this->options['layout']) {
278
+ case 'horizontal':
279
+ $bookmarks .= ' data-counter="right"';
280
+ break;
281
+ case 'vertical':
282
+ $bookmarks .= ' data-counter="top"';
283
+ break;
284
+ default:
285
+ $bookmarks .= '';
286
+ break;
287
+ }
288
+ $bookmarks .= '></script>
289
+ </li>';
290
+ }
291
+ if ($this->options['tumblr'] == 1) {
292
+ $bookmarks .= '
293
+ <li class="'.$class.'">
294
+ <a href="http://www.tumblr.com/share" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; ';
295
+ switch ($this->options['layout']) {
296
+ case 'horizontal':
297
+ $bookmarks .= 'width:81px; height:20px; background:url(\'http://platform.tumblr.com/v1/share_1.png\')';
298
+ break;
299
+ case 'vertical':
300
+ $bookmarks .= 'width:61px; height:20px; background:url(\'http://platform.tumblr.com/v1/share_2.png\')';
301
+ break;
302
+ default:
303
+ $bookmarks .= 'width:61px; height:20px; background:url(\'http://platform.tumblr.com/v1/share_2.png\')';
304
+ break;
305
+ }
306
+ $bookmarks .= ' top left no-repeat transparent;">Share on Tumblr</a>
307
+ </li>';
308
+ }
309
+ if ($this->options['stumble'] == 1) {
310
+ $bookmarks .= '
311
+ <li class="'.$class.'">
312
+ <script src="http://www.stumbleupon.com/hostedbadge.php?s=';
313
+ switch ($this->options['layout']) {
314
+ case 'horizontal':
315
+ $bookmarks .= '1';
316
+ break;
317
+ case 'vertical':
318
+ $bookmarks .= '5';
319
+ break;
320
+ default:
321
+ $bookmarks .= '4';
322
+ break;
323
+ }
324
+ $bookmarks .= '&r='.$url.'"></script>
325
+ </li>';
326
+ }
327
+ if ($this->options['digg'] == 1) {
328
+ $bookmarks .= '
329
+ <li class="'.$class.'">
330
+ <a class="DiggThisButton ';
331
+ switch ($this->options['layout']) {
332
+ case 'horizontal':
333
+ $bookmarks .= 'DiggCompact';
334
+ break;
335
+ case 'vertical':
336
+ $bookmarks .= 'DiggMedium';
337
+ break;
338
+ default:
339
+ $bookmarks .= 'DiggIcon';
340
+ break;
341
+ }
342
+ $bookmarks .= '" href="http://digg.com/submit?url='.$url.'&amp;title='.$title.'"></a>
343
+ </li>';
344
+ }
345
+ if ($this->options['reddit'] == 1) {
346
+ $bookmarks .= '
347
+ <li class="'.$class.'">';
348
+ switch ($this->options['layout']) {
349
+ case 'horizontal':
350
+ $bookmarks .= '
351
+ <script type="text/javascript">
352
+ reddit_url = "'.$url.'";
353
+ reddit_title = "'.$title.'";
354
+ </script>
355
+ <script type="text/javascript" src="http://www.reddit.com/static/button/button1.js"></script>';
356
+ break;
357
+ case 'vertical':
358
+ $bookmarks .= '
359
+ <script type="text/javascript">
360
+ reddit_url = "'.$url.'";
361
+ reddit_title = "'.$title.'";
362
+ </script>
363
+ <script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script>';
364
+ break;
365
+ default:
366
+ $bookmarks .= '
367
+ <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>';
368
+ break;
369
+ }
370
+ $bookmarks .= '
371
+ </li>';
372
+ }
373
+ if ($this->options['myspace'] == 1) {
374
+ $bookmarks .= '
375
+ <li class="'.$class.'">
376
+ <a href="javascript:void(window.open(\'http://www.myspace.com/Modules/PostTo/Pages/?u='.$url.'\',\'ptm\',\'height=450,width=550\').focus())">
377
+ <img src="http://cms.myspacecdn.com/cms//ShareOnMySpace/Myspace_btn_';
378
+ switch ($this->options['layout']) {
379
+ case 'horizontal':
380
+ $bookmarks .= 'ShareOnMyspace';
381
+ break;
382
+ default:
383
+ $bookmarks .= 'Share';
384
+ break;
385
+ }
386
+ $bookmarks .= '.png" border="0" alt="Share on Myspace" />
387
+ </a>
388
+ </li>';
389
+ }
390
+ if ($this->options['hyves'] == 1) {
391
+ $bookmarks .= '
392
+ <li class="'.$class.'">
393
+ <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>
394
+ </li>';
395
+ $bookmarks .= '
396
+ </ul>';
397
+ }
398
+ return $bookmarks;
399
+ }
400
+
401
+ function share($content) {
402
+ if ($this->options['position'] == 'top') {
403
+ $bookmarks = $this->create_bookmarks();
404
+ $content = $bookmarks.$content;
405
+ }
406
+ if ($this->options['position'] == 'bottom') {
407
+ $bookmarks = $this->create_bookmarks();
408
+ $content .= $bookmarks;
409
+ }
410
+ return $content;
411
+ }
412
+
413
+ function share_shortcode() {
414
+ $bookmarks = '';
415
+ if ($this->options['position'] == 'shortcode') {
416
+ $bookmarks = $this->create_bookmarks();
417
+ }
418
+ return $bookmarks;
419
+ }
420
+
421
+ function should_linkify_content() {
422
+ if ($this->options['linkify_content'] == 1) {
423
+ return true;
424
+ }
425
+ return false;
426
+ }
427
+
428
+ function should_linkify_comments() {
429
+ if ($this->options['linkify_comments'] == 1) {
430
+ return true;
431
+ }
432
+ return false;
433
+ }
434
+
435
+ function linkify($content) {
436
+ if ($this->options['twitter_handles'] == 1) {
437
+ $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);
438
+ }
439
+ if ($this->options['twitter_hashtags'] == 1) {
440
+ $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);
441
+ }
442
+ return $content;
443
+ }
444
+ }
445
+ $MR_Social_Sharing_Toolkit = new MR_Social_Sharing_Toolkit();
446
+ if ($MR_Social_Sharing_Toolkit->should_linkify_content()) {
447
+ add_filter('the_content', array($MR_Social_Sharing_Toolkit, 'linkify'));
448
+ }
449
+ if ($MR_Social_Sharing_Toolkit->should_linkify_comments()) {
450
+ add_filter('comment_text', array($MR_Social_Sharing_Toolkit, 'linkify'));
451
+ }
452
+ if ($MR_Social_Sharing_Toolkit->should_share_content()) {
453
+ add_filter( 'the_content', array($MR_Social_Sharing_Toolkit, 'share'));
454
+ }
455
+ add_shortcode('social_share', array($MR_Social_Sharing_Toolkit, 'share_shortcode'));
456
+ /* Register plugin admin page */
457
+ add_action('admin_menu', array($MR_Social_Sharing_Toolkit, 'plugin_menu'));
style.css ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ul.mr_social_sharing {
2
+ list-style-type: none;
3
+ float: left;
4
+ clear: both;
5
+ display: block;
6
+ width: 100%;
7
+ margin: 0;
8
+ padding: 0;
9
+ }
10
+
11
+ li.mr_social_sharing_none {
12
+ float: left;
13
+ width: auto;
14
+ height: 24px;
15
+ margin: 0;
16
+ padding: 4px;
17
+ }
18
+
19
+ li.mr_social_sharing_horizontal {
20
+ float: left;
21
+ width: 150px;
22
+ height: 24px;
23
+ margin: 0;
24
+ padding: 0;
25
+ text-align: left;
26
+ }
27
+
28
+ li.mr_social_sharing_vertical {
29
+ float: left;
30
+ width: 64px;
31
+ height: 70px;
32
+ margin: 0;
33
+ padding: 0;
34
+ text-align: center;
35
+ }
36
+
37
+ li.mr_social_sharing_none img, li.mr_social_sharing_horizontal img, li.mr_social_sharing_vertical img {
38
+ margin: 0;
39
+ padding: 0;
40
+ border: 0;
41
+ }