Version Description
- Added option to select image size available for sharing if featured image is set.
- Add new button to enable sharing on more services, including Gmail, AOL, Evernote, Hotmail, Instapaper, Mail.ru, Pocket, Sonico, vkontakte, Weibo, Yahoo Mail, and Yammer.
- Bug fixes.
Download this release
Release Info
Developer | linksalpha |
Plugin | Social Sharing Toolkit |
Version | 2.2 |
Comparing to | |
See all releases |
Code changes from version 2.1.4 to 2.2
- admin_2.1.2.css +1 -1
- images/buttons/share.png +0 -0
- images/icons_large/appnet.png +0 -0
- images/icons_large/share.png +0 -0
- images/icons_medium/appnet.png +0 -0
- images/icons_medium/share.png +0 -0
- images/icons_small/appnet.png +0 -0
- images/icons_small/share.png +0 -0
- includes/buttons/button.email.php +1 -1
- includes/buttons/button.facebook.php +8 -21
- includes/buttons/button.goodreads.php +1 -1
- includes/buttons/button.googleplus.js +1 -1
- includes/buttons/button.googleplus.php +2 -2
- includes/buttons/button.linksalpha.php +30 -0
- includes/buttons/button.twitter.php +2 -21
- includes/follow.widget.php +1 -1
- includes/share.widget.php +1 -1
- readme.txt +25 -14
- social_sharing_toolkit.php +605 -451
admin_2.1.2.css
CHANGED
@@ -50,7 +50,7 @@ div.mr_social_sharing_networks {
|
|
50 |
outline-style: none;
|
51 |
outline-width: 0px;
|
52 |
width: 600px;
|
53 |
-
padding:
|
54 |
}
|
55 |
|
56 |
.mr_social_sharing_networks h3, .mr_social_sharing_networks h4, .mr_social_sharing_networks p {
|
50 |
outline-style: none;
|
51 |
outline-width: 0px;
|
52 |
width: 600px;
|
53 |
+
padding: 10px 0 10px 0;
|
54 |
}
|
55 |
|
56 |
.mr_social_sharing_networks h3, .mr_social_sharing_networks h4, .mr_social_sharing_networks p {
|
images/buttons/share.png
ADDED
Binary file
|
images/icons_large/appnet.png
CHANGED
Binary file
|
images/icons_large/share.png
ADDED
Binary file
|
images/icons_medium/appnet.png
CHANGED
Binary file
|
images/icons_medium/share.png
ADDED
Binary file
|
images/icons_small/appnet.png
CHANGED
Binary file
|
images/icons_small/share.png
ADDED
Binary file
|
includes/buttons/button.email.php
CHANGED
@@ -9,7 +9,7 @@ class MR_Social_Sharing_Toolkit_Email extends MR_Social_Sharing_Toolkit_Button {
|
|
9 |
function ml_send($url, $title, $type, $id = '', $media = '', $description = '', $text = '', $icon = '') {
|
10 |
$url = 'mailto:?subject='.$title.'&body='.$url;
|
11 |
$text = ($text == '') ? __('Share via email','mr_social_sharing_toolkit') : $text;
|
12 |
-
return $this->get_icon($type, $url, $text, $icon, false, true);
|
13 |
}
|
14 |
}
|
15 |
?>
|
9 |
function ml_send($url, $title, $type, $id = '', $media = '', $description = '', $text = '', $icon = '') {
|
10 |
$url = 'mailto:?subject='.$title.'&body='.$url;
|
11 |
$text = ($text == '') ? __('Share via email','mr_social_sharing_toolkit') : $text;
|
12 |
+
return $this->get_icon($type, $url, $text, $icon, false, true);
|
13 |
}
|
14 |
}
|
15 |
?>
|
includes/buttons/button.facebook.php
CHANGED
@@ -10,11 +10,9 @@ class MR_Social_Sharing_Toolkit_Facebook extends MR_Social_Sharing_Toolkit_Butto
|
|
10 |
}
|
11 |
|
12 |
function fb_like($url, $title, $type, $id, $media = '', $description = '', $text = '', $icon = '') {
|
13 |
-
//$retval = '<iframe src="https://www.facebook.com/plugins/like.php?locale='.__('en_US','mr_social_sharing_toolkit').'&href='.urlencode($url).'&layout=';
|
14 |
$retval = '<div class="fb-like" data-href="'.$url.'" data-send="false" ';
|
15 |
switch ($type) {
|
16 |
case 'horizontal':
|
17 |
-
//$retval .= 'button_count';
|
18 |
if ($id == 'recommend') {
|
19 |
$width = __('fb_horizontal_recommend_width','mr_social_sharing_toolkit');
|
20 |
$width = ($width == 'fb_horizontal_recommend_width') ? '120' : $width;
|
@@ -27,7 +25,6 @@ class MR_Social_Sharing_Toolkit_Facebook extends MR_Social_Sharing_Toolkit_Butto
|
|
27 |
$height = '21';
|
28 |
break;
|
29 |
case 'vertical':
|
30 |
-
//$retval .= 'box_count';
|
31 |
if ($id == 'recommend') {
|
32 |
$width = __('fb_vertical_recommend_width','mr_social_sharing_toolkit');
|
33 |
$width = ($width == 'fb_vertical_recommend_width') ? '92' : $width;
|
@@ -40,7 +37,6 @@ class MR_Social_Sharing_Toolkit_Facebook extends MR_Social_Sharing_Toolkit_Butto
|
|
40 |
$height = '62';
|
41 |
break;
|
42 |
case 'none_text':
|
43 |
-
//$retval .= 'standard';
|
44 |
if ($id == 'recommend') {
|
45 |
$width = 'auto';
|
46 |
$retval .= 'data-width="'.$width.'" data-action="recommend"';
|
@@ -51,7 +47,6 @@ class MR_Social_Sharing_Toolkit_Facebook extends MR_Social_Sharing_Toolkit_Butto
|
|
51 |
$height = '25';
|
52 |
break;
|
53 |
default:
|
54 |
-
//$retval .= 'standard';
|
55 |
if ($id == 'recommend') {
|
56 |
$width = __('fb_standard_recommend_width','mr_social_sharing_toolkit');
|
57 |
$width = ($width == 'fb_standard_standard_recommend_width') ? '91' : $width;
|
@@ -61,15 +56,14 @@ class MR_Social_Sharing_Toolkit_Facebook extends MR_Social_Sharing_Toolkit_Butto
|
|
61 |
$width = ($width == 'fb_standard_width') ? '51' : $width;
|
62 |
$retval .= 'data-width="'.$width.'"';
|
63 |
}
|
64 |
-
$height = '
|
65 |
break;
|
66 |
}
|
67 |
-
//$retval .= '&show_faces=false&width='.$width.'&height='.$height.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$width.'px; height:'.$height.'px;" allowTransparency="true"></iframe>';*/
|
68 |
$retval .= ' data-show-faces="false"></div>';
|
69 |
$lang = __('en_US','mr_social_sharing_toolkit');
|
70 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
71 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__), $footer);
|
72 |
-
$this->enqueue_script('Social_sharing_facebook_xfbml', '
|
73 |
return '<span style="display: inline-block; width: '.$width.'px; height: '.$height.'px; overflow: hidden;">'.$retval.'</span>';
|
74 |
}
|
75 |
|
@@ -77,30 +71,24 @@ class MR_Social_Sharing_Toolkit_Facebook extends MR_Social_Sharing_Toolkit_Butto
|
|
77 |
switch ($type) {
|
78 |
case 'vertical':
|
79 |
$retval = '<fb:share-button type="box_count" href="'.$url.'"></fb:share-button>';
|
80 |
-
//$retval = '<a name="fb_share" type="box_count" share_url="'.$url.'" href="http://www.facebook.com/sharer.php">Share</a>';
|
81 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__));
|
82 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
83 |
-
$this->enqueue_script('Social_sharing_facebook_xfbml', '
|
84 |
-
//$this->enqueue_script('Social_sharing_facebook_share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share', $footer);
|
85 |
break;
|
86 |
case 'horizontal':
|
87 |
$retval = '<fb:share-button type="button_count" href="'.$url.'"></fb:share-button>';
|
88 |
-
//$retval = '<a name="fb_share" type="button_count" share_url="'.$url.'" href="http://www.facebook.com/sharer.php">Share</a>';
|
89 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__));
|
90 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
91 |
-
$this->enqueue_script('Social_sharing_facebook_xfbml', '
|
92 |
-
//$this->enqueue_script('Social_sharing_facebook_share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share', $footer);
|
93 |
break;
|
94 |
case 'none':
|
95 |
$retval = '<fb:share-button type="button" href="'.$url.'"></fb:share-button>';
|
96 |
-
//$retval = '<a name="fb_share" type="button" share_url="'.$url.'" href="http://www.facebook.com/sharer.php">Share</a>';
|
97 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__));
|
98 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
99 |
-
$this->enqueue_script('Social_sharing_facebook_xfbml', '
|
100 |
-
//$this->enqueue_script('Social_sharing_facebook_share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share', $footer);
|
101 |
break;
|
102 |
default:
|
103 |
-
$url = '
|
104 |
$text = ($text == '') ? __('Share on','mr_social_sharing_toolkit').' Facebook' : $text;
|
105 |
$retval = $this->get_icon($type, $url, $text, $icon, true);
|
106 |
break;
|
@@ -109,17 +97,16 @@ class MR_Social_Sharing_Toolkit_Facebook extends MR_Social_Sharing_Toolkit_Butto
|
|
109 |
}
|
110 |
|
111 |
function fb_send($url, $title, $type, $id, $media = '', $description = '', $text = '', $icon = '') {
|
112 |
-
//$retval = '<div id="fb-root"></div><fb:send href="'.$url.'" font=""></fb:send>';
|
113 |
$retval = '<div class="fb-send" data-href="'.$url.'"></div>';
|
114 |
$lang = __('en_US','mr_social_sharing_toolkit');
|
115 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__));
|
116 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
117 |
-
$this->enqueue_script('Social_sharing_facebook_xfbml', '
|
118 |
return $retval;
|
119 |
}
|
120 |
|
121 |
function follow_facebook($type, $id, $text = '', $icon = '') {
|
122 |
-
$url = '
|
123 |
$text = ($text == '') ? __('Friend me on','mr_social_sharing_toolkit').' Facebook' : $text;
|
124 |
$blank = (get_option('mr_social_sharing_follow_new') == 1) ? true : false;
|
125 |
return $this->get_icon($type, $url, $text, $icon, false, $blank);
|
10 |
}
|
11 |
|
12 |
function fb_like($url, $title, $type, $id, $media = '', $description = '', $text = '', $icon = '') {
|
|
|
13 |
$retval = '<div class="fb-like" data-href="'.$url.'" data-send="false" ';
|
14 |
switch ($type) {
|
15 |
case 'horizontal':
|
|
|
16 |
if ($id == 'recommend') {
|
17 |
$width = __('fb_horizontal_recommend_width','mr_social_sharing_toolkit');
|
18 |
$width = ($width == 'fb_horizontal_recommend_width') ? '120' : $width;
|
25 |
$height = '21';
|
26 |
break;
|
27 |
case 'vertical':
|
|
|
28 |
if ($id == 'recommend') {
|
29 |
$width = __('fb_vertical_recommend_width','mr_social_sharing_toolkit');
|
30 |
$width = ($width == 'fb_vertical_recommend_width') ? '92' : $width;
|
37 |
$height = '62';
|
38 |
break;
|
39 |
case 'none_text':
|
|
|
40 |
if ($id == 'recommend') {
|
41 |
$width = 'auto';
|
42 |
$retval .= 'data-width="'.$width.'" data-action="recommend"';
|
47 |
$height = '25';
|
48 |
break;
|
49 |
default:
|
|
|
50 |
if ($id == 'recommend') {
|
51 |
$width = __('fb_standard_recommend_width','mr_social_sharing_toolkit');
|
52 |
$width = ($width == 'fb_standard_standard_recommend_width') ? '91' : $width;
|
56 |
$width = ($width == 'fb_standard_width') ? '51' : $width;
|
57 |
$retval .= 'data-width="'.$width.'"';
|
58 |
}
|
59 |
+
$height = '21';
|
60 |
break;
|
61 |
}
|
|
|
62 |
$retval .= ' data-show-faces="false"></div>';
|
63 |
$lang = __('en_US','mr_social_sharing_toolkit');
|
64 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
65 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__), $footer);
|
66 |
+
$this->enqueue_script('Social_sharing_facebook_xfbml', '//connect.facebook.net/'.$lang.'/all.js#xfbml=1&appId=188707654478', $footer);
|
67 |
return '<span style="display: inline-block; width: '.$width.'px; height: '.$height.'px; overflow: hidden;">'.$retval.'</span>';
|
68 |
}
|
69 |
|
71 |
switch ($type) {
|
72 |
case 'vertical':
|
73 |
$retval = '<fb:share-button type="box_count" href="'.$url.'"></fb:share-button>';
|
|
|
74 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__));
|
75 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
76 |
+
$this->enqueue_script('Social_sharing_facebook_xfbml', '//connect.facebook.net/en_US/all.js#xfbml=1&appId=188707654478', $footer);
|
|
|
77 |
break;
|
78 |
case 'horizontal':
|
79 |
$retval = '<fb:share-button type="button_count" href="'.$url.'"></fb:share-button>';
|
|
|
80 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__));
|
81 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
82 |
+
$this->enqueue_script('Social_sharing_facebook_xfbml', '//connect.facebook.net/en_US/all.js#xfbml=1&appId=188707654478', $footer);
|
|
|
83 |
break;
|
84 |
case 'none':
|
85 |
$retval = '<fb:share-button type="button" href="'.$url.'"></fb:share-button>';
|
|
|
86 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__));
|
87 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
88 |
+
$this->enqueue_script('Social_sharing_facebook_xfbml', '//connect.facebook.net/en_US/all.js#xfbml=1&appId=188707654478', $footer);
|
|
|
89 |
break;
|
90 |
default:
|
91 |
+
$url = '//www.facebook.com/sharer/sharer.php?u='.urlencode($url).'&t='.urlencode($title);
|
92 |
$text = ($text == '') ? __('Share on','mr_social_sharing_toolkit').' Facebook' : $text;
|
93 |
$retval = $this->get_icon($type, $url, $text, $icon, true);
|
94 |
break;
|
97 |
}
|
98 |
|
99 |
function fb_send($url, $title, $type, $id, $media = '', $description = '', $text = '', $icon = '') {
|
|
|
100 |
$retval = '<div class="fb-send" data-href="'.$url.'"></div>';
|
101 |
$lang = __('en_US','mr_social_sharing_toolkit');
|
102 |
$this->enqueue_script('Social_sharing_facebook_root', plugins_url('/button.facebook.js', __FILE__));
|
103 |
$footer = (get_option('mr_social_sharing_js_footer') == 1) ? true : false;
|
104 |
+
$this->enqueue_script('Social_sharing_facebook_xfbml', '//connect.facebook.net/'.$lang.'/all.js#xfbml=1&appId=188707654478', $footer);
|
105 |
return $retval;
|
106 |
}
|
107 |
|
108 |
function follow_facebook($type, $id, $text = '', $icon = '') {
|
109 |
+
$url = '//www.facebook.com/'.$id;
|
110 |
$text = ($text == '') ? __('Friend me on','mr_social_sharing_toolkit').' Facebook' : $text;
|
111 |
$blank = (get_option('mr_social_sharing_follow_new') == 1) ? true : false;
|
112 |
return $this->get_icon($type, $url, $text, $icon, false, $blank);
|
includes/buttons/button.goodreads.php
CHANGED
@@ -7,7 +7,7 @@ class MR_Social_Sharing_Toolkit_Goodreads extends MR_Social_Sharing_Toolkit_Butt
|
|
7 |
}
|
8 |
|
9 |
function follow_goodreads($type, $id, $text = '', $icon = '') {
|
10 |
-
$url = 'http://goodreads.com/
|
11 |
$text = ($text == '') ? __('My profile on','mr_social_sharing_toolkit').' Goodreads' : $text;
|
12 |
$blank = (get_option('mr_social_sharing_follow_new') == 1) ? true : false;
|
13 |
return $this->get_icon($type, $url, $text, $icon, false, $blank);
|
7 |
}
|
8 |
|
9 |
function follow_goodreads($type, $id, $text = '', $icon = '') {
|
10 |
+
$url = 'http://goodreads.com/author/show/'.$id;
|
11 |
$text = ($text == '') ? __('My profile on','mr_social_sharing_toolkit').' Goodreads' : $text;
|
12 |
$blank = (get_option('mr_social_sharing_follow_new') == 1) ? true : false;
|
13 |
return $this->get_icon($type, $url, $text, $icon, false, $blank);
|
includes/buttons/button.googleplus.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
(function() {
|
2 |
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
|
3 |
-
po.src = '
|
4 |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
|
5 |
})();
|
1 |
(function() {
|
2 |
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
|
3 |
+
po.src = '//apis.google.com/js/plusone.js';
|
4 |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
|
5 |
})();
|
includes/buttons/button.googleplus.php
CHANGED
@@ -25,7 +25,7 @@ class MR_Social_Sharing_Toolkit_GooglePlus extends MR_Social_Sharing_Toolkit_But
|
|
25 |
$this->enqueue_script('Social_sharing_googleplus', plugins_url('/button.googleplus.js', __FILE__), $footer);
|
26 |
break;
|
27 |
default:
|
28 |
-
$url = '
|
29 |
$text = ($text == '') ? '+1' : $text;
|
30 |
$retval = $this->get_icon($type, $url, $text, $icon, true);
|
31 |
break;
|
@@ -34,7 +34,7 @@ class MR_Social_Sharing_Toolkit_GooglePlus extends MR_Social_Sharing_Toolkit_But
|
|
34 |
}
|
35 |
|
36 |
function follow_plus($type, $id, $text = '', $icon = '') {
|
37 |
-
$url = '
|
38 |
$text = ($text == '') ? __('Add me to your circles','mr_social_sharing_toolkit') : $text;
|
39 |
$blank = (get_option('mr_social_sharing_follow_new') == 1) ? true : false;
|
40 |
return $this->get_icon($type, $url, $text, $icon, false, $blank);
|
25 |
$this->enqueue_script('Social_sharing_googleplus', plugins_url('/button.googleplus.js', __FILE__), $footer);
|
26 |
break;
|
27 |
default:
|
28 |
+
$url = '//plusone.google.com/_/+1/confirm?hl=en&url='.urlencode($url).'&title='.urlencode($title);
|
29 |
$text = ($text == '') ? '+1' : $text;
|
30 |
$retval = $this->get_icon($type, $url, $text, $icon, true);
|
31 |
break;
|
34 |
}
|
35 |
|
36 |
function follow_plus($type, $id, $text = '', $icon = '') {
|
37 |
+
$url = '//plus.google.com/'.$id;
|
38 |
$text = ($text == '') ? __('Add me to your circles','mr_social_sharing_toolkit') : $text;
|
39 |
$blank = (get_option('mr_social_sharing_follow_new') == 1) ? true : false;
|
40 |
return $this->get_icon($type, $url, $text, $icon, false, $blank);
|
includes/buttons/button.linksalpha.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class MR_Social_Sharing_Toolkit_LinksAlpha extends MR_Social_Sharing_Toolkit_Button {
|
3 |
+
function __construct() {
|
4 |
+
$this->share_buttons[] = array('name' => 'linksalpha', 'types' => array('none', 'icon_small', 'icon_medium', 'icon_large'));
|
5 |
+
$this->title = 'LinksAlpha Share';
|
6 |
+
$this->icon = 'share';
|
7 |
+
}
|
8 |
+
function linksalpha($url, $title, $type, $id = '', $media = '', $description = '', $text = '', $icon = '') {
|
9 |
+
switch ($type) {
|
10 |
+
case 'icon_small':
|
11 |
+
$image = 'social_share_'.$type.'.png';
|
12 |
+
break;
|
13 |
+
case 'icon_medium':
|
14 |
+
$image = 'social_share_'.$type.'.png';
|
15 |
+
break;
|
16 |
+
case 'icon_large':
|
17 |
+
$image = 'social_share_'.$type.'.png';
|
18 |
+
break;
|
19 |
+
default:
|
20 |
+
$image = 'social_share_button.png';
|
21 |
+
break;
|
22 |
+
}
|
23 |
+
$retval = '<a class="linksalpha_button linksalpha_link" href="//www.linksalpha.com/social/mobile" data-url="'.$url.'" data-text="'.$title.'" data-desc="'.$description.'" data-image="'.$media.'" data-button="'.$type.'">
|
24 |
+
<img src="//www.linksalpha.com/images/'.$image.'" alt="Share" class="linksalpha_image" />
|
25 |
+
</a><script type="text/javascript" src="//www.linksalpha.com/social/loader_iconbox?link='.urlencode($url).'&id='.rand().'"></script>';
|
26 |
+
return $retval;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
$MR_Social_Sharing_Toolkit_LinksAlpha = new MR_Social_Sharing_Toolkit_LinksAlpha();
|
30 |
+
?>
|
includes/buttons/button.twitter.php
CHANGED
@@ -5,15 +5,13 @@ class MR_Social_Sharing_Toolkit_Twitter extends MR_Social_Sharing_Toolkit_Button
|
|
5 |
$this->follow_buttons[] = array('name' => 'follow_twitter', 'id' => '@', 'types' => array('none', 'horizontal', 'icon_small', 'icon_small_text', 'icon_medium', 'icon_medium_text', 'icon_large'));
|
6 |
$this->title = 'Twitter';
|
7 |
$this->icon = 'twitter';
|
8 |
-
//add_shortcode('social_share_twitter', array($this, 'shortcode_tweet'));
|
9 |
-
//add_shortcode('social_follow_twitter', array($this, 'shortcode_follow'));
|
10 |
}
|
11 |
|
12 |
function tw_tweet($url, $title, $type, $id, $media = '', $description = '', $text = '', $icon = '') {
|
13 |
$count_url = '';
|
14 |
$bitly = get_option('mr_social_sharing_bitly');
|
15 |
-
if ($bitly['enable'] == 1 && $bitly['username'] != '' && $bitly['key'] != '') {
|
16 |
-
if (is_array($bitly['cache']) && array_key_exists($url, $bitly['cache'])) {
|
17 |
$count_url = $url;
|
18 |
$url = $bitly['cache'][$url];
|
19 |
} else {
|
@@ -101,23 +99,6 @@ class MR_Social_Sharing_Toolkit_Twitter extends MR_Social_Sharing_Toolkit_Button
|
|
101 |
return $retval;
|
102 |
}
|
103 |
|
104 |
-
/*function shortcode_tweet() {
|
105 |
-
if (!is_feed()) {
|
106 |
-
extract(shortcode_atts(array('id' => '', 'type' => 'none', 'title' => get_the_title(), 'url' => get_permalink()), $atts));
|
107 |
-
return $this->tw_tweet($url, $title, $type, $id);
|
108 |
-
}
|
109 |
-
return '';
|
110 |
-
}
|
111 |
-
|
112 |
-
function shortcode_follow() {
|
113 |
-
if (!is_feed()) {
|
114 |
-
extract(shortcode_atts(array('id' => '', 'type' => 'none'), $atts));
|
115 |
-
if ($id != '') {
|
116 |
-
return $this->follow_twitter($type, $id);
|
117 |
-
}
|
118 |
-
}
|
119 |
-
return '';
|
120 |
-
}*/
|
121 |
}
|
122 |
$MR_Social_Sharing_Toolkit_Twitter = new MR_Social_Sharing_Toolkit_Twitter();
|
123 |
?>
|
5 |
$this->follow_buttons[] = array('name' => 'follow_twitter', 'id' => '@', 'types' => array('none', 'horizontal', 'icon_small', 'icon_small_text', 'icon_medium', 'icon_medium_text', 'icon_large'));
|
6 |
$this->title = 'Twitter';
|
7 |
$this->icon = 'twitter';
|
|
|
|
|
8 |
}
|
9 |
|
10 |
function tw_tweet($url, $title, $type, $id, $media = '', $description = '', $text = '', $icon = '') {
|
11 |
$count_url = '';
|
12 |
$bitly = get_option('mr_social_sharing_bitly');
|
13 |
+
if (isset($bitly['enable']) && $bitly['enable'] == 1 && $bitly['username'] != '' && $bitly['key'] != '') {
|
14 |
+
if (isset($bitly['cache']) && is_array($bitly['cache']) && array_key_exists($url, $bitly['cache'])) {
|
15 |
$count_url = $url;
|
16 |
$url = $bitly['cache'][$url];
|
17 |
} else {
|
99 |
return $retval;
|
100 |
}
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
$MR_Social_Sharing_Toolkit_Twitter = new MR_Social_Sharing_Toolkit_Twitter();
|
104 |
?>
|
includes/follow.widget.php
CHANGED
@@ -6,7 +6,7 @@ class MR_Social_Sharing_Toolkit_Follow_Widget extends WP_Widget {
|
|
6 |
$this->WP_Widget( 'mr-social-sharing-toolkit-follow-widget', 'Social Sharing Toolkit '.__('Follow Widget','mr_social_sharing_toolkit'), $widget_ops, $control_ops );
|
7 |
}
|
8 |
|
9 |
-
function widget
|
10 |
extract( $args );
|
11 |
global $MR_Social_Sharing_Toolkit;
|
12 |
$widget_title = empty($instance['widget_title']) ? '' : $instance['widget_title'];
|
6 |
$this->WP_Widget( 'mr-social-sharing-toolkit-follow-widget', 'Social Sharing Toolkit '.__('Follow Widget','mr_social_sharing_toolkit'), $widget_ops, $control_ops );
|
7 |
}
|
8 |
|
9 |
+
function widget($args, $instance) {
|
10 |
extract( $args );
|
11 |
global $MR_Social_Sharing_Toolkit;
|
12 |
$widget_title = empty($instance['widget_title']) ? '' : $instance['widget_title'];
|
includes/share.widget.php
CHANGED
@@ -13,7 +13,7 @@ class MR_Social_Sharing_Toolkit_Widget extends WP_Widget {
|
|
13 |
$url = empty($instance['fixed_url']) ? '' : $instance['fixed_url'];
|
14 |
$title = empty($instance['fixed_title']) ? wp_title('', false) : $instance['fixed_title'];
|
15 |
$media = '';
|
16 |
-
if ($this->options['mr_social_sharing_pinterest']['default_image'] != '' && $this->options['mr_social_sharing_pinterest']['fixed_image'] == 1) {
|
17 |
$media = $this->options['mr_social_sharing_pinterest']['default_image'];
|
18 |
} else {
|
19 |
if (current_theme_supports('post-thumbnails')) {
|
13 |
$url = empty($instance['fixed_url']) ? '' : $instance['fixed_url'];
|
14 |
$title = empty($instance['fixed_title']) ? wp_title('', false) : $instance['fixed_title'];
|
15 |
$media = '';
|
16 |
+
if (( isset($this->options['mr_social_sharing_pinterest']['default_image']) && $this->options['mr_social_sharing_pinterest']['default_image'] != '') && (isset($this->options['mr_social_sharing_pinterest']['fixed_image']) && $this->options['mr_social_sharing_pinterest']['fixed_image'] == 1)) {
|
17 |
$media = $this->options['mr_social_sharing_pinterest']['default_image'];
|
18 |
} else {
|
19 |
if (current_theme_supports('post-thumbnails')) {
|
readme.txt
CHANGED
@@ -1,30 +1,21 @@
|
|
1 |
=== Social Sharing Toolkit ===
|
2 |
Contributors: linksalpha
|
3 |
-
Tags: Facebook, Like, LinkedIn, Share, Google, Plus, +1, Pinterest, Google+, Twitter, Tweet,
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 2.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
Easy sharing and connecting on social networks. Display on posts or use widgets or shortcode. Also Twitter name/hashtag to link converter.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
= Change of developer after version 2.1.4 =
|
14 |
-
|
15 |
-
Version 2.1.4 is the last version I have personally updated and supported. From now on, further development and support will be provided by LinksAlpha.
|
16 |
-
|
17 |
-
The last years I have been amazed at how well received this plugin has been. Sadly, I find myself unable to effectively combine further development and, more importantly, support with my other obligations. This is why I agreed to transfer further development and support to LinksAlpha. I fully expect that the current quality of the plugin will be maintained and improved under the care of LinksAlpha.
|
18 |
-
|
19 |
-
~ Marijn Rongen, Active-Bits - July 2013
|
20 |
-
|
21 |
= Sharing content =
|
22 |
|
23 |
The plugin currently supports the following networks for sharing your content:
|
24 |
|
25 |
* Facebook (like, share and send buttons)
|
26 |
* Twitter
|
27 |
-
* Buffer
|
28 |
* Google +1
|
29 |
* Pinterest
|
30 |
* LinkedIn
|
@@ -36,8 +27,20 @@ The plugin currently supports the following networks for sharing your content:
|
|
36 |
* Myspace
|
37 |
* Hyves
|
38 |
* App.net
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
You can decide which networks to support on your blog, where the buttons will appear (either above or below the content). Through drag and drop you can easily change the order in which the buttons appear.
|
43 |
|
@@ -126,6 +129,9 @@ Since version 2.0.7 is is possible to enter the URL of a default image to use in
|
|
126 |
Since version 2.0.5 the plugin also has the option to automatically create Open Graph tags on your Wordpress site. These will tell Facebook for example which image to display when sharing a page.
|
127 |
You can enter the URL of a default image to use in case no image was found. The plugin will try to use the thumbnail attached to the post (if your theme supports it), or the first image it finds in the content. To turn of this behavior you can check a box which will force the plugin to always use the default image you have specified.
|
128 |
|
|
|
|
|
|
|
129 |
== Frequently Asked Questions ==
|
130 |
|
131 |
= My excerpts aren't displaying the buttons but some strange text is displayed =
|
@@ -177,6 +183,11 @@ Upload the Social Sharing Toolkit plugin to the `/wp-content/plugins/` folder on
|
|
177 |
|
178 |
== Upgrade Notice ==
|
179 |
|
|
|
|
|
|
|
|
|
|
|
180 |
= 2.1.4 =
|
181 |
|
182 |
Change from webstagram profile to native instagram profile, notification of author change.
|
1 |
=== Social Sharing Toolkit ===
|
2 |
Contributors: linksalpha
|
3 |
+
Tags: Facebook, Like, LinkedIn, Share, Google, Plus, +1, Pinterest, Google+, Twitter, Tweet, Follow, StumbleUpon, Stumble, Tumblr, Delicious, Digg, Reddit, Myspace, Hyves, YouTube, Flickr, 500px, Picasa, deaviantART, App.net, mail, Gmail, AOL, Evernote, Hotmail, Instapaper, Mail.ru, Pocket, Sonico, vkontakte, Weibo, Yahoo Mail, Yammer, RSS, feed, connect, recommend, social, sharing, widget, shortcode, page, post, button, counter, icon, bitly, Open Graph
|
4 |
Requires at least: 3.0
|
5 |
+
Tested up to: 3.6.1
|
6 |
+
Stable tag: 2.2
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
Easy sharing and connecting on social networks. Display on posts or use widgets or shortcode. Also Twitter name/hashtag to link converter.
|
10 |
|
11 |
== Description ==
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
= Sharing content =
|
14 |
|
15 |
The plugin currently supports the following networks for sharing your content:
|
16 |
|
17 |
* Facebook (like, share and send buttons)
|
18 |
* Twitter
|
|
|
19 |
* Google +1
|
20 |
* Pinterest
|
21 |
* LinkedIn
|
27 |
* Myspace
|
28 |
* Hyves
|
29 |
* App.net
|
30 |
+
* Gmail
|
31 |
+
* AOL
|
32 |
+
* Evernote
|
33 |
+
* Hotmail
|
34 |
+
* Instapaper
|
35 |
+
* Mail.ru
|
36 |
+
* Pocket
|
37 |
+
* Sonico
|
38 |
+
* vkontakte
|
39 |
+
* Weibo
|
40 |
+
* Yahoo Mail
|
41 |
+
* Yammer.
|
42 |
+
|
43 |
+
On Tweet button you can specify a Twitter handle which is then appended to the tweet a visitor sends (like "... via @WordPress"). An email send button is also included.
|
44 |
|
45 |
You can decide which networks to support on your blog, where the buttons will appear (either above or below the content). Through drag and drop you can easily change the order in which the buttons appear.
|
46 |
|
129 |
Since version 2.0.5 the plugin also has the option to automatically create Open Graph tags on your Wordpress site. These will tell Facebook for example which image to display when sharing a page.
|
130 |
You can enter the URL of a default image to use in case no image was found. The plugin will try to use the thumbnail attached to the post (if your theme supports it), or the first image it finds in the content. To turn of this behavior you can check a box which will force the plugin to always use the default image you have specified.
|
131 |
|
132 |
+
= Analytics =
|
133 |
+
The plugin runs off our servers at LinksAlpha.com in order to process the social sharing analytics which helps you track virality of your content across social channels.
|
134 |
+
|
135 |
== Frequently Asked Questions ==
|
136 |
|
137 |
= My excerpts aren't displaying the buttons but some strange text is displayed =
|
183 |
|
184 |
== Upgrade Notice ==
|
185 |
|
186 |
+
= 2.2 =
|
187 |
+
* Added option to select image size available for sharing if featured image is set.
|
188 |
+
* Add new button to enable sharing on more services, including Gmail, AOL, Evernote, Hotmail, Instapaper, Mail.ru, Pocket, Sonico, vkontakte, Weibo, Yahoo Mail, and Yammer.
|
189 |
+
* Bug fixes.
|
190 |
+
|
191 |
= 2.1.4 =
|
192 |
|
193 |
Change from webstagram profile to native instagram profile, notification of author change.
|
social_sharing_toolkit.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name: Social Sharing Toolkit
|
4 |
-
Plugin URI: http://wordpress.org/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: 2.
|
7 |
-
Author: linksalpha
|
8 |
-
Author URI: http://www.linksalpha.com
|
9 |
-
*/
|
10 |
|
11 |
class MR_Social_Sharing_Toolkit {
|
12 |
var $count;
|
@@ -17,61 +17,61 @@ class MR_Social_Sharing_Toolkit {
|
|
17 |
var $follow_buttons;
|
18 |
var $error;
|
19 |
var $scripts;
|
20 |
-
|
21 |
function MR_Social_Sharing_Toolkit() {
|
22 |
-
$this->count = 0;
|
23 |
-
$this->error = '';
|
24 |
-
$this->scripts = array();
|
25 |
-
load_plugin_textdomain(
|
26 |
/* Declare button types */
|
27 |
-
$this->types['none'] = __('Button','mr_social_sharing_toolkit');
|
28 |
-
$this->types['none_text'] = __('Button + text','mr_social_sharing_toolkit');
|
29 |
-
$this->types['horizontal'] = __('Button + side counter','mr_social_sharing_toolkit');
|
30 |
-
$this->types['vertical'] = __('Button + top counter','mr_social_sharing_toolkit');
|
31 |
-
$this->types['icon_small'] = __('Small icon','mr_social_sharing_toolkit');
|
32 |
-
$this->types['icon_small_text'] = __('Small icon + text','mr_social_sharing_toolkit');
|
33 |
-
$this->types['icon_medium'] = __('Medium icon','mr_social_sharing_toolkit');
|
34 |
-
$this->types['icon_medium_text'] = __('Medium icon + text','mr_social_sharing_toolkit');
|
35 |
-
$this->types['icon_large'] = __('Large icon','mr_social_sharing_toolkit');
|
36 |
-
$buttons = glob(dirname(__FILE__).'/includes/buttons/button.*.php');
|
37 |
if (is_array($buttons) && count($buttons) > 0) {
|
38 |
foreach ($buttons as $button) {
|
39 |
-
$name = str_replace(dirname(__FILE__).'/includes/buttons/button.','',str_replace('.php',''
|
40 |
-
$class_name = 'MR_Social_Sharing_Toolkit_'.ucfirst($name);
|
41 |
if (class_exists($class_name)) {
|
42 |
-
$this->buttons[$name] = new $class_name();
|
43 |
-
if ($this->buttons[$name]->hasShare()) {
|
44 |
-
foreach ($this->buttons[$name]->getShareButtons() as $tmp) {
|
45 |
-
$this->share_buttons[$tmp['name']] = array('icon' => $this->buttons[$name]->getIcon(), 'types' => $tmp['types']);
|
46 |
-
$this->share_buttons[$tmp['name']]['title'] = (array_key_exists('title', $tmp)) ? $tmp['title'] : $this->buttons[$name]->getTitle();
|
47 |
if (array_key_exists('id', $tmp)) {
|
48 |
-
$this->share_buttons[$tmp['name']]['id'] = $tmp['id'];
|
49 |
}
|
50 |
unset($tmp);
|
51 |
}
|
52 |
}
|
53 |
-
if ($this->buttons[$name]->hasFollow()) {
|
54 |
foreach ($this->buttons[$name]->getFollowButtons() as $tmp) {
|
55 |
-
$this->follow_buttons[$tmp['name']] = array('icon' => $this->buttons[$name]->getIcon(), 'types' => $tmp['types']);
|
56 |
-
$this->follow_buttons[$tmp['name']]['title'] = (array_key_exists('title', $tmp)) ? $tmp['title'] : $this->buttons[$name]->getTitle();
|
57 |
if (array_key_exists('id', $tmp)) {
|
58 |
-
$this->follow_buttons[$tmp['name']]['id'] = $tmp['id'];
|
59 |
}
|
60 |
unset($tmp);
|
61 |
}
|
62 |
}
|
63 |
}
|
64 |
-
}
|
65 |
-
}
|
66 |
-
unset($buttons);
|
67 |
-
$this->share_buttons['ln_break_1'] = array('icon' => 'divider', 'title' => __('Divider','mr_social_sharing_toolkit').' 1', 'types' => array(''));
|
68 |
-
$this->share_buttons['ln_break_2'] = array('icon' => 'divider', 'title' => __('Divider','mr_social_sharing_toolkit').' 2', 'types' => array(''));
|
69 |
-
$this->share_buttons['ln_break_3'] = array('icon' => 'divider', 'title' => __('Divider','mr_social_sharing_toolkit').' 3', 'types' => array(''));
|
70 |
-
$this->follow_buttons['ln_break_1'] = array('icon' => 'divider', 'title' => __('Divider','mr_social_sharing_toolkit').' 1', 'types' => array(''));
|
71 |
-
$this->follow_buttons['ln_break_2'] = array('icon' => 'divider', 'title' => __('Divider','mr_social_sharing_toolkit').' 2', 'types' => array(''));
|
72 |
-
$this->follow_buttons['ln_break_3'] = array('icon' => 'divider', 'title' => __('Divider','mr_social_sharing_toolkit').' 3', 'types' => array(''));
|
73 |
/* Set defaults and load user options */
|
74 |
-
$this->get_options();
|
75 |
}
|
76 |
|
77 |
function get_options() {
|
@@ -87,135 +87,168 @@ class MR_Social_Sharing_Toolkit {
|
|
87 |
$followers[$key] = array('enable' => 0, 'type' => $val['types'][0], 'id' => '');
|
88 |
$follow_order[] = $key;
|
89 |
}
|
|
|
90 |
$pinterest_options = array('default_image' => '', 'fixed_image' => 0);
|
91 |
$bitly_options = array('enable' => 0, 'username' => '', 'key' => '', 'cache' => array());
|
92 |
$opengraph_options = array('enable' => 0, 'default_image' => '', 'fixed_image' => 0);
|
93 |
-
$this->options = array('mr_social_sharing_buttons' => $buttons,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
foreach ($this->options as $key => $val) {
|
95 |
-
$this->options[$key] = get_option(
|
96 |
}
|
97 |
-
if (!is_array($this->options['mr_social_sharing_types'])) {
|
98 |
$types = array();
|
99 |
switch ($this->options['mr_social_sharing_types']) {
|
100 |
-
case 'both':
|
101 |
-
$types[] = 'page';
|
102 |
$types[] = 'post';
|
103 |
break;
|
104 |
-
case 'pages':
|
105 |
$types[] = 'page';
|
106 |
break;
|
107 |
-
case 'posts':
|
108 |
$types[] = 'post';
|
109 |
-
break;
|
110 |
}
|
111 |
-
$this->options['mr_social_sharing_types'] = $types;
|
112 |
}
|
113 |
-
if ($this->options['mr_social_sharing_position'] == 'shortcode') {
|
114 |
-
$this->options['mr_social_sharing_position'] = 'none';
|
115 |
-
$this->options['mr_social_sharing_enable_shortcode'] = 1;
|
116 |
}
|
117 |
foreach ($this->share_buttons as $key => $val) {
|
118 |
-
if (!array_key_exists($key, $this->options['mr_social_sharing_buttons'])) {
|
119 |
-
$this->options['mr_social_sharing_buttons'][$key] = array('enable' => 0, 'type' => $val['types'][0]);
|
120 |
}
|
121 |
-
if (!array_key_exists($key, $this->options['mr_social_sharing_shortcode_buttons'])) {
|
122 |
-
$this->options['mr_social_sharing_shortcode_buttons'][$key] = array('enable' => 0, 'type' => $val['types'][0]);
|
123 |
}
|
124 |
-
if (!array_key_exists($key, $this->options['mr_social_sharing_widget_buttons'])) {
|
125 |
-
$this->options['mr_social_sharing_widget_buttons'][$key] = array('enable' => 0, 'type' => $val['types'][0]);
|
126 |
}
|
127 |
-
if (!in_array($key, $this->options['mr_social_sharing_button_order'])) {
|
128 |
-
$this->options['mr_social_sharing_button_order'][] = $key;
|
129 |
}
|
130 |
-
if (!in_array($key, $this->options['mr_social_sharing_shortcode_button_order'])) {
|
131 |
-
$this->options['mr_social_sharing_shortcode_button_order'][] = $key;
|
132 |
}
|
133 |
-
if (!in_array($key, $this->options['mr_social_sharing_widget_button_order'])) {
|
134 |
-
$this->options['mr_social_sharing_widget_button_order'][] = $key;
|
135 |
}
|
136 |
}
|
137 |
foreach ($this->follow_buttons as $key => $val) {
|
138 |
-
if (!array_key_exists($key, $this->options['mr_social_sharing_follow_buttons'])) {
|
139 |
-
$this->options['mr_social_sharing_follow_buttons'][$key] = array('enable' => 0, 'type' => $val['types'][0], 'id' => '');
|
140 |
}
|
141 |
-
if (!in_array($key, $this->options['mr_social_sharing_follow_button_order'])) {
|
142 |
-
$this->options['mr_social_sharing_follow_button_order'][] = $key;
|
143 |
}
|
144 |
}
|
145 |
-
return $this->options;
|
146 |
}
|
147 |
-
|
148 |
/* Admin functions */
|
149 |
-
|
150 |
// Simple input sanitizing to prevent script injections:
|
151 |
function sanitize_value($val) {
|
152 |
$val = str_replace('"', '', html_entity_decode($val, ENT_QUOTES));
|
153 |
$val = strtr($val, "&;<>'", ";;;;;");
|
154 |
-
return str_replace(";", "", $val);
|
155 |
}
|
156 |
-
|
157 |
function save_options($new_options) {
|
158 |
foreach ($this->options as $key => $val) {
|
159 |
if (array_key_exists($key, $new_options)) {
|
160 |
if (is_array($new_options[$key])) {
|
161 |
foreach ($new_options[$key] as $sub_key => $val) {
|
162 |
if (is_array($new_options[$key][$sub_key]) && array_key_exists('id', $new_options[$key][$sub_key])) {
|
163 |
-
$new_options[$key][$sub_key]['id'] = $this->sanitize_value($new_options[$key][$sub_key]['id']);
|
164 |
}
|
165 |
if (is_array($new_options[$key][$sub_key]) && array_key_exists('text', $new_options[$key][$sub_key])) {
|
166 |
-
$new_options[$key][$sub_key]['text'] = $this->sanitize_value($new_options[$key][$sub_key]['text']);
|
167 |
}
|
168 |
}
|
169 |
}
|
170 |
-
update_option(
|
171 |
-
$this->options[$key] = $new_options[$key]
|
172 |
} else {
|
173 |
-
update_option(
|
174 |
-
$this->options[$key] = 0;
|
175 |
}
|
176 |
}
|
177 |
// Write to custom CSS file:
|
178 |
-
if ($this->options['mr_social_sharing_custom_css'] != '') {
|
179 |
-
$upload = wp_upload_dir();
|
180 |
try {
|
181 |
-
if (!@file_put_contents($upload['basedir'].'/social_sharing_custom.css', $this->options['mr_social_sharing_custom_css'])) {
|
182 |
-
throw new Exception(__('Could not write to CSS file, to fix this create a file called "social_sharing_custom.css" in ','mr_social_sharing_toolkit')
|
183 |
}
|
184 |
} catch (Exception $e) {
|
185 |
-
$this->error = $e->getMessage();
|
186 |
}
|
187 |
}
|
188 |
}
|
189 |
-
|
190 |
function plugin_menu() {
|
191 |
add_options_page('Social Sharing', 'Social Sharing Toolkit', 'manage_options', 'mr_social_sharing', array($this, 'plugin_admin_page'));
|
192 |
-
add_filter('plugin_row_meta', array('MR_Social_Sharing_Toolkit', 'plugin_links'),10,2);
|
193 |
wp_enqueue_script('jquery-ui-tabs');
|
194 |
wp_enqueue_script('jquery-ui-sortable');
|
195 |
wp_enqueue_style('mr_social_sharing-admin', plugins_url('/admin_2.1.2.css', __FILE__));
|
196 |
wp_enqueue_script('mr_social_sharing-admin', plugins_url('/admin_2.1.2.js', __FILE__));
|
197 |
}
|
198 |
-
|
199 |
function plugin_links($links, $file) {
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
}
|
205 |
-
|
206 |
function plugin_admin_page() {
|
207 |
-
if (!current_user_can('manage_options'))
|
208 |
-
wp_die(
|
209 |
-
}
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
<div class="updated"><p><strong>'.__('Settings saved.','mr_social_sharing_toolkit').'</strong></p></div>';
|
214 |
-
|
215 |
-
|
216 |
-
<div class="error"><p><strong>'
|
217 |
-
|
218 |
-
|
219 |
echo '
|
220 |
<div class="wrap">
|
221 |
<form method="post" action="">
|
@@ -224,681 +257,802 @@ class MR_Social_Sharing_Toolkit {
|
|
224 |
|
225 |
<div id="mr_social_sharing_tabs">
|
226 |
<ul class="tabs">
|
227 |
-
<li><a href="#tab_0">'.__('General settings','mr_social_sharing_toolkit').'</a><li>
|
228 |
-
<li><a href="#tab_1">'.__('Content','mr_social_sharing_toolkit').'</a><li>
|
229 |
-
<li><a href="#tab_2">'.__('Shortcode','mr_social_sharing_toolkit').'</a><li>
|
230 |
-
<li><a href="#tab_3">'.__('Share Widget','mr_social_sharing_toolkit').'</a><li>
|
231 |
-
<li><a href="#tab_4">'.__('Follow Widget','mr_social_sharing_toolkit').'</a><li>
|
232 |
-
<li><a href="#tab_5">'.__('Advanced settings','mr_social_sharing_toolkit').'</a><li>
|
233 |
-
<li><a href="#tab_6">'.__('Custom CSS','mr_social_sharing_toolkit').'</a><li>
|
234 |
</ul>
|
235 |
<div id="tab_0" class="mr_social_sharing_networks">
|
236 |
-
<h3>'.__('General settings','mr_social_sharing_toolkit').':</h3>
|
237 |
<label for="mr_social_sharing_js_footer" class="check"><input type="checkbox" name="mr_social_sharing_js_footer" id="mr_social_sharing_js_footer"';
|
238 |
-
if ($this->options['mr_social_sharing_js_footer'] == 1) { echo ' checked="checked"';
|
239 |
-
|
|
|
240 |
|
241 |
<p>
|
242 |
-
<span class="description"> '.__('Improves performance but may not work on some themes','mr_social_sharing_toolkit').'</span>
|
243 |
</p>
|
244 |
<p>
|
245 |
-
'.__('Choose where the buttons must be displayed and if the buttons should be displayed on posts, pages or both.','mr_social_sharing_toolkit').'
|
246 |
</p>
|
247 |
-
<label for="mr_social_sharing_position">'.__('Button location','mr_social_sharing_toolkit').'</label>
|
248 |
<select name="mr_social_sharing_position" id="mr_social_sharing_position">
|
249 |
<option value="none"';
|
250 |
-
if ($this->options['mr_social_sharing_position'] == 'none') { echo ' selected="selected"';
|
251 |
-
|
|
|
252 |
<option value="top"';
|
253 |
-
if ($this->options['mr_social_sharing_position'] == 'top') { echo ' selected="selected"';
|
254 |
-
|
|
|
255 |
<option value="bottom"';
|
256 |
-
if ($this->options['mr_social_sharing_position'] == 'bottom') { echo ' selected="selected"';
|
257 |
-
|
|
|
258 |
<option value="both"';
|
259 |
-
if ($this->options['mr_social_sharing_position'] == 'both') { echo ' selected="selected"';
|
260 |
-
|
|
|
261 |
</select><br/><br/>
|
262 |
-
<label for="mr_social_sharing_types">'.__('Place buttons on','mr_social_sharing_toolkit').'</label><br/>';
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
<br/>
|
277 |
<input type="hidden" name="mr_social_sharing_enable_shortcode" value="1" />
|
278 |
-
<p><span class="description"> '.__('Use the shortcode [social_share/] where you want the buttons to appear', 'mr_social_sharing_toolkit').'</span></p>
|
279 |
<label for="mr_social_sharing_include_excerpts" class="check"><input type="checkbox" name="mr_social_sharing_include_excerpts" id="mr_social_sharing_include_excerpts"';
|
280 |
-
if ($this->options['mr_social_sharing_include_excerpts'] == 1) { echo ' checked="checked"';
|
281 |
-
|
282 |
-
|
|
|
283 |
<label for="mr_social_sharing_no_follow" class="check"><input type="checkbox" name="mr_social_sharing_no_follow" id="mr_social_sharing_no_follow"';
|
284 |
-
if ($this->options['mr_social_sharing_no_follow'] == 1) { echo ' checked="checked"';
|
285 |
-
|
|
|
286 |
</div>
|
287 |
<div id="tab_1" class="mr_social_sharing_networks">
|
288 |
-
<h3>'.__('Content','mr_social_sharing_toolkit').'</h3>
|
289 |
<p>
|
290 |
-
'.__('Check the boxes to display the button on your website. For each button you can select a separate style from the dropdown box. You can change the order of the buttons by dragging them to the desired location in the list. For the tweet button you can also fill in your Twitter username which will then be appended to the tweet (like via @WordPress).','mr_social_sharing_toolkit').'
|
291 |
</p>';
|
292 |
-
$this->showListAdmin($this->share_buttons);
|
293 |
echo '
|
294 |
</div>
|
295 |
<div id="tab_2" class="mr_social_sharing_networks">
|
296 |
-
<h3>'.__('Shortcode','mr_social_sharing_toolkit').'</h3>
|
297 |
<p>
|
298 |
-
'.__('Check the boxes to display the button on your website. For each button you can select a separate style from the dropdown box. You can change the order of the buttons by dragging them to the desired location in the list. For the tweet button you can also fill in your Twitter username which will then be appended to the tweet (like via @WordPress).','mr_social_sharing_toolkit').'
|
299 |
</p>';
|
300 |
-
$this->showListAdmin($this->share_buttons, 'shortcode_');
|
301 |
echo '
|
302 |
</div>
|
303 |
<div id="tab_3" class="mr_social_sharing_networks">
|
304 |
-
<h3>'.__('Share Widget','mr_social_sharing_toolkit').'</h3>
|
305 |
<p>
|
306 |
-
'.__('Check the boxes to display the button on Social Sharing Toolkit Share widget. For each button you can select a separate style from the dropdown box. You can change the order of the buttons by dragging them to the desired location in the list. For the tweet button you can also fill in your Twitter username which will then be appended to the tweet (like via @WordPress).','mr_social_sharing_toolkit').'
|
307 |
<br/><br/>
|
308 |
-
'.__('For each widget you can enter a fixed url and title for the buttons, to do this','mr_social_sharing_toolkit').' <a href="widgets.php">'.__('go to the widget configuration page','mr_social_sharing_toolkit').'</a>.
|
309 |
-
</p>';
|
310 |
-
$this->showListAdmin($this->share_buttons, 'widget_');
|
311 |
echo '
|
312 |
</div>
|
313 |
<div id="tab_4" class="mr_social_sharing_networks">
|
314 |
-
<h3>'.__('Follow Widget','mr_social_sharing_toolkit').'</h3>
|
315 |
<p>
|
316 |
-
'.__('Check the boxes to display the button on Social Sharing Toolkit Follow widget. For each button you can select a separate style from the dropdown box. You can change the order of the buttons by dragging them to the desired location in the list.','mr_social_sharing_toolkit').'
|
317 |
<br/><br/>
|
318 |
-
'.__('For each button you only have to enter your id or username of the network as it appears in the url of your profile page. You will need to enter the complete url for the RSS Feed (including the http:// part) if you wish to display this button.','mr_social_sharing_toolkit').'
|
319 |
<br/>
|
320 |
<br/>
|
321 |
-
'.__('To add the widget to your website','mr_social_sharing_toolkit').' <a href="widgets.php">'.__('go to the widget configuration page','mr_social_sharing_toolkit').'</a>.
|
322 |
</p>';
|
323 |
-
$this->showListAdmin($this->follow_buttons, 'follow_');
|
324 |
echo '
|
325 |
<label for="mr_social_sharing_follow_new" class="check"><input type="checkbox" name="mr_social_sharing_follow_new" id="mr_social_sharing_follow_new"';
|
326 |
-
if ($this->options['mr_social_sharing_follow_new'] == 1) { echo ' checked="checked"';
|
327 |
-
|
|
|
328 |
</div>
|
329 |
<div id="tab_5" class="mr_social_sharing_networks">
|
330 |
-
<h3>'.__('Advanced settings','mr_social_sharing_toolkit').'</h3>
|
331 |
-
<h4>'.__('Automatic Twitter links','mr_social_sharing_toolkit').'</h4>
|
332 |
-
<p>'.__('Select what you want to convert:','mr_social_sharing_toolkit').'</p>
|
333 |
<label for="mr_social_sharing_twitter_handles" class="check"><input type="checkbox" name="mr_social_sharing_twitter_handles" id="mr_social_sharing_twitter_handles"';
|
334 |
-
if ($this->options['mr_social_sharing_twitter_handles'] == 1) { echo ' checked="checked"';
|
335 |
-
|
|
|
336 |
<label for="mr_social_sharing_twitter_hashtags" class="check"><input type="checkbox" name="mr_social_sharing_twitter_hashtags" id="mr_social_sharing_twitter_hashtags"';
|
337 |
-
if ($this->options['mr_social_sharing_twitter_hashtags'] == 1) { echo ' checked="checked"';
|
338 |
-
|
339 |
-
|
|
|
340 |
<label for="mr_social_sharing_linkify_content" class="check"><input type="checkbox" name="mr_social_sharing_linkify_content" id="mr_social_sharing_linkify_content"';
|
341 |
-
if ($this->options['mr_social_sharing_linkify_content'] == 1) { echo ' checked="checked"';
|
342 |
-
|
|
|
343 |
<label for="mr_social_sharing_linkify_comments" class="check"><input type="checkbox" name="mr_social_sharing_linkify_comments" id="mr_social_sharing_linkify_comments"';
|
344 |
-
if ($this->options['mr_social_sharing_linkify_comments'] == 1) { echo ' checked="checked"';
|
345 |
-
|
|
|
346 |
<label for="mr_social_sharing_linkify_new" class="check"><input type="checkbox" name="mr_social_sharing_linkify_new" id="mr_social_sharing_linkify_new"';
|
347 |
-
if ($this->options['mr_social_sharing_linkify_new'] == 1) { echo ' checked="checked"';
|
348 |
-
|
349 |
-
|
350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
<label for="mr_social_sharing_bitly_enable" class="check"><input type="checkbox" name="mr_social_sharing_bitly[enable]" id="mr_social_sharing_bitly_enable"';
|
352 |
-
if ($this->options['mr_social_sharing_bitly']['enable'] == 1) { echo ' checked="checked"';
|
353 |
-
|
354 |
-
|
355 |
-
<
|
356 |
-
<
|
357 |
-
<
|
358 |
-
<
|
359 |
-
<
|
360 |
-
<
|
361 |
-
<
|
|
|
362 |
<label for="mr_social_sharing_pinterest_fixed_image" class="check"><input type="checkbox" name="mr_social_sharing_pinterest[fixed_image]" id="mr_social_sharing_pinterest_fixed_image"';
|
363 |
-
if ($this->options['mr_social_sharing_pinterest']['fixed_image'] == 1) { echo ' checked="checked"';
|
364 |
-
|
365 |
-
|
366 |
-
<
|
367 |
-
<
|
|
|
368 |
<label for="mr_social_sharing_opengraph_enable" class="check"><input type="checkbox" name="mr_social_sharing_opengraph[enable]" id="mr_social_sharing_opengraph_enable"';
|
369 |
-
if ($this->options['mr_social_sharing_opengraph']['enable'] == 1) { echo ' checked="checked"';
|
370 |
-
|
371 |
-
|
372 |
-
<
|
373 |
-
<
|
|
|
374 |
<label for="mr_social_sharing_opengraph_fixed_image" class="check"><input type="checkbox" name="mr_social_sharing_opengraph[fixed_image]" id="mr_social_sharing_opengraph_fixed_image"';
|
375 |
-
if ($this->options['mr_social_sharing_opengraph']['fixed_image'] == 1) { echo ' checked="checked"';
|
376 |
-
|
377 |
-
|
|
|
378 |
</div>
|
379 |
<div id="tab_6" class="mr_social_sharing_networks">
|
380 |
-
<h3>'.__('Custom CSS','mr_social_sharing_toolkit').'</h3>
|
381 |
-
<p>'.__('Enter your custom styles or CSS fixes here','mr_social_sharing_toolkit').'</p>
|
382 |
-
<textarea name="mr_social_sharing_custom_css" id="mr_social_sharing_custom_css">'
|
383 |
</div>
|
384 |
</div>
|
385 |
<p class="submit">
|
386 |
-
<input type="submit" name="Submit" class="button-primary" value="'.esc_attr__('Save Changes').'" />
|
387 |
</p>
|
388 |
-
<div class="mr_social_sharing_networks">
|
389 |
-
<h3>'.__('Thank you for using the Social Sharing Toolkit!','mr_social_sharing_toolkit').'</h3>
|
390 |
-
<p>
|
391 |
-
Version 2.1.4 is the last version I have personally updated and supported. From now on, further development and support will be provided by LinksAlpha.
|
392 |
-
</p>
|
393 |
-
<p>
|
394 |
-
The last years I have been amazed at how well received this plugin has been. Sadly, I find myself unable to effectively combine further development and, more importantly, support with my other obligations. This is why I agreed to transfer further development and support to LinksAlpha. I fully expect that the current quality of the plugin will be maintained and improved under the care of LinksAlpha.
|
395 |
-
</p>
|
396 |
-
<p style="font-style: italic;">
|
397 |
-
~ Marijn Rongen, Active-Bits - July 2013
|
398 |
-
</p>
|
399 |
-
</div>
|
400 |
</form>
|
401 |
</div>';
|
402 |
}
|
403 |
-
|
404 |
function showListAdmin($buttons, $button_type = '') {
|
405 |
echo '
|
406 |
-
<ul id="mr_social_sharing_'
|
407 |
foreach ($this->options['mr_social_sharing_'.$button_type.'button_order'] as $button) {
|
408 |
if (array_key_exists($button, $buttons)) {
|
409 |
echo '
|
410 |
<li>
|
411 |
-
<span class="mr_social_sharing_options"><img src="'.plugins_url('/images/icons_small/'
|
412 |
-
<label for="mr_social_sharing_'
|
413 |
-
if ($this->options['mr_social_sharing_'
|
414 |
-
|
415 |
-
|
|
|
|
|
|
|
|
|
416 |
if (is_array($buttons[$button]['types']) && $buttons[$button]['types'][0] != '') {
|
417 |
if (count($buttons[$button]['types']) == 1) {
|
418 |
echo '
|
419 |
-
<input type="hidden" name="mr_social_sharing_'
|
420 |
} else {
|
421 |
echo '
|
422 |
-
<select name="mr_social_sharing_'
|
423 |
foreach ($buttons[$button]['types'] as $type) {
|
424 |
-
echo '<option value="'
|
425 |
-
if ($this->options['mr_social_sharing_'
|
426 |
-
|
|
|
427 |
}
|
428 |
echo '</select>';
|
429 |
}
|
430 |
} else {
|
431 |
echo '
|
432 |
-
<input type="hidden" name="mr_social_sharing_'
|
433 |
}
|
434 |
if (array_key_exists('id', $buttons[$button])) {
|
435 |
if (is_array($buttons[$button]['id']) && array_key_exists('label', $buttons[$button]['id']) && array_key_exists('options', $buttons[$button]['id']) && is_array($buttons[$button]['id']['options'])) {
|
436 |
echo '
|
437 |
-
<select name="mr_social_sharing_'
|
438 |
foreach ($buttons[$button]['id']['options'] as $option) {
|
439 |
if (array_key_exists('label', $option) && array_key_exists('value', $option)) {
|
440 |
-
echo '<option value="'
|
441 |
-
if ($option['value'] == $this->options['mr_social_sharing_'
|
442 |
echo ' selected="selected"';
|
443 |
}
|
444 |
-
echo '>'
|
445 |
}
|
446 |
}
|
447 |
echo '</select>';
|
448 |
} else {
|
449 |
echo '
|
450 |
-
<input type="text" class="text" name="mr_social_sharing_'
|
451 |
-
<label for="mr_social_sharing_'
|
452 |
}
|
453 |
}
|
454 |
echo '
|
455 |
-
<input type="hidden" name="mr_social_sharing_'
|
456 |
-
<span class="mr_social_sharing_custom"><input type="text" class="text" name="mr_social_sharing_'
|
457 |
-
<label for="mr_social_sharing_'
|
458 |
|
459 |
-
<input type="text" class="text" name="mr_social_sharing_'
|
460 |
-
<label for="mr_social_sharing_'
|
461 |
|
462 |
|
463 |
</li>';
|
464 |
}
|
465 |
-
}
|
466 |
echo '
|
467 |
</ul>
|
468 |
<p>
|
469 |
-
'.__('Choose button orientation horizontal to display the buttons side by side, vertical will place them below each other. You can also select an alignment to better suit your theme.','mr_social_sharing_toolkit').'
|
470 |
</p>
|
471 |
-
<label for="mr_social_sharing_'
|
472 |
-
<select name="mr_social_sharing_'
|
473 |
<option value="span"';
|
474 |
-
if ($this->options['mr_social_sharing_'
|
475 |
-
|
|
|
476 |
<option value="div"';
|
477 |
-
if ($this->options['mr_social_sharing_'
|
478 |
-
|
|
|
479 |
</select><br/>
|
480 |
-
<label for="mr_social_sharing_'
|
481 |
-
<select name="mr_social_sharing_'
|
482 |
<option value=""';
|
483 |
-
if ($this->options['mr_social_sharing_'
|
484 |
-
|
|
|
485 |
<option value="_top"';
|
486 |
-
if ($this->options['mr_social_sharing_'
|
487 |
-
|
488 |
-
|
|
|
489 |
}
|
490 |
-
|
491 |
/* Output functions */
|
492 |
-
|
493 |
function print_opengraph() {
|
494 |
echo '<!-- Open Graph tags provided by Social Sharing Toolkit v2.1.2 -->
|
495 |
-
<meta property="og:locale" content="'.str_replace('-', '_', get_bloginfo('language')).'"/>';
|
496 |
if (is_single() || is_page()) {
|
497 |
$excerpt = get_the_excerpt();
|
498 |
echo '
|
499 |
-
<meta property="og:title" content="'.trim(wp_title('', 0)).'"/>';
|
500 |
if ($excerpt != '') {
|
501 |
echo '
|
502 |
-
<meta property="og:description" content="'
|
503 |
} else {
|
504 |
echo '
|
505 |
-
<meta property="og:description" content="'.get_bloginfo('description').'"/>';
|
506 |
}
|
507 |
echo '
|
508 |
-
<meta property="og:url" content="'.get_permalink().'"/>
|
509 |
<meta property="og:type" content="article"/>';
|
510 |
} else {
|
511 |
echo '
|
512 |
-
<meta property="og:title" content="'.get_bloginfo('name').'"/>
|
513 |
-
<meta property="og:description" content="'.get_bloginfo('description').'"/>
|
514 |
-
<meta property="og:url" content="'.get_home_url().'"/>
|
515 |
<meta property="og:type" content="website"/>';
|
516 |
-
}
|
517 |
echo '
|
518 |
-
<meta property="og:site_name" content="'.get_bloginfo('name').'"/>';
|
519 |
-
if ($this->options['mr_social_sharing_opengraph']['fixed_image']) {
|
520 |
-
if ($this->options['mr_social_sharing_opengraph']['default_image'] != '') {
|
521 |
echo '
|
522 |
-
<meta property="og:image" content="'
|
523 |
}
|
524 |
} else {
|
525 |
$media = '';
|
526 |
if (current_theme_supports('post-thumbnails')) {
|
527 |
-
if
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
$media = '';
|
532 |
-
}
|
533 |
}
|
534 |
-
|
|
|
|
|
|
|
|
|
|
|
535 |
if ($media == '') {
|
536 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_content(), $matches);
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
|
|
|
|
541 |
}
|
542 |
if ($media != '') {
|
543 |
echo '
|
544 |
-
|
545 |
-
} elseif ($this->options['mr_social_sharing_opengraph']['default_image'] != '') {
|
546 |
echo '
|
547 |
-
|
548 |
}
|
549 |
}
|
550 |
-
}
|
551 |
-
|
552 |
function prepare_styles() {
|
553 |
wp_enqueue_style('mr_social_sharing', plugins_url('/style_2.1.2.css', __FILE__));
|
554 |
$upload = wp_upload_dir();
|
555 |
-
if (file_exists($upload['basedir'].'/social_sharing_custom.css') && $this->options['mr_social_sharing_custom_css'] != '') {
|
556 |
-
wp_enqueue_style('mr_social_sharing_custom', $upload['baseurl'].'/social_sharing_custom.css');
|
557 |
-
}
|
558 |
}
|
559 |
-
|
560 |
function prepare_scripts() {
|
561 |
-
if ($this->options['mr_social_sharing_no_follow'] == 1) {
|
562 |
-
if ($this->options['mr_social_sharing_js_footer'] == 1) {
|
563 |
wp_enqueue_script('mr_social_sharing', plugins_url('/script_no_follow_2.1.2.js', __FILE__), array('jquery'), false, true);
|
564 |
} else {
|
565 |
wp_enqueue_script('mr_social_sharing', plugins_url('/script_no_follow_2.1.2.js', __FILE__), array('jquery'));
|
566 |
}
|
567 |
} else {
|
568 |
-
if ($this->options['mr_social_sharing_js_footer'] == 1) {
|
569 |
wp_enqueue_script('mr_social_sharing', plugins_url('/script_2.1.2.js', __FILE__), array('jquery'), false, true);
|
570 |
} else {
|
571 |
wp_enqueue_script('mr_social_sharing', plugins_url('/script_2.1.2.js', __FILE__), array('jquery'));
|
572 |
}
|
573 |
}
|
574 |
-
$this->load_scripts();
|
575 |
-
if (is_array($this->scripts) && count($this->scripts) > 0) {
|
576 |
foreach ($this->scripts as $script) {
|
577 |
wp_enqueue_script($script['name'], $script['src'], array(), false, $script['in_footer']);
|
578 |
-
}
|
579 |
}
|
580 |
-
}
|
581 |
-
|
582 |
function load_scripts() {
|
583 |
$types = array('', 'shortcode_', 'widget_');
|
584 |
foreach ($types as $type) {
|
585 |
foreach ($this->options['mr_social_sharing_'.$type.'button_order'] as $button) {
|
586 |
-
if ($this->options['mr_social_sharing_'
|
587 |
-
$id = (array_key_exists('id', $this->options['mr_social_sharing_'
|
588 |
-
$text = (array_key_exists('text', $this->options['mr_social_sharing_'
|
589 |
-
$icon = (array_key_exists('icon', $this->options['mr_social_sharing_'
|
590 |
foreach ($this->buttons as $tmp) {
|
591 |
-
if (method_exists($tmp, $button)) {
|
592 |
-
$tmp
|
593 |
-
if (is_array($tmp->get_enqueued_scripts())) {
|
594 |
-
$this->scripts = array_merge($this->scripts, $tmp->get_enqueued_scripts());
|
595 |
}
|
596 |
}
|
597 |
}
|
598 |
}
|
599 |
}
|
600 |
-
}
|
601 |
foreach ($this->options['mr_social_sharing_follow_button_order'] as $button) {
|
602 |
-
if ($this->options['mr_social_sharing_follow_buttons'][$button]['enable'] == 1) {
|
603 |
-
$id = (array_key_exists('id', $this->options['mr_social_sharing_follow_buttons'][$button])) ? $this->options['mr_social_sharing_follow_buttons'][$button]['id'] : '';
|
604 |
-
$text = (array_key_exists('text', $this->options['mr_social_sharing_follow_buttons'][$button])) ? stripslashes($this->options['mr_social_sharing_follow_buttons'][$button]['text']) : '';
|
605 |
-
$icon = (array_key_exists('icon', $this->options['mr_social_sharing_follow_buttons'][$button])) ? $this->options['mr_social_sharing_follow_buttons'][$button]['icon'] : '';
|
606 |
foreach ($this->buttons as $tmp) {
|
607 |
-
if (method_exists($tmp, $button)) {
|
608 |
-
$tmp
|
609 |
-
if (is_array($tmp->get_enqueued_scripts())) {
|
610 |
-
$this->scripts = array_merge($this->scripts, $tmp->get_enqueued_scripts());
|
611 |
}
|
612 |
}
|
613 |
-
}
|
614 |
}
|
615 |
}
|
616 |
-
}
|
617 |
-
|
618 |
function create_bookmarks($url = '', $title = '', $type = '', $media = '', $description = '') {
|
619 |
$url = trim($url);
|
620 |
$title = trim($title);
|
621 |
-
$title =
|
|
|
|
|
|
|
622 |
if ($url == '') {
|
623 |
-
$url = 'http://'
|
624 |
}
|
|
|
625 |
$bookmarks = '
|
626 |
<div class="mr_social_sharing_wrapper">
|
627 |
-
<!-- Social Sharing Toolkit v2.
|
628 |
foreach ($this->options['mr_social_sharing_'.$type.'button_order'] as $button) {
|
629 |
-
if ($this->options['mr_social_sharing_'
|
630 |
-
$id = (array_key_exists('id', $this->options['mr_social_sharing_'
|
631 |
-
$text = (array_key_exists('text', $this->options['mr_social_sharing_'
|
632 |
-
$icon = (array_key_exists('icon', $this->options['mr_social_sharing_'
|
633 |
-
$bookmarks .= $this->get_bookmark_button($button, $url, $title, $this->options['mr_social_sharing_'
|
|
|
634 |
}
|
635 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
636 |
$bookmarks .= '</div>';
|
637 |
$bookmarks = str_replace('<div class="mr_social_sharing_wrapper"></div>', '', $bookmarks);
|
638 |
-
$this->count++;
|
639 |
-
return $bookmarks;
|
640 |
}
|
641 |
-
|
642 |
function create_followers() {
|
643 |
$followers = '
|
644 |
<div class="mr_social_sharing_wrapper">
|
645 |
-
<!-- Social Sharing Toolkit v2.
|
646 |
foreach ($this->options['mr_social_sharing_follow_button_order'] as $button) {
|
647 |
-
if ($this->options['mr_social_sharing_follow_buttons'][$button]['
|
648 |
-
$id = (array_key_exists('id', $this->options['mr_social_sharing_follow_buttons'][$button])) ? $this->options['mr_social_sharing_follow_buttons'][$button]['id'] : '';
|
649 |
-
$text = (array_key_exists('text', $this->options['mr_social_sharing_follow_buttons'][$button])) ? stripslashes($this->options['mr_social_sharing_follow_buttons'][$button]['text']) : '';
|
650 |
-
$icon = (array_key_exists('icon', $this->options['mr_social_sharing_follow_buttons'][$button])) ? $this->options['mr_social_sharing_follow_buttons'][$button]['icon'] : '';
|
651 |
-
$followers .= $this->get_follow_button($button, $this->options['mr_social_sharing_follow_buttons'][$button]['type'], $this->options['mr_social_sharing_follow_display'], $this->options['mr_social_sharing_follow_align'], $id, $text, $icon);
|
652 |
}
|
653 |
-
}
|
654 |
$followers .= '</div>';
|
655 |
$followers = str_replace('<div class="mr_social_sharing_wrapper"></div>', '', $followers);
|
656 |
return $followers;
|
657 |
}
|
658 |
-
|
659 |
function get_bookmark_button($button, $url, $title, $type, $display = 'span', $align = '', $id = '', $media = '', $description = '', $text = '', $icon = '') {
|
660 |
$retval = '';
|
661 |
if ($button == 'ln_break_1' || $button == 'ln_break_2' || $button == 'ln_break_3') {
|
662 |
$retval = '</div><div class="mr_social_sharing_wrapper">';
|
663 |
} else {
|
664 |
foreach ($this->buttons as $tmp) {
|
665 |
-
if (method_exists($tmp, $button)) {
|
666 |
-
$retval = '<'
|
667 |
}
|
668 |
}
|
669 |
}
|
670 |
return $retval;
|
671 |
}
|
672 |
-
|
673 |
function get_follow_button($button, $type, $display = 'span', $align = '', $id = '', $text = '', $icon = '') {
|
674 |
$retval = '';
|
675 |
if ($button == 'ln_break_1' || $button == 'ln_break_2' || $button == 'ln_break_3') {
|
676 |
$retval = '</div><div class="mr_social_sharing_wrapper">';
|
677 |
} else {
|
678 |
foreach ($this->buttons as $tmp) {
|
679 |
-
if (method_exists($tmp, $button)) {
|
680 |
-
$retval = '<'
|
681 |
-
}
|
682 |
}
|
683 |
}
|
684 |
return $retval;
|
685 |
}
|
686 |
-
|
687 |
function should_print_opengraph() {
|
688 |
-
if ($this->options['mr_social_sharing_opengraph']['enable'] == 1) {
|
689 |
return true;
|
690 |
}
|
691 |
}
|
692 |
-
|
693 |
function should_share_content() {
|
694 |
-
if ($this->options['mr_social_sharing_position'] != 'none') {
|
695 |
return true;
|
696 |
}
|
697 |
-
return false;
|
698 |
}
|
699 |
-
|
700 |
function should_share_excerpt() {
|
701 |
-
if ($this->options['mr_social_sharing_position'] != 'none' && $this->options['mr_social_sharing_include_excerpts'] == 1) {
|
702 |
return true;
|
703 |
}
|
704 |
-
return false;
|
705 |
}
|
706 |
-
|
707 |
function share($content) {
|
708 |
if (is_feed()) {
|
709 |
return $content;
|
710 |
} else {
|
711 |
$media = '';
|
712 |
-
if ($this->options['mr_social_sharing_pinterest']['default_image'] != '' && $this->options['mr_social_sharing_pinterest']['fixed_image'] == 1) {
|
713 |
-
$media = $this->options['mr_social_sharing_pinterest']['default_image'];
|
714 |
} else {
|
715 |
if (current_theme_supports('post-thumbnails')) {
|
716 |
-
if
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
$media = '';
|
721 |
-
}
|
722 |
}
|
723 |
-
|
|
|
|
|
|
|
|
|
|
|
724 |
if ($media == '') {
|
725 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
|
|
|
|
730 |
}
|
731 |
-
if ($media == '' && $this->options['mr_social_sharing_pinterest']['default_image'] != '') {
|
732 |
-
$media = $this->options['mr_social_sharing_pinterest']['default_image'];
|
733 |
}
|
734 |
}
|
735 |
$type = get_post_type();
|
736 |
-
if (in_array($type, $this->options['mr_social_sharing_types']) && ((is_single() || $this->options['mr_social_sharing_include_excerpts'] == 1) || $type == 'page')) {
|
737 |
-
if ($this->options['mr_social_sharing_position'] == 'top') {
|
738 |
-
$bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false), '', $media,
|
739 |
-
$content = $bookmarks
|
740 |
}
|
741 |
-
if ($this->options['mr_social_sharing_position'] == 'bottom') {
|
742 |
-
$bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false), '', $media,
|
743 |
$content .= $bookmarks;
|
744 |
}
|
745 |
-
if ($this->options['mr_social_sharing_position'] == 'both') {
|
746 |
-
$bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false), '', $media,
|
747 |
-
$
|
|
|
748 |
}
|
749 |
}
|
750 |
return $content;
|
751 |
}
|
752 |
}
|
753 |
-
|
754 |
function share_excerpt($content) {
|
755 |
if (is_feed()) {
|
756 |
return $content;
|
757 |
} else {
|
758 |
$media = '';
|
759 |
-
if ($this->options['mr_social_sharing_pinterest']['default_image'] != '' && $this->options['mr_social_sharing_pinterest']['fixed_image'] == 1) {
|
760 |
-
$media = $this->options['mr_social_sharing_pinterest']['default_image'];
|
761 |
} else {
|
762 |
if (current_theme_supports('post-thumbnails')) {
|
763 |
-
if
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
|
|
|
|
|
|
769 |
}
|
770 |
-
}
|
771 |
if ($media == '') {
|
772 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
|
|
|
|
777 |
}
|
778 |
-
if ($media == '' && $this->options['mr_social_sharing_pinterest']['default_image'] != '') {
|
779 |
-
$media = $this->options['mr_social_sharing_pinterest']['default_image'];
|
780 |
}
|
781 |
}
|
782 |
$type = get_post_type();
|
783 |
-
if (in_array($type, $this->options['mr_social_sharing_types'])) {
|
784 |
-
if ($this->options['mr_social_sharing_position'] == 'top') {
|
785 |
-
$bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false), '', $media,
|
786 |
-
$content = $bookmarks
|
787 |
}
|
788 |
-
if ($this->options['mr_social_sharing_position'] == 'bottom') {
|
789 |
-
$bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false), '', $media,
|
790 |
$content .= $bookmarks;
|
791 |
}
|
792 |
-
if ($this->options['mr_social_sharing_position'] == 'both') {
|
793 |
-
$bookmarks = $this->create_bookmarks(get_permalink(), the_title('','',false), '', $media,
|
794 |
-
$content = $bookmarks
|
795 |
}
|
796 |
}
|
797 |
return $content;
|
798 |
}
|
799 |
}
|
800 |
-
|
801 |
function share_shortcode($atts) {
|
802 |
-
extract(
|
803 |
-
'url' => '',
|
804 |
-
'title' => ''
|
805 |
-
), $atts ) );
|
806 |
if (is_feed()) {
|
807 |
return '';
|
808 |
} else {
|
809 |
$media = '';
|
810 |
-
if ($this->options['mr_social_sharing_pinterest']['default_image'] != '' && $this->options['mr_social_sharing_pinterest']['fixed_image'] == 1) {
|
811 |
-
$media = $this->options['mr_social_sharing_pinterest']['default_image'];
|
812 |
} else {
|
813 |
if (current_theme_supports('post-thumbnails')) {
|
814 |
-
if
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
$media = '';
|
819 |
-
}
|
820 |
}
|
821 |
-
|
|
|
|
|
|
|
|
|
|
|
822 |
if ($media == '') {
|
823 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_content(), $matches);
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
|
|
|
|
828 |
}
|
829 |
-
if ($media == '' && $this->options['mr_social_sharing_pinterest']['default_image'] != '') {
|
830 |
-
$media = $this->options['mr_social_sharing_pinterest']['default_image'];
|
831 |
}
|
832 |
}
|
833 |
$type = get_post_type();
|
834 |
-
$bookmarks = '';
|
835 |
-
if ((is_single() || $type == 'page') || $this->options['mr_social_sharing_include_excerpts'] == 1) {
|
836 |
$url = ($url == '') ? get_permalink() : $url;
|
837 |
-
$title = ($title == '') ? the_title('','',false) : $title;
|
838 |
-
$bookmarks = $this->create_bookmarks($url, $title, 'shortcode_', $media,
|
839 |
}
|
840 |
return $bookmarks;
|
841 |
}
|
842 |
}
|
843 |
-
|
844 |
function should_linkify_content() {
|
845 |
-
if ($this->options['mr_social_sharing_linkify_content'] == 1) {
|
846 |
return true;
|
847 |
}
|
848 |
return false;
|
849 |
}
|
850 |
-
|
851 |
function should_linkify_comments() {
|
852 |
-
if ($this->options['mr_social_sharing_linkify_comments'] == 1) {
|
853 |
return true;
|
854 |
}
|
855 |
return false;
|
856 |
}
|
857 |
-
|
858 |
function linkify($content) {
|
859 |
-
if ($this->options['mr_social_sharing_linkify_new'] == 1) {
|
860 |
-
if ($this->options['mr_social_sharing_twitter_handles'] == 1) {
|
861 |
$content = preg_replace("/(^|\s)+(@([a-zA-Z0-9_-]{1,15}))(\.*[^|\n|\r|\t|\s|\<|\&]*)/i", "$1<a href=\"http://twitter.com/$3\" target=\"_BLANK\">$2</a>$4", $content);
|
862 |
}
|
863 |
-
if ($this->options['mr_social_sharing_twitter_hashtags'] == 1) {
|
864 |
$content = preg_replace("/(^|\s)+((?:(?<!&))#([a-zA-Z0-9]+^[-|;]))([^|\n|\r|\t|\s|\.|\<|\&]*)/i", "$1<a href=\"http://twitter.com/search/$3\" target=\"_BLANK\">$2</a>$4", $content);
|
865 |
}
|
866 |
} else {
|
867 |
-
if ($this->options['mr_social_sharing_twitter_handles'] == 1) {
|
868 |
$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);
|
869 |
}
|
870 |
-
if ($this->options['mr_social_sharing_twitter_hashtags'] == 1) {
|
871 |
$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);
|
872 |
}
|
873 |
}
|
874 |
return $content;
|
875 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
876 |
}
|
|
|
877 |
require 'includes/class.button.php';
|
878 |
-
$buttons = glob(dirname(__FILE__).'/includes/buttons/button.*.php');
|
879 |
if (is_array($buttons) && count($buttons) > 0) {
|
880 |
foreach ($buttons as $button) {
|
881 |
-
include
|
882 |
-
}
|
883 |
}
|
884 |
unset($buttons);
|
885 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
886 |
|
887 |
$MR_Social_Sharing_Toolkit = new MR_Social_Sharing_Toolkit();
|
888 |
add_action('admin_menu', array($MR_Social_Sharing_Toolkit, 'plugin_menu'));
|
889 |
-
if ($MR_Social_Sharing_Toolkit->should_print_opengraph()) {
|
890 |
add_action('wp_head', array($MR_Social_Sharing_Toolkit, 'print_opengraph'), 1);
|
891 |
}
|
892 |
-
if ($MR_Social_Sharing_Toolkit->should_linkify_content()) {
|
893 |
add_filter('the_content', array($MR_Social_Sharing_Toolkit, 'linkify'));
|
894 |
}
|
895 |
-
if ($MR_Social_Sharing_Toolkit->should_linkify_comments()) {
|
896 |
add_filter('comment_text', array($MR_Social_Sharing_Toolkit, 'linkify'));
|
897 |
}
|
898 |
-
if ($MR_Social_Sharing_Toolkit->should_share_excerpt()) {
|
899 |
add_filter('the_excerpt', array($MR_Social_Sharing_Toolkit, 'share_excerpt'));
|
900 |
}
|
901 |
-
if ($MR_Social_Sharing_Toolkit->should_share_content()) {
|
902 |
add_filter('the_content', array($MR_Social_Sharing_Toolkit, 'share'));
|
903 |
}
|
904 |
add_shortcode('social_share', array($MR_Social_Sharing_Toolkit, 'share_shortcode'), 15);
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Social Sharing Toolkit
|
4 |
+
Plugin URI: http://wordpress.org/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: 2.2
|
7 |
+
Author: linksalpha
|
8 |
+
Author URI: http://www.linksalpha.com
|
9 |
+
*/
|
10 |
|
11 |
class MR_Social_Sharing_Toolkit {
|
12 |
var $count;
|
17 |
var $follow_buttons;
|
18 |
var $error;
|
19 |
var $scripts;
|
20 |
+
|
21 |
function MR_Social_Sharing_Toolkit() {
|
22 |
+
$this -> count = 0;
|
23 |
+
$this -> error = '';
|
24 |
+
$this -> scripts = array();
|
25 |
+
load_plugin_textdomain('mr_social_sharing_toolkit', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
26 |
/* Declare button types */
|
27 |
+
$this -> types['none'] = __('Button', 'mr_social_sharing_toolkit');
|
28 |
+
$this -> types['none_text'] = __('Button + text', 'mr_social_sharing_toolkit');
|
29 |
+
$this -> types['horizontal'] = __('Button + side counter', 'mr_social_sharing_toolkit');
|
30 |
+
$this -> types['vertical'] = __('Button + top counter', 'mr_social_sharing_toolkit');
|
31 |
+
$this -> types['icon_small'] = __('Small icon', 'mr_social_sharing_toolkit');
|
32 |
+
$this -> types['icon_small_text'] = __('Small icon + text', 'mr_social_sharing_toolkit');
|
33 |
+
$this -> types['icon_medium'] = __('Medium icon', 'mr_social_sharing_toolkit');
|
34 |
+
$this -> types['icon_medium_text'] = __('Medium icon + text', 'mr_social_sharing_toolkit');
|
35 |
+
$this -> types['icon_large'] = __('Large icon', 'mr_social_sharing_toolkit');
|
36 |
+
$buttons = glob(dirname(__FILE__) . '/includes/buttons/button.*.php');
|
37 |
if (is_array($buttons) && count($buttons) > 0) {
|
38 |
foreach ($buttons as $button) {
|
39 |
+
$name = str_replace(dirname(__FILE__) . '/includes/buttons/button.', '', str_replace('.php', '', $button));
|
40 |
+
$class_name = 'MR_Social_Sharing_Toolkit_' . ucfirst($name);
|
41 |
if (class_exists($class_name)) {
|
42 |
+
$this -> buttons[$name] = new $class_name();
|
43 |
+
if ($this -> buttons[$name] -> hasShare()) {
|
44 |
+
foreach ($this->buttons[$name]->getShareButtons() as $tmp) {
|
45 |
+
$this -> share_buttons[$tmp['name']] = array('icon' => $this -> buttons[$name] -> getIcon(), 'types' => $tmp['types']);
|
46 |
+
$this -> share_buttons[$tmp['name']]['title'] = (array_key_exists('title', $tmp)) ? $tmp['title'] : $this -> buttons[$name] -> getTitle();
|
47 |
if (array_key_exists('id', $tmp)) {
|
48 |
+
$this -> share_buttons[$tmp['name']]['id'] = $tmp['id'];
|
49 |
}
|
50 |
unset($tmp);
|
51 |
}
|
52 |
}
|
53 |
+
if ($this -> buttons[$name] -> hasFollow()) {
|
54 |
foreach ($this->buttons[$name]->getFollowButtons() as $tmp) {
|
55 |
+
$this -> follow_buttons[$tmp['name']] = array('icon' => $this -> buttons[$name] -> getIcon(), 'types' => $tmp['types']);
|
56 |
+
$this -> follow_buttons[$tmp['name']]['title'] = (array_key_exists('title', $tmp)) ? $tmp['title'] : $this -> buttons[$name] -> getTitle();
|
57 |
if (array_key_exists('id', $tmp)) {
|
58 |
+
$this -> follow_buttons[$tmp['name']]['id'] = $tmp['id'];
|
59 |
}
|
60 |
unset($tmp);
|
61 |
}
|
62 |
}
|
63 |
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
unset($buttons);
|
67 |
+
$this -> share_buttons['ln_break_1'] = array('icon' => 'divider', 'title' => __('Divider', 'mr_social_sharing_toolkit') . ' 1', 'types' => array(''));
|
68 |
+
$this -> share_buttons['ln_break_2'] = array('icon' => 'divider', 'title' => __('Divider', 'mr_social_sharing_toolkit') . ' 2', 'types' => array(''));
|
69 |
+
$this -> share_buttons['ln_break_3'] = array('icon' => 'divider', 'title' => __('Divider', 'mr_social_sharing_toolkit') . ' 3', 'types' => array(''));
|
70 |
+
$this -> follow_buttons['ln_break_1'] = array('icon' => 'divider', 'title' => __('Divider', 'mr_social_sharing_toolkit') . ' 1', 'types' => array(''));
|
71 |
+
$this -> follow_buttons['ln_break_2'] = array('icon' => 'divider', 'title' => __('Divider', 'mr_social_sharing_toolkit') . ' 2', 'types' => array(''));
|
72 |
+
$this -> follow_buttons['ln_break_3'] = array('icon' => 'divider', 'title' => __('Divider', 'mr_social_sharing_toolkit') . ' 3', 'types' => array(''));
|
73 |
/* Set defaults and load user options */
|
74 |
+
$this -> get_options();
|
75 |
}
|
76 |
|
77 |
function get_options() {
|
87 |
$followers[$key] = array('enable' => 0, 'type' => $val['types'][0], 'id' => '');
|
88 |
$follow_order[] = $key;
|
89 |
}
|
90 |
+
$attachment_image_size_options = array('default_size' => 'medium');
|
91 |
$pinterest_options = array('default_image' => '', 'fixed_image' => 0);
|
92 |
$bitly_options = array('enable' => 0, 'username' => '', 'key' => '', 'cache' => array());
|
93 |
$opengraph_options = array('enable' => 0, 'default_image' => '', 'fixed_image' => 0);
|
94 |
+
$this -> options = array('mr_social_sharing_buttons' => $buttons,
|
95 |
+
'mr_social_sharing_shortcode_buttons' => $shortcodes,
|
96 |
+
'mr_social_sharing_widget_buttons' => $widgets,
|
97 |
+
'mr_social_sharing_follow_buttons' => $followers,
|
98 |
+
'mr_social_sharing_display' => 'span',
|
99 |
+
'mr_social_sharing_shortcode_display' => 'span',
|
100 |
+
'mr_social_sharing_widget_display' => 'span',
|
101 |
+
'mr_social_sharing_follow_display' => 'span',
|
102 |
+
'mr_social_sharing_align' => '',
|
103 |
+
'mr_social_sharing_shortcode_align' => '',
|
104 |
+
'mr_social_sharing_widget_align' => '',
|
105 |
+
'mr_social_sharing_follow_align' => '',
|
106 |
+
'mr_social_sharing_position' => 'none',
|
107 |
+
'mr_social_sharing_types' => array('post', 'page'),
|
108 |
+
'mr_social_sharing_enable_shortcode' => 1,
|
109 |
+
'mr_social_sharing_include_excerpts' => 1,
|
110 |
+
'mr_social_sharing_button_order' => $button_order,
|
111 |
+
'mr_social_sharing_shortcode_button_order' => $shortcode_order,
|
112 |
+
'mr_social_sharing_widget_button_order' => $widget_order,
|
113 |
+
'mr_social_sharing_follow_button_order' => $follow_order,
|
114 |
+
'mr_social_sharing_linkify_content' => 0,
|
115 |
+
'mr_social_sharing_linkify_comments' => 0,
|
116 |
+
'mr_social_sharing_linkify_new' => 1,
|
117 |
+
'mr_social_sharing_follow_new' => 1,
|
118 |
+
'mr_social_sharing_twitter_handles' => 0,
|
119 |
+
'mr_social_sharing_twitter_hashtags' => 0,
|
120 |
+
'mr_social_sharing_js_footer' => 1,
|
121 |
+
'mr_social_sharing_no_follow' => 0,
|
122 |
+
'mr_social_sharing_attachment_image_size' => $attachment_image_size_options,
|
123 |
+
'mr_social_sharing_pinterest' => $pinterest_options,
|
124 |
+
'mr_social_sharing_bitly' => $bitly_options,
|
125 |
+
'mr_social_sharing_opengraph' => $opengraph_options,
|
126 |
+
'mr_social_sharing_custom_css' => '');
|
127 |
foreach ($this->options as $key => $val) {
|
128 |
+
$this -> options[$key] = get_option($key, $val);
|
129 |
}
|
130 |
+
if (!is_array($this -> options['mr_social_sharing_types'])) {
|
131 |
$types = array();
|
132 |
switch ($this->options['mr_social_sharing_types']) {
|
133 |
+
case 'both' :
|
134 |
+
$types[] = 'page';
|
135 |
$types[] = 'post';
|
136 |
break;
|
137 |
+
case 'pages' :
|
138 |
$types[] = 'page';
|
139 |
break;
|
140 |
+
case 'posts' :
|
141 |
$types[] = 'post';
|
142 |
+
break;
|
143 |
}
|
144 |
+
$this -> options['mr_social_sharing_types'] = $types;
|
145 |
}
|
146 |
+
if ($this -> options['mr_social_sharing_position'] == 'shortcode') {
|
147 |
+
$this -> options['mr_social_sharing_position'] = 'none';
|
148 |
+
$this -> options['mr_social_sharing_enable_shortcode'] = 1;
|
149 |
}
|
150 |
foreach ($this->share_buttons as $key => $val) {
|
151 |
+
if (!array_key_exists($key, $this -> options['mr_social_sharing_buttons'])) {
|
152 |
+
$this -> options['mr_social_sharing_buttons'][$key] = array('enable' => 0, 'type' => $val['types'][0]);
|
153 |
}
|
154 |
+
if (!array_key_exists($key, $this -> options['mr_social_sharing_shortcode_buttons'])) {
|
155 |
+
$this -> options['mr_social_sharing_shortcode_buttons'][$key] = array('enable' => 0, 'type' => $val['types'][0]);
|
156 |
}
|
157 |
+
if (!array_key_exists($key, $this -> options['mr_social_sharing_widget_buttons'])) {
|
158 |
+
$this -> options['mr_social_sharing_widget_buttons'][$key] = array('enable' => 0, 'type' => $val['types'][0]);
|
159 |
}
|
160 |
+
if (!in_array($key, $this -> options['mr_social_sharing_button_order'])) {
|
161 |
+
$this -> options['mr_social_sharing_button_order'][] = $key;
|
162 |
}
|
163 |
+
if (!in_array($key, $this -> options['mr_social_sharing_shortcode_button_order'])) {
|
164 |
+
$this -> options['mr_social_sharing_shortcode_button_order'][] = $key;
|
165 |
}
|
166 |
+
if (!in_array($key, $this -> options['mr_social_sharing_widget_button_order'])) {
|
167 |
+
$this -> options['mr_social_sharing_widget_button_order'][] = $key;
|
168 |
}
|
169 |
}
|
170 |
foreach ($this->follow_buttons as $key => $val) {
|
171 |
+
if (!array_key_exists($key, $this -> options['mr_social_sharing_follow_buttons'])) {
|
172 |
+
$this -> options['mr_social_sharing_follow_buttons'][$key] = array('enable' => 0, 'type' => $val['types'][0], 'id' => '');
|
173 |
}
|
174 |
+
if (!in_array($key, $this -> options['mr_social_sharing_follow_button_order'])) {
|
175 |
+
$this -> options['mr_social_sharing_follow_button_order'][] = $key;
|
176 |
}
|
177 |
}
|
178 |
+
return $this -> options;
|
179 |
}
|
180 |
+
|
181 |
/* Admin functions */
|
182 |
+
|
183 |
// Simple input sanitizing to prevent script injections:
|
184 |
function sanitize_value($val) {
|
185 |
$val = str_replace('"', '', html_entity_decode($val, ENT_QUOTES));
|
186 |
$val = strtr($val, "&;<>'", ";;;;;");
|
187 |
+
return str_replace(";", "", $val);
|
188 |
}
|
189 |
+
|
190 |
function save_options($new_options) {
|
191 |
foreach ($this->options as $key => $val) {
|
192 |
if (array_key_exists($key, $new_options)) {
|
193 |
if (is_array($new_options[$key])) {
|
194 |
foreach ($new_options[$key] as $sub_key => $val) {
|
195 |
if (is_array($new_options[$key][$sub_key]) && array_key_exists('id', $new_options[$key][$sub_key])) {
|
196 |
+
$new_options[$key][$sub_key]['id'] = $this -> sanitize_value($new_options[$key][$sub_key]['id']);
|
197 |
}
|
198 |
if (is_array($new_options[$key][$sub_key]) && array_key_exists('text', $new_options[$key][$sub_key])) {
|
199 |
+
$new_options[$key][$sub_key]['text'] = $this -> sanitize_value($new_options[$key][$sub_key]['text']);
|
200 |
}
|
201 |
}
|
202 |
}
|
203 |
+
update_option($key, $new_options[$key]);
|
204 |
+
$this -> options[$key] = $new_options[$key];
|
205 |
} else {
|
206 |
+
update_option($key, 0);
|
207 |
+
$this -> options[$key] = 0;
|
208 |
}
|
209 |
}
|
210 |
// Write to custom CSS file:
|
211 |
+
if ($this -> options['mr_social_sharing_custom_css'] != '') {
|
212 |
+
$upload = wp_upload_dir();
|
213 |
try {
|
214 |
+
if (!@file_put_contents($upload['basedir'] . '/social_sharing_custom.css', $this -> options['mr_social_sharing_custom_css'])) {
|
215 |
+
throw new Exception(__('Could not write to CSS file, to fix this create a file called "social_sharing_custom.css" in ', 'mr_social_sharing_toolkit') . $upload['basedir'] . __('. Make sure the file has read and write permissions.', 'mr_social_sharing_toolkit'));
|
216 |
}
|
217 |
} catch (Exception $e) {
|
218 |
+
$this -> error = $e -> getMessage();
|
219 |
}
|
220 |
}
|
221 |
}
|
222 |
+
|
223 |
function plugin_menu() {
|
224 |
add_options_page('Social Sharing', 'Social Sharing Toolkit', 'manage_options', 'mr_social_sharing', array($this, 'plugin_admin_page'));
|
225 |
+
add_filter('plugin_row_meta', array('MR_Social_Sharing_Toolkit', 'plugin_links'), 10, 2);
|
226 |
wp_enqueue_script('jquery-ui-tabs');
|
227 |
wp_enqueue_script('jquery-ui-sortable');
|
228 |
wp_enqueue_style('mr_social_sharing-admin', plugins_url('/admin_2.1.2.css', __FILE__));
|
229 |
wp_enqueue_script('mr_social_sharing-admin', plugins_url('/admin_2.1.2.js', __FILE__));
|
230 |
}
|
231 |
+
|
232 |
function plugin_links($links, $file) {
|
233 |
+
if ($file == plugin_basename(__FILE__)) {
|
234 |
+
$links[] = '<a href="/wp-admin/options-general.php?page=mr_social_sharing">' . __('Settings') . '</a>';
|
235 |
+
}
|
236 |
+
return $links;
|
237 |
+
}
|
238 |
+
|
239 |
function plugin_admin_page() {
|
240 |
+
if (!current_user_can('manage_options')) {
|
241 |
+
wp_die(__('You do not have sufficient permissions to access this page.'));
|
242 |
+
}
|
243 |
+
if (isset($_POST['mr_social_sharing_save_options']) && $_POST['mr_social_sharing_save_options'] == 'Y') {
|
244 |
+
$this -> save_options($_POST);
|
245 |
+
echo '
|
246 |
+
<div class="updated"><p><strong>' . __('Settings saved.', 'mr_social_sharing_toolkit') . '</strong></p></div>';
|
247 |
+
if ($this -> error != '') {
|
248 |
+
echo '
|
249 |
+
<div class="error"><p><strong>' . $this -> error . '</strong></p></div>';
|
250 |
+
}
|
251 |
+
}
|
252 |
echo '
|
253 |
<div class="wrap">
|
254 |
<form method="post" action="">
|
257 |
|
258 |
<div id="mr_social_sharing_tabs">
|
259 |
<ul class="tabs">
|
260 |
+
<li><a href="#tab_0">' . __('General settings', 'mr_social_sharing_toolkit') . '</a><li>
|
261 |
+
<li><a href="#tab_1">' . __('Content', 'mr_social_sharing_toolkit') . '</a><li>
|
262 |
+
<li><a href="#tab_2">' . __('Shortcode', 'mr_social_sharing_toolkit') . '</a><li>
|
263 |
+
<li><a href="#tab_3">' . __('Share Widget', 'mr_social_sharing_toolkit') . '</a><li>
|
264 |
+
<li><a href="#tab_4">' . __('Follow Widget', 'mr_social_sharing_toolkit') . '</a><li>
|
265 |
+
<li><a href="#tab_5">' . __('Advanced settings', 'mr_social_sharing_toolkit') . '</a><li>
|
266 |
+
<li><a href="#tab_6">' . __('Custom CSS', 'mr_social_sharing_toolkit') . '</a><li>
|
267 |
</ul>
|
268 |
<div id="tab_0" class="mr_social_sharing_networks">
|
269 |
+
<h3>' . __('General settings', 'mr_social_sharing_toolkit') . ':</h3>
|
270 |
<label for="mr_social_sharing_js_footer" class="check"><input type="checkbox" name="mr_social_sharing_js_footer" id="mr_social_sharing_js_footer"';
|
271 |
+
if ($this -> options['mr_social_sharing_js_footer'] == 1) { echo ' checked="checked"';
|
272 |
+
}
|
273 |
+
echo ' value="1" /> ' . __('Load JavaScript in footer', 'mr_social_sharing_toolkit') . '</label>
|
274 |
|
275 |
<p>
|
276 |
+
<span class="description"> ' . __('Improves performance but may not work on some themes', 'mr_social_sharing_toolkit') . '</span>
|
277 |
</p>
|
278 |
<p>
|
279 |
+
' . __('Choose where the buttons must be displayed and if the buttons should be displayed on posts, pages or both.', 'mr_social_sharing_toolkit') . '
|
280 |
</p>
|
281 |
+
<label for="mr_social_sharing_position">' . __('Button location', 'mr_social_sharing_toolkit') . '</label>
|
282 |
<select name="mr_social_sharing_position" id="mr_social_sharing_position">
|
283 |
<option value="none"';
|
284 |
+
if ($this -> options['mr_social_sharing_position'] == 'none') { echo ' selected="selected"';
|
285 |
+
}
|
286 |
+
echo '>' . __('Do not display', 'mr_social_sharing_toolkit') . '</option>
|
287 |
<option value="top"';
|
288 |
+
if ($this -> options['mr_social_sharing_position'] == 'top') { echo ' selected="selected"';
|
289 |
+
}
|
290 |
+
echo '>' . __('Display before content', 'mr_social_sharing_toolkit') . '</option>
|
291 |
<option value="bottom"';
|
292 |
+
if ($this -> options['mr_social_sharing_position'] == 'bottom') { echo ' selected="selected"';
|
293 |
+
}
|
294 |
+
echo '>' . __('Display after content', 'mr_social_sharing_toolkit') . '</option>
|
295 |
<option value="both"';
|
296 |
+
if ($this -> options['mr_social_sharing_position'] == 'both') { echo ' selected="selected"';
|
297 |
+
}
|
298 |
+
echo '>' . __('Display before and after content', 'mr_social_sharing_toolkit') . '</option>
|
299 |
</select><br/><br/>
|
300 |
+
<label for="mr_social_sharing_types">' . __('Place buttons on', 'mr_social_sharing_toolkit') . '</label><br/>';
|
301 |
+
$types = get_post_types();
|
302 |
+
if (is_array($types) && count($types) > 0) {
|
303 |
+
foreach ($types as $type) {
|
304 |
+
if (!in_array($type, array('attachment', 'revision', 'nav_menu_item'))) {
|
305 |
+
echo '<label for="share_type_' . $type . '"><input type="checkbox" id="share_type_' . $type . '" name="mr_social_sharing_types[]" value="' . $type . '"';
|
306 |
+
if (is_array($this -> options['mr_social_sharing_types']) && in_array($type, $this -> options['mr_social_sharing_types'])) {
|
307 |
+
echo ' checked="checked"';
|
308 |
+
}
|
309 |
+
echo '/> ' . ucfirst(__($type)) . '</label><br/>';
|
310 |
+
}
|
311 |
+
}
|
312 |
+
}
|
313 |
+
echo '
|
314 |
<br/>
|
315 |
<input type="hidden" name="mr_social_sharing_enable_shortcode" value="1" />
|
316 |
+
<p><span class="description"> ' . __('Use the shortcode [social_share/] where you want the buttons to appear', 'mr_social_sharing_toolkit') . '</span></p>
|
317 |
<label for="mr_social_sharing_include_excerpts" class="check"><input type="checkbox" name="mr_social_sharing_include_excerpts" id="mr_social_sharing_include_excerpts"';
|
318 |
+
if ($this -> options['mr_social_sharing_include_excerpts'] == 1) { echo ' checked="checked"';
|
319 |
+
}
|
320 |
+
echo ' value="1" /> ' . __('Include buttons in excerpts', 'mr_social_sharing_toolkit') . '</label>
|
321 |
+
<p><span class="description">' . __('Uncheck this box if you are having issues displaying the buttons with excerpts (some themes have custom excerpt functions which do not play nice with the plugin).', 'mr_social_sharing_toolkit') . '</p>
|
322 |
<label for="mr_social_sharing_no_follow" class="check"><input type="checkbox" name="mr_social_sharing_no_follow" id="mr_social_sharing_no_follow"';
|
323 |
+
if ($this -> options['mr_social_sharing_no_follow'] == 1) { echo ' checked="checked"';
|
324 |
+
}
|
325 |
+
echo ' value="1" /> ' . __('Use rel="nofollow" on links to social networks', 'mr_social_sharing_toolkit') . '</label>
|
326 |
</div>
|
327 |
<div id="tab_1" class="mr_social_sharing_networks">
|
328 |
+
<h3>' . __('Content', 'mr_social_sharing_toolkit') . '</h3>
|
329 |
<p>
|
330 |
+
' . __('Check the boxes to display the button on your website. For each button you can select a separate style from the dropdown box. You can change the order of the buttons by dragging them to the desired location in the list. For the tweet button you can also fill in your Twitter username which will then be appended to the tweet (like via @WordPress).', 'mr_social_sharing_toolkit') . '
|
331 |
</p>';
|
332 |
+
$this -> showListAdmin($this -> share_buttons);
|
333 |
echo '
|
334 |
</div>
|
335 |
<div id="tab_2" class="mr_social_sharing_networks">
|
336 |
+
<h3>' . __('Shortcode', 'mr_social_sharing_toolkit') . '</h3>
|
337 |
<p>
|
338 |
+
' . __('Check the boxes to display the button on your website. For each button you can select a separate style from the dropdown box. You can change the order of the buttons by dragging them to the desired location in the list. For the tweet button you can also fill in your Twitter username which will then be appended to the tweet (like via @WordPress).', 'mr_social_sharing_toolkit') . '
|
339 |
</p>';
|
340 |
+
$this -> showListAdmin($this -> share_buttons, 'shortcode_');
|
341 |
echo '
|
342 |
</div>
|
343 |
<div id="tab_3" class="mr_social_sharing_networks">
|
344 |
+
<h3>' . __('Share Widget', 'mr_social_sharing_toolkit') . '</h3>
|
345 |
<p>
|
346 |
+
' . __('Check the boxes to display the button on Social Sharing Toolkit Share widget. For each button you can select a separate style from the dropdown box. You can change the order of the buttons by dragging them to the desired location in the list. For the tweet button you can also fill in your Twitter username which will then be appended to the tweet (like via @WordPress).', 'mr_social_sharing_toolkit') . '
|
347 |
<br/><br/>
|
348 |
+
' . __('For each widget you can enter a fixed url and title for the buttons, to do this', 'mr_social_sharing_toolkit') . ' <a href="widgets.php">' . __('go to the widget configuration page', 'mr_social_sharing_toolkit') . '</a>.
|
349 |
+
</p>';
|
350 |
+
$this -> showListAdmin($this -> share_buttons, 'widget_');
|
351 |
echo '
|
352 |
</div>
|
353 |
<div id="tab_4" class="mr_social_sharing_networks">
|
354 |
+
<h3>' . __('Follow Widget', 'mr_social_sharing_toolkit') . '</h3>
|
355 |
<p>
|
356 |
+
' . __('Check the boxes to display the button on Social Sharing Toolkit Follow widget. For each button you can select a separate style from the dropdown box. You can change the order of the buttons by dragging them to the desired location in the list.', 'mr_social_sharing_toolkit') . '
|
357 |
<br/><br/>
|
358 |
+
' . __('For each button you only have to enter your id or username of the network as it appears in the url of your profile page. You will need to enter the complete url for the RSS Feed (including the http:// part) if you wish to display this button.', 'mr_social_sharing_toolkit') . '
|
359 |
<br/>
|
360 |
<br/>
|
361 |
+
' . __('To add the widget to your website', 'mr_social_sharing_toolkit') . ' <a href="widgets.php">' . __('go to the widget configuration page', 'mr_social_sharing_toolkit') . '</a>.
|
362 |
</p>';
|
363 |
+
$this -> showListAdmin($this -> follow_buttons, 'follow_');
|
364 |
echo '
|
365 |
<label for="mr_social_sharing_follow_new" class="check"><input type="checkbox" name="mr_social_sharing_follow_new" id="mr_social_sharing_follow_new"';
|
366 |
+
if ($this -> options['mr_social_sharing_follow_new'] == 1) { echo ' checked="checked"';
|
367 |
+
}
|
368 |
+
echo ' value="1" /> ' . __("Open links in new window or tab", 'mr_social_sharing_toolkit') . '</label>
|
369 |
</div>
|
370 |
<div id="tab_5" class="mr_social_sharing_networks">
|
371 |
+
<h3>' . __('Advanced settings', 'mr_social_sharing_toolkit') . '</h3>
|
372 |
+
<h4>' . __('Automatic Twitter links', 'mr_social_sharing_toolkit') . '</h4>
|
373 |
+
<p>' . __('Select what you want to convert:', 'mr_social_sharing_toolkit') . '</p>
|
374 |
<label for="mr_social_sharing_twitter_handles" class="check"><input type="checkbox" name="mr_social_sharing_twitter_handles" id="mr_social_sharing_twitter_handles"';
|
375 |
+
if ($this -> options['mr_social_sharing_twitter_handles'] == 1) { echo ' checked="checked"';
|
376 |
+
}
|
377 |
+
echo ' value="1" /> ' . __("Convert Twitter usernames", 'mr_social_sharing_toolkit') . '</label><br/>
|
378 |
<label for="mr_social_sharing_twitter_hashtags" class="check"><input type="checkbox" name="mr_social_sharing_twitter_hashtags" id="mr_social_sharing_twitter_hashtags"';
|
379 |
+
if ($this -> options['mr_social_sharing_twitter_hashtags'] == 1) { echo ' checked="checked"';
|
380 |
+
}
|
381 |
+
echo ' value="1" /> ' . __("Convert hashtags", 'mr_social_sharing_toolkit') . '</label>
|
382 |
+
<p>' . __('And where it should be converted:', 'mr_social_sharing_toolkit') . '</p>
|
383 |
<label for="mr_social_sharing_linkify_content" class="check"><input type="checkbox" name="mr_social_sharing_linkify_content" id="mr_social_sharing_linkify_content"';
|
384 |
+
if ($this -> options['mr_social_sharing_linkify_content'] == 1) { echo ' checked="checked"';
|
385 |
+
}
|
386 |
+
echo ' value="1" /> ' . __("Convert in posts and pages", 'mr_social_sharing_toolkit') . '</label><br/>
|
387 |
<label for="mr_social_sharing_linkify_comments" class="check"><input type="checkbox" name="mr_social_sharing_linkify_comments" id="mr_social_sharing_linkify_comments"';
|
388 |
+
if ($this -> options['mr_social_sharing_linkify_comments'] == 1) { echo ' checked="checked"';
|
389 |
+
}
|
390 |
+
echo ' value="1" /> ' . __("Convert in comments", 'mr_social_sharing_toolkit') . '</label><br/>
|
391 |
<label for="mr_social_sharing_linkify_new" class="check"><input type="checkbox" name="mr_social_sharing_linkify_new" id="mr_social_sharing_linkify_new"';
|
392 |
+
if ($this -> options['mr_social_sharing_linkify_new'] == 1) { echo ' checked="checked"';
|
393 |
+
}
|
394 |
+
echo ' value="1" /> ' . __("Open links in new window or tab", 'mr_social_sharing_toolkit') . '</label>';
|
395 |
+
|
396 |
+
// Image Size
|
397 |
+
echo '<h4>' . __('Image Size', 'mr_social_sharing_toolkit') . '</h4>
|
398 |
+
<p>' . __('Select the image size to be used while sharing', 'mr_social_sharing_toolkit') . '</p>
|
399 |
+
<label for="mr_social_sharing_attachment_image_size_enable"><select name="mr_social_sharing_attachment_image_size" id="mr_social_sharing_attachment_image_size_enable">';
|
400 |
+
echo '<option value="thumbnail"';
|
401 |
+
if ($this -> options['mr_social_sharing_attachment_image_size'] == 'thumbnail') { echo ' selected="selected"';}
|
402 |
+
echo '>' . __('Thumbnail', 'mr_social_sharing_toolkit') . '</option>
|
403 |
+
<option value="medium"';
|
404 |
+
if ($this -> options['mr_social_sharing_attachment_image_size'] == 'medium') { echo ' selected="selected"';}
|
405 |
+
echo '>' . __('Medium', 'mr_social_sharing_toolkit') . '</option>
|
406 |
+
<option value="large"';
|
407 |
+
if ($this -> options['mr_social_sharing_attachment_image_size'] == 'large') { echo ' selected="selected"';}
|
408 |
+
echo '>' . __('Large', 'mr_social_sharing_toolkit') . '</option>
|
409 |
+
<option value="full"';
|
410 |
+
if ($this -> options['mr_social_sharing_attachment_image_size'] == 'full') { echo ' selected="selected"';}
|
411 |
+
echo '>' . __('Full', 'mr_social_sharing_toolkit') . '</option>
|
412 |
+
</select></label><br/><br/>';
|
413 |
+
|
414 |
+
// Bitly
|
415 |
+
echo '<h4>' . __('Bitly', 'mr_social_sharing_toolkit') . '</h4>
|
416 |
+
<p>' . __('Use Bitly url shortening for the tweet button', 'mr_social_sharing_toolkit') . '</p>
|
417 |
<label for="mr_social_sharing_bitly_enable" class="check"><input type="checkbox" name="mr_social_sharing_bitly[enable]" id="mr_social_sharing_bitly_enable"';
|
418 |
+
if (isset($this -> options['mr_social_sharing_bitly']['enable']) && $this -> options['mr_social_sharing_bitly']['enable'] == 1) { echo ' checked="checked"';
|
419 |
+
}
|
420 |
+
echo ' value="1" /> ' . __("Enable Bitly URL shortening", 'mr_social_sharing_toolkit') . '</label></br/>
|
421 |
+
<label for="mr_social_sharing_bitly_username">' . __('Your bitly Username', 'mr_social_sharing_toolkit') . '</label>
|
422 |
+
<input type="text" name="mr_social_sharing_bitly[username]" id="mr_social_sharing_bitly_username" value="' . $this -> options['mr_social_sharing_bitly']['username'] . '"/></br/>
|
423 |
+
<label for="mr_social_sharing_bitly_key">' . __('Your bitly API Key', 'mr_social_sharing_toolkit') . '</label>
|
424 |
+
<input type="password" name="mr_social_sharing_bitly[key]" id="mr_social_sharing_bitly_key" value="' . $this -> options['mr_social_sharing_bitly']['key'] . '"/>
|
425 |
+
<h4>' . __('Pinterest', 'mr_social_sharing_toolkit') . '</h4>
|
426 |
+
<label for="mr_social_sharing_pinterest_default_image">' . __('Default image URL', 'mr_social_sharing_toolkit') . '</label>
|
427 |
+
<input type="text" name="mr_social_sharing_pinterest[default_image]" id="mr_social_sharing_pinterest_default_image" value="' . $this -> options['mr_social_sharing_pinterest']['default_image'] . '"/></br/>
|
428 |
+
<p><span class="description">' . __('You can specify a link to an image you would like to use for Pinterest pins when no image is available', 'mr_social_sharing_toolkit') . '</span></p>
|
429 |
<label for="mr_social_sharing_pinterest_fixed_image" class="check"><input type="checkbox" name="mr_social_sharing_pinterest[fixed_image]" id="mr_social_sharing_pinterest_fixed_image"';
|
430 |
+
if (isset($this -> options['mr_social_sharing_pinterest']['fixed_image']) && $this -> options['mr_social_sharing_pinterest']['fixed_image'] == 1) { echo ' checked="checked"';
|
431 |
+
}
|
432 |
+
echo ' value="1" /> ' . __("Always use the default image", 'mr_social_sharing_toolkit') . '</label><br/>
|
433 |
+
<p><span class="description">' . __("Check this box to always display the default image with your Pins", 'mr_social_sharing_toolkit') . '</span></p>
|
434 |
+
<h4>' . __('OpenGraph', 'mr_social_sharing_toolkit') . '</h4>
|
435 |
+
<p>' . __('Include Open Graph tags', 'mr_social_sharing_toolkit') . '</p>
|
436 |
<label for="mr_social_sharing_opengraph_enable" class="check"><input type="checkbox" name="mr_social_sharing_opengraph[enable]" id="mr_social_sharing_opengraph_enable"';
|
437 |
+
if (isset($this -> options['mr_social_sharing_opengraph']['enable']) && $this -> options['mr_social_sharing_opengraph']['enable'] == 1) { echo ' checked="checked"';
|
438 |
+
}
|
439 |
+
echo ' value="1" /> ' . __("Enable Open Graph", 'mr_social_sharing_toolkit') . '</label><br/>
|
440 |
+
<label for="mr_social_sharing_opengraph_default_image">' . __('Default image URL', 'mr_social_sharing_toolkit') . '</label>
|
441 |
+
<input type="text" name="mr_social_sharing_opengraph[default_image]" id="mr_social_sharing_opengraph_default_image" value="' . $this -> options['mr_social_sharing_opengraph']['default_image'] . '"/></br/>
|
442 |
+
<p><span class="description">' . __('You can specify a link to an image you would like to include in your likes and shares', 'mr_social_sharing_toolkit') . '</span></p>
|
443 |
<label for="mr_social_sharing_opengraph_fixed_image" class="check"><input type="checkbox" name="mr_social_sharing_opengraph[fixed_image]" id="mr_social_sharing_opengraph_fixed_image"';
|
444 |
+
if (isset($this -> options['mr_social_sharing_opengraph']['fixed_image']) && $this -> options['mr_social_sharing_opengraph']['fixed_image'] == 1) { echo ' checked="checked"';
|
445 |
+
}
|
446 |
+
echo ' value="1" /> ' . __("Always use the default image", 'mr_social_sharing_toolkit') . '</label><br/>
|
447 |
+
<p><span class="description">' . __("Check this box to always display the default image with your shared content", 'mr_social_sharing_toolkit') . '</span></p>
|
448 |
</div>
|
449 |
<div id="tab_6" class="mr_social_sharing_networks">
|
450 |
+
<h3>' . __('Custom CSS', 'mr_social_sharing_toolkit') . '</h3>
|
451 |
+
<p>' . __('Enter your custom styles or CSS fixes here', 'mr_social_sharing_toolkit') . '</p>
|
452 |
+
<textarea name="mr_social_sharing_custom_css" id="mr_social_sharing_custom_css">' . $this -> options['mr_social_sharing_custom_css'] . '</textarea>
|
453 |
</div>
|
454 |
</div>
|
455 |
<p class="submit">
|
456 |
+
<input type="submit" name="Submit" class="button-primary" value="' . esc_attr__('Save Changes') . '" />
|
457 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
</form>
|
459 |
</div>';
|
460 |
}
|
461 |
+
|
462 |
function showListAdmin($buttons, $button_type = '') {
|
463 |
echo '
|
464 |
+
<ul id="mr_social_sharing_' . $button_type . 'networks">';
|
465 |
foreach ($this->options['mr_social_sharing_'.$button_type.'button_order'] as $button) {
|
466 |
if (array_key_exists($button, $buttons)) {
|
467 |
echo '
|
468 |
<li>
|
469 |
+
<span class="mr_social_sharing_options"><img src="' . plugins_url('/images/icons_small/' . $buttons[$button]['icon'] . '.png', __FILE__) . '" title="' . $buttons[$button]['title'] . '" alt="' . $buttons[$button]['title'] . '"/>
|
470 |
+
<label for="mr_social_sharing_' . $button_type . $button . '"><input type="checkbox" name="mr_social_sharing_' . $button_type . 'buttons[' . $button . '][enable]" id="mr_social_sharing_' . $button_type . $button . '"';
|
471 |
+
if (isset($this -> options['mr_social_sharing_' . $button_type . 'buttons'][$button]['enable']) && $this -> options['mr_social_sharing_' . $button_type . 'buttons'][$button]['enable'] == 1) { echo ' checked="checked"';
|
472 |
+
}
|
473 |
+
if ($button == 'linksalpha') {
|
474 |
+
echo ' checked="checked" disabled="disabled"';
|
475 |
+
}
|
476 |
+
echo ' value="1" />' . $buttons[$button]['title'] . '</label>
|
477 |
+
<img class="right" src="' . plugins_url('/images/move.png', __FILE__) . '" title="' . __('Change button order', 'mr_social_sharing_toolkit') . '" alt="' . __('Change button order', 'mr_social_sharing_toolkit') . '"/>';
|
478 |
if (is_array($buttons[$button]['types']) && $buttons[$button]['types'][0] != '') {
|
479 |
if (count($buttons[$button]['types']) == 1) {
|
480 |
echo '
|
481 |
+
<input type="hidden" name="mr_social_sharing_' . $button_type . 'buttons[' . $button . '][type]" value="' . $buttons[$button]['types'][0] . '"/>';
|
482 |
} else {
|
483 |
echo '
|
484 |
+
<select name="mr_social_sharing_' . $button_type . 'buttons[' . $button . '][type]" id="mr_social_sharing_' . $button_type . $button . '_type" class="mr_social_sharing_type_select">';
|
485 |
foreach ($buttons[$button]['types'] as $type) {
|
486 |
+
echo '<option value="' . $type . '"';
|
487 |
+
if ($this -> options['mr_social_sharing_' . $button_type . 'buttons'][$button]['type'] == $type) { echo ' selected="selected"';
|
488 |
+
}
|
489 |
+
echo '>' . $this -> types[$type] . '</option>';
|
490 |
}
|
491 |
echo '</select>';
|
492 |
}
|
493 |
} else {
|
494 |
echo '
|
495 |
+
<input type="hidden" name="mr_social_sharing_' . $button_type . 'buttons[' . $button . '][type]" value=""/>';
|
496 |
}
|
497 |
if (array_key_exists('id', $buttons[$button])) {
|
498 |
if (is_array($buttons[$button]['id']) && array_key_exists('label', $buttons[$button]['id']) && array_key_exists('options', $buttons[$button]['id']) && is_array($buttons[$button]['id']['options'])) {
|
499 |
echo '
|
500 |
+
<select name="mr_social_sharing_' . $button_type . 'buttons[' . $button . '][id]" id="mr_social_sharing_' . $button_type . $button . '_id">';
|
501 |
foreach ($buttons[$button]['id']['options'] as $option) {
|
502 |
if (array_key_exists('label', $option) && array_key_exists('value', $option)) {
|
503 |
+
echo '<option value="' . $option['value'] . '"';
|
504 |
+
if ($option['value'] == $this -> options['mr_social_sharing_' . $button_type . 'buttons'][$button]['id']) {
|
505 |
echo ' selected="selected"';
|
506 |
}
|
507 |
+
echo '>' . $option['label'] . '</option>';
|
508 |
}
|
509 |
}
|
510 |
echo '</select>';
|
511 |
} else {
|
512 |
echo '
|
513 |
+
<input type="text" class="text" name="mr_social_sharing_' . $button_type . 'buttons[' . $button . '][id]" id="mr_social_sharing_' . $button_type . $button . '_id" value="' . $this -> options['mr_social_sharing_' . $button_type . 'buttons'][$button]['id'] . '"/>
|
514 |
+
<label for="mr_social_sharing_' . $button_type . $button . '_id" class="text">' . $buttons[$button]['id'] . '</label>';
|
515 |
}
|
516 |
}
|
517 |
echo '
|
518 |
+
<input type="hidden" name="mr_social_sharing_' . $button_type . 'button_order[]" value="' . $button . '"/></span>
|
519 |
+
<span class="mr_social_sharing_custom"><input type="text" class="text" name="mr_social_sharing_' . $button_type . 'buttons[' . $button . '][icon]" id="mr_social_sharing_' . $button_type . $button . '_icon" value="' . $this -> options['mr_social_sharing_' . $button_type . 'buttons'][$button]['icon'] . '"/>
|
520 |
+
<label for="mr_social_sharing_' . $button_type . $button . '_icon" class="text">' . __('Custom icon url', 'mr_social_sharing_toolkit') . '</label>
|
521 |
|
522 |
+
<input type="text" class="text" name="mr_social_sharing_' . $button_type . 'buttons[' . $button . '][text]" id="mr_social_sharing_' . $button_type . $button . '_text" value="' . stripslashes($this -> options['mr_social_sharing_' . $button_type . 'buttons'][$button]['text']) . '"/>
|
523 |
+
<label for="mr_social_sharing_' . $button_type . $button . '_text" class="text">' . __('Custom text', 'mr_social_sharing_toolkit') . '</label></span>
|
524 |
|
525 |
|
526 |
</li>';
|
527 |
}
|
528 |
+
}
|
529 |
echo '
|
530 |
</ul>
|
531 |
<p>
|
532 |
+
' . __('Choose button orientation horizontal to display the buttons side by side, vertical will place them below each other. You can also select an alignment to better suit your theme.', 'mr_social_sharing_toolkit') . '
|
533 |
</p>
|
534 |
+
<label for="mr_social_sharing_' . $button_type . 'display">' . __('Button orientation', 'mr_social_sharing_toolkit') . '</label>
|
535 |
+
<select name="mr_social_sharing_' . $button_type . 'display" id="mr_social_sharing_' . $button_type . 'display">
|
536 |
<option value="span"';
|
537 |
+
if ($this -> options['mr_social_sharing_' . $button_type . 'display'] == 'span') { echo ' selected="selected"';
|
538 |
+
}
|
539 |
+
echo '>' . __('Horizontal', 'mr_social_sharing_toolkit') . '</option>
|
540 |
<option value="div"';
|
541 |
+
if ($this -> options['mr_social_sharing_' . $button_type . 'display'] == 'div') { echo ' selected="selected"';
|
542 |
+
}
|
543 |
+
echo '>' . __('Vertical', 'mr_social_sharing_toolkit') . '</option>
|
544 |
</select><br/>
|
545 |
+
<label for="mr_social_sharing_' . $button_type . 'align">' . __('Button alignment', 'mr_social_sharing_toolkit') . '</label>
|
546 |
+
<select name="mr_social_sharing_' . $button_type . 'align" id="mr_social_sharing_' . $button_type . 'align">
|
547 |
<option value=""';
|
548 |
+
if ($this -> options['mr_social_sharing_' . $button_type . 'align'] == '') { echo ' selected="selected"';
|
549 |
+
}
|
550 |
+
echo '>' . __('Align to bottom', 'mr_social_sharing_toolkit') . '</option>
|
551 |
<option value="_top"';
|
552 |
+
if ($this -> options['mr_social_sharing_' . $button_type . 'align'] == '_top') { echo ' selected="selected"';
|
553 |
+
}
|
554 |
+
echo '>' . __('Align to top', 'mr_social_sharing_toolkit') . '</option>
|
555 |
+
</select>';
|
556 |
}
|
557 |
+
|
558 |
/* Output functions */
|
559 |
+
|
560 |
function print_opengraph() {
|
561 |
echo '<!-- Open Graph tags provided by Social Sharing Toolkit v2.1.2 -->
|
562 |
+
<meta property="og:locale" content="' . str_replace('-', '_', get_bloginfo('language')) . '"/>';
|
563 |
if (is_single() || is_page()) {
|
564 |
$excerpt = get_the_excerpt();
|
565 |
echo '
|
566 |
+
<meta property="og:title" content="' . trim(wp_title('', 0)) . '"/>';
|
567 |
if ($excerpt != '') {
|
568 |
echo '
|
569 |
+
<meta property="og:description" content="' . $excerpt . '"/>';
|
570 |
} else {
|
571 |
echo '
|
572 |
+
<meta property="og:description" content="' . get_bloginfo('description') . '"/>';
|
573 |
}
|
574 |
echo '
|
575 |
+
<meta property="og:url" content="' . get_permalink() . '"/>
|
576 |
<meta property="og:type" content="article"/>';
|
577 |
} else {
|
578 |
echo '
|
579 |
+
<meta property="og:title" content="' . get_bloginfo('name') . '"/>
|
580 |
+
<meta property="og:description" content="' . get_bloginfo('description') . '"/>
|
581 |
+
<meta property="og:url" content="' . get_home_url() . '"/>
|
582 |
<meta property="og:type" content="website"/>';
|
583 |
+
}
|
584 |
echo '
|
585 |
+
<meta property="og:site_name" content="' . get_bloginfo('name') . '"/>';
|
586 |
+
if (isset($this -> options['mr_social_sharing_opengraph']['fixed_image']) && $this -> options['mr_social_sharing_opengraph']['fixed_image']) {
|
587 |
+
if ($this -> options['mr_social_sharing_opengraph']['default_image'] != '') {
|
588 |
echo '
|
589 |
+
<meta property="og:image" content="' . $this -> options['mr_social_sharing_opengraph']['default_image'] . '"/>';
|
590 |
}
|
591 |
} else {
|
592 |
$media = '';
|
593 |
if (current_theme_supports('post-thumbnails')) {
|
594 |
+
if(isset($this->options['mr_social_sharing_attachment_image_size'])) {
|
595 |
+
$image_size = $this->options['mr_social_sharing_attachment_image_size'];
|
596 |
+
} else {
|
597 |
+
$image_size = 'thumbnail';
|
|
|
|
|
598 |
}
|
599 |
+
if ($media = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $image_size)) {
|
600 |
+
if (is_array($media)) {
|
601 |
+
$media = $media[0];
|
602 |
+
}
|
603 |
+
}
|
604 |
+
}
|
605 |
if ($media == '') {
|
606 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_content(), $matches);
|
607 |
+
if (!empty($matches[1])) {
|
608 |
+
$img = $matches[1][0];
|
609 |
+
if ($img != '') {
|
610 |
+
$media = $img;
|
611 |
+
}
|
612 |
+
}
|
613 |
}
|
614 |
if ($media != '') {
|
615 |
echo '
|
616 |
+
<meta property="og:image" content="' . $media . '"/>';
|
617 |
+
} elseif ($this -> options['mr_social_sharing_opengraph']['default_image'] != '') {
|
618 |
echo '
|
619 |
+
<meta property="og:image" content="' . $this -> options['mr_social_sharing_opengraph']['default_image'] . '"/>';
|
620 |
}
|
621 |
}
|
622 |
+
}
|
623 |
+
|
624 |
function prepare_styles() {
|
625 |
wp_enqueue_style('mr_social_sharing', plugins_url('/style_2.1.2.css', __FILE__));
|
626 |
$upload = wp_upload_dir();
|
627 |
+
if (file_exists($upload['basedir'] . '/social_sharing_custom.css') && $this -> options['mr_social_sharing_custom_css'] != '') {
|
628 |
+
wp_enqueue_style('mr_social_sharing_custom', $upload['baseurl'] . '/social_sharing_custom.css');
|
629 |
+
}
|
630 |
}
|
631 |
+
|
632 |
function prepare_scripts() {
|
633 |
+
if ($this -> options['mr_social_sharing_no_follow'] == 1) {
|
634 |
+
if ($this -> options['mr_social_sharing_js_footer'] == 1) {
|
635 |
wp_enqueue_script('mr_social_sharing', plugins_url('/script_no_follow_2.1.2.js', __FILE__), array('jquery'), false, true);
|
636 |
} else {
|
637 |
wp_enqueue_script('mr_social_sharing', plugins_url('/script_no_follow_2.1.2.js', __FILE__), array('jquery'));
|
638 |
}
|
639 |
} else {
|
640 |
+
if ($this -> options['mr_social_sharing_js_footer'] == 1) {
|
641 |
wp_enqueue_script('mr_social_sharing', plugins_url('/script_2.1.2.js', __FILE__), array('jquery'), false, true);
|
642 |
} else {
|
643 |
wp_enqueue_script('mr_social_sharing', plugins_url('/script_2.1.2.js', __FILE__), array('jquery'));
|
644 |
}
|
645 |
}
|
646 |
+
$this -> load_scripts();
|
647 |
+
if (is_array($this -> scripts) && count($this -> scripts) > 0) {
|
648 |
foreach ($this->scripts as $script) {
|
649 |
wp_enqueue_script($script['name'], $script['src'], array(), false, $script['in_footer']);
|
650 |
+
}
|
651 |
}
|
652 |
+
}
|
653 |
+
|
654 |
function load_scripts() {
|
655 |
$types = array('', 'shortcode_', 'widget_');
|
656 |
foreach ($types as $type) {
|
657 |
foreach ($this->options['mr_social_sharing_'.$type.'button_order'] as $button) {
|
658 |
+
if (isset($this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['enable']) && $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['enable'] == 1) {
|
659 |
+
$id = (array_key_exists('id', $this -> options['mr_social_sharing_' . $type . 'buttons'][$button])) ? $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['id'] : '';
|
660 |
+
$text = (array_key_exists('text', $this -> options['mr_social_sharing_' . $type . 'buttons'][$button])) ? stripslashes($this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['text']) : '';
|
661 |
+
$icon = (array_key_exists('icon', $this -> options['mr_social_sharing_' . $type . 'buttons'][$button])) ? $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['icon'] : '';
|
662 |
foreach ($this->buttons as $tmp) {
|
663 |
+
if (method_exists($tmp, $button)) {
|
664 |
+
$tmp -> $button('', '', $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['type'], $id, '', '', $text, $icon);
|
665 |
+
if (is_array($tmp -> get_enqueued_scripts())) {
|
666 |
+
$this -> scripts = array_merge($this -> scripts, $tmp -> get_enqueued_scripts());
|
667 |
}
|
668 |
}
|
669 |
}
|
670 |
}
|
671 |
}
|
672 |
+
}
|
673 |
foreach ($this->options['mr_social_sharing_follow_button_order'] as $button) {
|
674 |
+
if (isset($this -> options['mr_social_sharing_follow_buttons'][$button]['enable']) && $this -> options['mr_social_sharing_follow_buttons'][$button]['enable'] == 1) {
|
675 |
+
$id = (array_key_exists('id', $this -> options['mr_social_sharing_follow_buttons'][$button])) ? $this -> options['mr_social_sharing_follow_buttons'][$button]['id'] : '';
|
676 |
+
$text = (array_key_exists('text', $this -> options['mr_social_sharing_follow_buttons'][$button])) ? stripslashes($this -> options['mr_social_sharing_follow_buttons'][$button]['text']) : '';
|
677 |
+
$icon = (array_key_exists('icon', $this -> options['mr_social_sharing_follow_buttons'][$button])) ? $this -> options['mr_social_sharing_follow_buttons'][$button]['icon'] : '';
|
678 |
foreach ($this->buttons as $tmp) {
|
679 |
+
if (method_exists($tmp, $button)) {
|
680 |
+
$tmp -> $button($this -> options['mr_social_sharing_follow_buttons'][$button]['type'], $id, $text, $icon);
|
681 |
+
if (is_array($tmp -> get_enqueued_scripts())) {
|
682 |
+
$this -> scripts = array_merge($this -> scripts, $tmp -> get_enqueued_scripts());
|
683 |
}
|
684 |
}
|
685 |
+
}
|
686 |
}
|
687 |
}
|
688 |
+
}
|
689 |
+
|
690 |
function create_bookmarks($url = '', $title = '', $type = '', $media = '', $description = '') {
|
691 |
$url = trim($url);
|
692 |
$title = trim($title);
|
693 |
+
$title = $this->prepare_text($title);
|
694 |
+
if($description) {
|
695 |
+
$description = $this->prepare_text($description);
|
696 |
+
}
|
697 |
if ($url == '') {
|
698 |
+
$url = 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
699 |
}
|
700 |
+
$count_bookmarks = 0;
|
701 |
$bookmarks = '
|
702 |
<div class="mr_social_sharing_wrapper">
|
703 |
+
<!-- Social Sharing Toolkit v2.2 -->';
|
704 |
foreach ($this->options['mr_social_sharing_'.$type.'button_order'] as $button) {
|
705 |
+
if (isset($this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['enable']) && $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['enable'] == 1) {
|
706 |
+
$id = (array_key_exists('id', $this -> options['mr_social_sharing_' . $type . 'buttons'][$button])) ? $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['id'] : '';
|
707 |
+
$text = (array_key_exists('text', $this -> options['mr_social_sharing_' . $type . 'buttons'][$button])) ? stripslashes($this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['text']) : '';
|
708 |
+
$icon = (array_key_exists('icon', $this -> options['mr_social_sharing_' . $type . 'buttons'][$button])) ? $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['icon'] : '';
|
709 |
+
$bookmarks .= $this -> get_bookmark_button($button, $url, $title, $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['type'], $this -> options['mr_social_sharing_' . $type . 'display'], $this -> options['mr_social_sharing_' . $type . 'align'], $id, $media, $description, $text, $icon);
|
710 |
+
$count_bookmarks++;
|
711 |
}
|
712 |
+
}
|
713 |
+
if ($count_bookmarks) {
|
714 |
+
$button = 'linksalpha';
|
715 |
+
$type = (array_key_exists('icon', $this -> options['mr_social_sharing_' . $type . 'buttons'][$button])) ? $this -> options['mr_social_sharing_' . $type . 'buttons'][$button]['type'] : '';
|
716 |
+
$la_button = $this -> get_bookmark_button($button, $url, $title, $type, $this -> options['mr_social_sharing_display'], '', '', $media, $description);
|
717 |
+
$bookmarks .= $la_button;
|
718 |
+
}
|
719 |
$bookmarks .= '</div>';
|
720 |
$bookmarks = str_replace('<div class="mr_social_sharing_wrapper"></div>', '', $bookmarks);
|
721 |
+
$this -> count++;
|
722 |
+
return $bookmarks;
|
723 |
}
|
724 |
+
|
725 |
function create_followers() {
|
726 |
$followers = '
|
727 |
<div class="mr_social_sharing_wrapper">
|
728 |
+
<!-- Social Sharing Toolkit v2.2 -->';
|
729 |
foreach ($this->options['mr_social_sharing_follow_button_order'] as $button) {
|
730 |
+
if (isset($this -> options['mr_social_sharing_follow_buttons'][$button]['id']) && $this -> options['mr_social_sharing_follow_buttons'][$button]['id']) {
|
731 |
+
$id = (array_key_exists('id', $this -> options['mr_social_sharing_follow_buttons'][$button])) ? $this -> options['mr_social_sharing_follow_buttons'][$button]['id'] : '';
|
732 |
+
$text = (array_key_exists('text', $this -> options['mr_social_sharing_follow_buttons'][$button])) ? stripslashes($this -> options['mr_social_sharing_follow_buttons'][$button]['text']) : '';
|
733 |
+
$icon = (array_key_exists('icon', $this -> options['mr_social_sharing_follow_buttons'][$button])) ? $this -> options['mr_social_sharing_follow_buttons'][$button]['icon'] : '';
|
734 |
+
$followers .= $this -> get_follow_button($button, $this -> options['mr_social_sharing_follow_buttons'][$button]['type'], $this -> options['mr_social_sharing_follow_display'], $this -> options['mr_social_sharing_follow_align'], $id, $text, $icon);
|
735 |
}
|
736 |
+
}
|
737 |
$followers .= '</div>';
|
738 |
$followers = str_replace('<div class="mr_social_sharing_wrapper"></div>', '', $followers);
|
739 |
return $followers;
|
740 |
}
|
741 |
+
|
742 |
function get_bookmark_button($button, $url, $title, $type, $display = 'span', $align = '', $id = '', $media = '', $description = '', $text = '', $icon = '') {
|
743 |
$retval = '';
|
744 |
if ($button == 'ln_break_1' || $button == 'ln_break_2' || $button == 'ln_break_3') {
|
745 |
$retval = '</div><div class="mr_social_sharing_wrapper">';
|
746 |
} else {
|
747 |
foreach ($this->buttons as $tmp) {
|
748 |
+
if (method_exists($tmp, $button)) {
|
749 |
+
$retval = '<' . $display . ' class="mr_social_sharing' . $align . '">' . $tmp -> $button($url, $title, $type, $id, $media, $description, $text, $icon) . '</' . $display . '>';
|
750 |
}
|
751 |
}
|
752 |
}
|
753 |
return $retval;
|
754 |
}
|
755 |
+
|
756 |
function get_follow_button($button, $type, $display = 'span', $align = '', $id = '', $text = '', $icon = '') {
|
757 |
$retval = '';
|
758 |
if ($button == 'ln_break_1' || $button == 'ln_break_2' || $button == 'ln_break_3') {
|
759 |
$retval = '</div><div class="mr_social_sharing_wrapper">';
|
760 |
} else {
|
761 |
foreach ($this->buttons as $tmp) {
|
762 |
+
if (method_exists($tmp, $button)) {
|
763 |
+
$retval = '<' . $display . ' class="mr_social_sharing' . $align . '">' . $tmp -> $button($type, $id, $text, $icon) . '</' . $display . '>';
|
764 |
+
}
|
765 |
}
|
766 |
}
|
767 |
return $retval;
|
768 |
}
|
769 |
+
|
770 |
function should_print_opengraph() {
|
771 |
+
if (isset($this -> options['mr_social_sharing_opengraph']['enable']) && $this -> options['mr_social_sharing_opengraph']['enable'] == 1) {
|
772 |
return true;
|
773 |
}
|
774 |
}
|
775 |
+
|
776 |
function should_share_content() {
|
777 |
+
if ($this -> options['mr_social_sharing_position'] != 'none') {
|
778 |
return true;
|
779 |
}
|
780 |
+
return false;
|
781 |
}
|
782 |
+
|
783 |
function should_share_excerpt() {
|
784 |
+
if ($this -> options['mr_social_sharing_position'] != 'none' && $this -> options['mr_social_sharing_include_excerpts'] == 1) {
|
785 |
return true;
|
786 |
}
|
787 |
+
return false;
|
788 |
}
|
789 |
+
|
790 |
function share($content) {
|
791 |
if (is_feed()) {
|
792 |
return $content;
|
793 |
} else {
|
794 |
$media = '';
|
795 |
+
if ($this -> options['mr_social_sharing_pinterest']['default_image'] != '' && $this -> options['mr_social_sharing_pinterest']['fixed_image'] == 1) {
|
796 |
+
$media = $this -> options['mr_social_sharing_pinterest']['default_image'];
|
797 |
} else {
|
798 |
if (current_theme_supports('post-thumbnails')) {
|
799 |
+
if(isset($this->options['mr_social_sharing_attachment_image_size'])) {
|
800 |
+
$image_size = $this->options['mr_social_sharing_attachment_image_size'];
|
801 |
+
} else {
|
802 |
+
$image_size = 'thumbnail';
|
|
|
|
|
803 |
}
|
804 |
+
if ($media = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $image_size)) {
|
805 |
+
if (is_array($media)) {
|
806 |
+
$media = $media[0];
|
807 |
+
}
|
808 |
+
}
|
809 |
+
}
|
810 |
if ($media == '') {
|
811 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
|
812 |
+
if (!empty($matches[1])) {
|
813 |
+
$img = $matches[1][0];
|
814 |
+
if ($img != '') {
|
815 |
+
$media = $img;
|
816 |
+
}
|
817 |
+
}
|
818 |
}
|
819 |
+
if ($media == '' && $this -> options['mr_social_sharing_pinterest']['default_image'] != '') {
|
820 |
+
$media = $this -> options['mr_social_sharing_pinterest']['default_image'];
|
821 |
}
|
822 |
}
|
823 |
$type = get_post_type();
|
824 |
+
if (in_array($type, $this -> options['mr_social_sharing_types']) && ((is_single() || $this -> options['mr_social_sharing_include_excerpts'] == 1) || $type == 'page')) {
|
825 |
+
if ($this -> options['mr_social_sharing_position'] == 'top') {
|
826 |
+
$bookmarks = $this -> create_bookmarks(get_permalink(), the_title('', '', false), '', $media, get_the_content());
|
827 |
+
$content = $bookmarks . $content;
|
828 |
}
|
829 |
+
if ($this -> options['mr_social_sharing_position'] == 'bottom') {
|
830 |
+
$bookmarks = $this -> create_bookmarks(get_permalink(), the_title('', '', false), '', $media, get_the_content());
|
831 |
$content .= $bookmarks;
|
832 |
}
|
833 |
+
if ($this -> options['mr_social_sharing_position'] == 'both') {
|
834 |
+
$bookmarks = $this -> create_bookmarks(get_permalink(), the_title('', '', false), '', $media, get_the_content());
|
835 |
+
$bookmarks2 = $this -> create_bookmarks(get_permalink(), the_title('', '', false), '', $media, get_the_content());
|
836 |
+
$content = $bookmarks . $content . $bookmarks2;
|
837 |
}
|
838 |
}
|
839 |
return $content;
|
840 |
}
|
841 |
}
|
842 |
+
|
843 |
function share_excerpt($content) {
|
844 |
if (is_feed()) {
|
845 |
return $content;
|
846 |
} else {
|
847 |
$media = '';
|
848 |
+
if ($this -> options['mr_social_sharing_pinterest']['default_image'] != '' && $this -> options['mr_social_sharing_pinterest']['fixed_image'] == 1) {
|
849 |
+
$media = $this -> options['mr_social_sharing_pinterest']['default_image'];
|
850 |
} else {
|
851 |
if (current_theme_supports('post-thumbnails')) {
|
852 |
+
if(isset($this->options['mr_social_sharing_attachment_image_size'])) {
|
853 |
+
$image_size = $this->options['mr_social_sharing_attachment_image_size'];
|
854 |
+
} else {
|
855 |
+
$image_size = 'thumbnail';
|
856 |
+
}
|
857 |
+
if ($media = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $image_size)) {
|
858 |
+
if (is_array($media)) {
|
859 |
+
$media = $media[0];
|
860 |
+
}
|
861 |
}
|
862 |
+
}
|
863 |
if ($media == '') {
|
864 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
|
865 |
+
if (!empty($matches[1])) {
|
866 |
+
$img = $matches[1][0];
|
867 |
+
if ($img != '') {
|
868 |
+
$media = $img;
|
869 |
+
}
|
870 |
+
}
|
871 |
}
|
872 |
+
if ($media == '' && $this -> options['mr_social_sharing_pinterest']['default_image'] != '') {
|
873 |
+
$media = $this -> options['mr_social_sharing_pinterest']['default_image'];
|
874 |
}
|
875 |
}
|
876 |
$type = get_post_type();
|
877 |
+
if (in_array($type, $this -> options['mr_social_sharing_types'])) {
|
878 |
+
if ($this -> options['mr_social_sharing_position'] == 'top') {
|
879 |
+
$bookmarks = $this -> create_bookmarks(get_permalink(), the_title('', '', false), '', $media, get_the_content());
|
880 |
+
$content = $bookmarks . $content;
|
881 |
}
|
882 |
+
if ($this -> options['mr_social_sharing_position'] == 'bottom') {
|
883 |
+
$bookmarks = $this -> create_bookmarks(get_permalink(), the_title('', '', false), '', $media, get_the_content());
|
884 |
$content .= $bookmarks;
|
885 |
}
|
886 |
+
if ($this -> options['mr_social_sharing_position'] == 'both') {
|
887 |
+
$bookmarks = $this -> create_bookmarks(get_permalink(), the_title('', '', false), '', $media, get_the_content());
|
888 |
+
$content = $bookmarks . $content . $bookmarks;
|
889 |
}
|
890 |
}
|
891 |
return $content;
|
892 |
}
|
893 |
}
|
894 |
+
|
895 |
function share_shortcode($atts) {
|
896 |
+
extract(shortcode_atts(array('url' => '', 'title' => ''), $atts));
|
|
|
|
|
|
|
897 |
if (is_feed()) {
|
898 |
return '';
|
899 |
} else {
|
900 |
$media = '';
|
901 |
+
if ($this -> options['mr_social_sharing_pinterest']['default_image'] != '' && $this -> options['mr_social_sharing_pinterest']['fixed_image'] == 1) {
|
902 |
+
$media = $this -> options['mr_social_sharing_pinterest']['default_image'];
|
903 |
} else {
|
904 |
if (current_theme_supports('post-thumbnails')) {
|
905 |
+
if(isset($this->options['mr_social_sharing_attachment_image_size'])) {
|
906 |
+
$image_size = $this->options['mr_social_sharing_attachment_image_size'];
|
907 |
+
} else {
|
908 |
+
$image_size = 'thumbnail';
|
|
|
|
|
909 |
}
|
910 |
+
if ($media = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $image_size)) {
|
911 |
+
if (is_array($media)) {
|
912 |
+
$media = $media[0];
|
913 |
+
}
|
914 |
+
}
|
915 |
+
}
|
916 |
if ($media == '') {
|
917 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_content(), $matches);
|
918 |
+
if (!empty($matches[1])) {
|
919 |
+
$img = $matches[1][0];
|
920 |
+
if ($img != '') {
|
921 |
+
$media = $img;
|
922 |
+
}
|
923 |
+
}
|
924 |
}
|
925 |
+
if ($media == '' && $this -> options['mr_social_sharing_pinterest']['default_image'] != '') {
|
926 |
+
$media = $this -> options['mr_social_sharing_pinterest']['default_image'];
|
927 |
}
|
928 |
}
|
929 |
$type = get_post_type();
|
930 |
+
$bookmarks = '';
|
931 |
+
if ((is_single() || $type == 'page') || $this -> options['mr_social_sharing_include_excerpts'] == 1) {
|
932 |
$url = ($url == '') ? get_permalink() : $url;
|
933 |
+
$title = ($title == '') ? the_title('', '', false) : $title;
|
934 |
+
$bookmarks = $this -> create_bookmarks($url, $title, 'shortcode_', $media, get_the_content());
|
935 |
}
|
936 |
return $bookmarks;
|
937 |
}
|
938 |
}
|
939 |
+
|
940 |
function should_linkify_content() {
|
941 |
+
if ($this -> options['mr_social_sharing_linkify_content'] == 1) {
|
942 |
return true;
|
943 |
}
|
944 |
return false;
|
945 |
}
|
946 |
+
|
947 |
function should_linkify_comments() {
|
948 |
+
if ($this -> options['mr_social_sharing_linkify_comments'] == 1) {
|
949 |
return true;
|
950 |
}
|
951 |
return false;
|
952 |
}
|
953 |
+
|
954 |
function linkify($content) {
|
955 |
+
if ($this -> options['mr_social_sharing_linkify_new'] == 1) {
|
956 |
+
if ($this -> options['mr_social_sharing_twitter_handles'] == 1) {
|
957 |
$content = preg_replace("/(^|\s)+(@([a-zA-Z0-9_-]{1,15}))(\.*[^|\n|\r|\t|\s|\<|\&]*)/i", "$1<a href=\"http://twitter.com/$3\" target=\"_BLANK\">$2</a>$4", $content);
|
958 |
}
|
959 |
+
if ($this -> options['mr_social_sharing_twitter_hashtags'] == 1) {
|
960 |
$content = preg_replace("/(^|\s)+((?:(?<!&))#([a-zA-Z0-9]+^[-|;]))([^|\n|\r|\t|\s|\.|\<|\&]*)/i", "$1<a href=\"http://twitter.com/search/$3\" target=\"_BLANK\">$2</a>$4", $content);
|
961 |
}
|
962 |
} else {
|
963 |
+
if ($this -> options['mr_social_sharing_twitter_handles'] == 1) {
|
964 |
$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);
|
965 |
}
|
966 |
+
if ($this -> options['mr_social_sharing_twitter_hashtags'] == 1) {
|
967 |
$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);
|
968 |
}
|
969 |
}
|
970 |
return $content;
|
971 |
}
|
972 |
+
|
973 |
+
function prepare_text($text) {
|
974 |
+
$text = stripslashes($text);
|
975 |
+
$text = strip_tags($text);
|
976 |
+
$text = preg_replace("/\[.*?\]/", '', $text);
|
977 |
+
$text = preg_replace('/([\n \t\r]+)/', ' ', $text);
|
978 |
+
$text = preg_replace('/( +)/', ' ', $text);
|
979 |
+
$text = preg_replace('/\s\s+/', ' ', $text);
|
980 |
+
$text = $this->prepare_string($text, 310);
|
981 |
+
$text = $this->smart_truncate($text, 300);
|
982 |
+
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
|
983 |
+
$text = trim($text);
|
984 |
+
return $text;
|
985 |
+
}
|
986 |
+
|
987 |
+
function smart_truncate($string, $required_length) {
|
988 |
+
$parts = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
|
989 |
+
$parts_count = count($parts);
|
990 |
+
$length = 0;
|
991 |
+
$last_part = 0;
|
992 |
+
for (; $last_part < $parts_count; ++$last_part) {
|
993 |
+
$length += strlen($parts[$last_part]);
|
994 |
+
if ($length > $required_length) {
|
995 |
+
break;
|
996 |
+
}
|
997 |
+
}
|
998 |
+
return implode(array_slice($parts, 0, $last_part));
|
999 |
+
}
|
1000 |
+
|
1001 |
+
function prepare_string($string, $string_length) {
|
1002 |
+
$final_string = '';
|
1003 |
+
$utf8marker = chr(128);
|
1004 |
+
$count = 0;
|
1005 |
+
while (isset($string{$count})) {
|
1006 |
+
if ($string{$count} >= $utf8marker) {
|
1007 |
+
$parsechar = substr($string, $count, 2);
|
1008 |
+
$count += 2;
|
1009 |
+
} else {
|
1010 |
+
$parsechar = $string{$count};
|
1011 |
+
$count++;
|
1012 |
+
}
|
1013 |
+
if ($count > $string_length) {
|
1014 |
+
return $final_string;
|
1015 |
+
}
|
1016 |
+
$final_string = $final_string . $parsechar;
|
1017 |
+
}
|
1018 |
+
return $final_string;
|
1019 |
+
}
|
1020 |
+
|
1021 |
}
|
1022 |
+
|
1023 |
require 'includes/class.button.php';
|
1024 |
+
$buttons = glob(dirname(__FILE__) . '/includes/buttons/button.*.php');
|
1025 |
if (is_array($buttons) && count($buttons) > 0) {
|
1026 |
foreach ($buttons as $button) {
|
1027 |
+
include str_replace(dirname(__FILE__) . '/', '', $button);
|
1028 |
+
}
|
1029 |
}
|
1030 |
unset($buttons);
|
1031 |
|
1032 |
+
define('MR_Social_Sharing_Toolkit_Admin_URL', "options-general.php?page=mr_social_sharing");
|
1033 |
+
function mr_social_sharing_actlinks( $links ) {
|
1034 |
+
$settings_link = '<a href="'.MR_Social_Sharing_Toolkit_Admin_URL.'">'.__('Settings').'</a>';
|
1035 |
+
array_unshift( $links, $settings_link );
|
1036 |
+
return $links;
|
1037 |
+
}
|
1038 |
+
$plugin = plugin_basename(__FILE__);
|
1039 |
+
add_filter("plugin_action_links_$plugin", 'mr_social_sharing_actlinks' );
|
1040 |
|
1041 |
$MR_Social_Sharing_Toolkit = new MR_Social_Sharing_Toolkit();
|
1042 |
add_action('admin_menu', array($MR_Social_Sharing_Toolkit, 'plugin_menu'));
|
1043 |
+
if ($MR_Social_Sharing_Toolkit -> should_print_opengraph()) {
|
1044 |
add_action('wp_head', array($MR_Social_Sharing_Toolkit, 'print_opengraph'), 1);
|
1045 |
}
|
1046 |
+
if ($MR_Social_Sharing_Toolkit -> should_linkify_content()) {
|
1047 |
add_filter('the_content', array($MR_Social_Sharing_Toolkit, 'linkify'));
|
1048 |
}
|
1049 |
+
if ($MR_Social_Sharing_Toolkit -> should_linkify_comments()) {
|
1050 |
add_filter('comment_text', array($MR_Social_Sharing_Toolkit, 'linkify'));
|
1051 |
}
|
1052 |
+
if ($MR_Social_Sharing_Toolkit -> should_share_excerpt()) {
|
1053 |
add_filter('the_excerpt', array($MR_Social_Sharing_Toolkit, 'share_excerpt'));
|
1054 |
}
|
1055 |
+
if ($MR_Social_Sharing_Toolkit -> should_share_content()) {
|
1056 |
add_filter('the_content', array($MR_Social_Sharing_Toolkit, 'share'));
|
1057 |
}
|
1058 |
add_shortcode('social_share', array($MR_Social_Sharing_Toolkit, 'share_shortcode'), 15);
|