Add Twitter, Facebook Like, Google plus one Social share - Version 1.1.0

Version Description

= *Added new feature to display Social share buttons on home page, static pages, category, archives, tags.

=

Download this release

Release Info

Developer BeingMaverick
Plugin Icon wp plugin Add Twitter, Facebook Like, Google plus one Social share
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.2 to 1.1.0

Files changed (4) hide show
  1. readme.txt +11 -1
  2. tf_admin_page.php +27 -1
  3. tf_display.php +90 -18
  4. twitter-facebook-share.php +2 -1
readme.txt CHANGED
@@ -4,7 +4,7 @@ Plugin Site: http://www.searchtechword.com
4
  Tags: Facebook like, twitter button, twitter share, Google +1 (plus one) button, Google plus one, Stumbleupon, social share, twitter facebook share, google +1 share
5
  Requires at least: 2.8+
6
  Tested up to: 3.1.3
7
- Stable tag: 1.0.2
8
 
9
  == Description ==
10
  <br />
@@ -23,6 +23,8 @@ Option to load the script in header as well, if you wish to.
23
 
24
  * Left side floating option is the latest trend these days. The top and left spacing can be configured according to your site layout. Using simple CSS and not ajax for better performance. Also floating bar can be fixed on that position or absolute and can be configured easily through settings.
25
 
 
 
26
  * Option to manually display the share box at any position.
27
 
28
 
@@ -46,6 +48,9 @@ You can Check Screen Shots on my website. I use the same plugin to display Socia
46
 
47
  == Change log ==
48
 
 
 
 
49
  == 1.0.2 ==
50
  *Fixed a small bug for left side floating facebook like.
51
  *Eliminated the use of javascript for facebook like as it was conflicting with other facebook plugins.
@@ -56,3 +61,8 @@ You can Check Screen Shots on my website. I use the same plugin to display Socia
56
 
57
  == 1.0.0 ==
58
  *Initial version
 
 
 
 
 
4
  Tags: Facebook like, twitter button, twitter share, Google +1 (plus one) button, Google plus one, Stumbleupon, social share, twitter facebook share, google +1 share
5
  Requires at least: 2.8+
6
  Tested up to: 3.1.3
7
+ Stable tag: 1.1.0
8
 
9
  == Description ==
10
  <br />
23
 
24
  * Left side floating option is the latest trend these days. The top and left spacing can be configured according to your site layout. Using simple CSS and not ajax for better performance. Also floating bar can be fixed on that position or absolute and can be configured easily through settings.
25
 
26
+ * Option to display on home page, static pages, category, tag, archive pages.
27
+
28
  * Option to manually display the share box at any position.
29
 
30
 
48
 
49
  == Change log ==
50
 
51
+ == 1.1.0 ==
52
+ *Added new feature to display Social share buttons on home page, static pages, category, archives, tags.
53
+
54
  == 1.0.2 ==
55
  *Fixed a small bug for left side floating facebook like.
56
  *Eliminated the use of javascript for facebook like as it was conflicting with other facebook plugins.
61
 
62
  == 1.0.0 ==
63
  *Initial version
64
+
65
+ == Upgrade Notice ==
66
+
67
+ == 1.1.0 ==
68
+ *New feature to display on home and static page added.
tf_admin_page.php CHANGED
@@ -21,6 +21,17 @@ $active_buttons = array(
21
  'stumbleupon'=>'Stumbleupon',
22
  'Google_plusone'=>'Google PlusOne'
23
  );
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  $out = '';
26
 
@@ -32,6 +43,9 @@ $active_buttons = array(
32
  foreach (array_keys($active_buttons) as $item) {
33
  $option['active_buttons'][$item] = (isset($_POST['twitter_facebook_share_active_'.$item]) and $_POST['twitter_facebook_share_active_'.$item]=='on') ? true : false;
34
  }
 
 
 
35
  $option['position'] = esc_html($_POST['twitter_facebook_share_position']);
36
  $option['border'] = esc_html($_POST['twitter_facebook_share_border']);
37
 
@@ -91,7 +105,7 @@ $active_buttons = array(
91
  </td></tr>
92
 
93
  <tr><td valign="top" style="width:130px;">'.__("Active share buttons", 'menu-test' ).':</td>
94
- <td style="padding-bottom:40px;">';
95
 
96
  foreach ($active_buttons as $name => $text) {
97
  $checked = ($option['active_buttons'][$name]) ? 'checked="checked"' : '';
@@ -100,6 +114,17 @@ $active_buttons = array(
100
  . __($text, 'menu-test' ).' &nbsp;&nbsp;</div>';
101
 
102
  }
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  $out .= '</td></tr>
105
 
@@ -247,6 +272,7 @@ function twitter_facebook_share_get_options_default ($position='above', $border=
247
  $option = array();
248
  $option['auto'] = true;
249
  $option['active_buttons'] = array('facebook_like'=>true, 'twitter'=>true, 'stumbleupon'=>true, 'Google_plusone'=>true);
 
250
  $option['position'] = $position;
251
  $option['border'] = $border;
252
  $option['bkcolor'] = true;
21
  'stumbleupon'=>'Stumbleupon',
22
  'Google_plusone'=>'Google PlusOne'
23
  );
24
+
25
+ $show_in = array(
26
+ 'posts'=>'Single posts',
27
+ 'pages'=>'Pages',
28
+ 'home_page'=>'Home page',
29
+ 'tags'=>'Tags',
30
+ 'categories'=>'Categories',
31
+ 'authors'=>'Author archives',
32
+ 'search'=>'Search results',
33
+ 'date_arch'=>'Archives'
34
+ );
35
 
36
  $out = '';
37
 
43
  foreach (array_keys($active_buttons) as $item) {
44
  $option['active_buttons'][$item] = (isset($_POST['twitter_facebook_share_active_'.$item]) and $_POST['twitter_facebook_share_active_'.$item]=='on') ? true : false;
45
  }
46
+ foreach (array_keys($show_in) as $item) {
47
+ $option['show_in'][$item] = (isset($_POST['twitter_facebook_share_show_'.$item]) and $_POST['twitter_facebook_share_show_'.$item]=='on') ? true : false;
48
+ }
49
  $option['position'] = esc_html($_POST['twitter_facebook_share_position']);
50
  $option['border'] = esc_html($_POST['twitter_facebook_share_border']);
51
 
105
  </td></tr>
106
 
107
  <tr><td valign="top" style="width:130px;">'.__("Active share buttons", 'menu-test' ).':</td>
108
+ <td style="padding-bottom:30px;">';
109
 
110
  foreach ($active_buttons as $name => $text) {
111
  $checked = ($option['active_buttons'][$name]) ? 'checked="checked"' : '';
114
  . __($text, 'menu-test' ).' &nbsp;&nbsp;</div>';
115
 
116
  }
117
+
118
+ $out .= '</td></tr>
119
+ <tr><td valign="top" style="width:130px;">'.__("Show buttons in these pages", 'menu-test' ).':</td>
120
+ <td style="padding-bottom:20px;">';
121
+
122
+ foreach ($show_in as $name => $text) {
123
+ $checked = ($option['show_in'][$name]) ? 'checked="checked"' : '';
124
+ $out .= '<div style="width:150px; float:left;">
125
+ <input type="checkbox" name="twitter_facebook_share_show_'.$name.'" '.$checked.' /> '
126
+ . __($text, 'menu-test' ).' &nbsp;&nbsp;</div>';
127
+ }
128
 
129
  $out .= '</td></tr>
130
 
272
  $option = array();
273
  $option['auto'] = true;
274
  $option['active_buttons'] = array('facebook_like'=>true, 'twitter'=>true, 'stumbleupon'=>true, 'Google_plusone'=>true);
275
+ $option['show_in'] = array('posts'=>true, 'pages'=>true, 'home_page'=>true, 'tags'=>true, 'categories'=>true, 'authors'=>true, 'search'=>true,'date_arch'=>true);
276
  $option['position'] = $position;
277
  $option['border'] = $border;
278
  $option['bkcolor'] = true;
tf_display.php CHANGED
@@ -29,8 +29,19 @@ function kc_twitter_facebook_contents($content)
29
  {
30
  global $single;
31
  $output = kc_social_share();
32
- if (is_single()) {
33
- $option = twitter_facebook_share_get_options_stored();
 
 
 
 
 
 
 
 
 
 
 
34
  if ($option['position'] == 'above')
35
  return $output . $content;
36
  if ($option['position'] == 'below')
@@ -39,9 +50,68 @@ function kc_twitter_facebook_contents($content)
39
  return $output . $content;
40
  if ($option['position'] == 'both')
41
  return $output . $content . $output;
42
- } else {
43
- return $content;
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
  // Function to manually display related posts.
@@ -111,14 +181,16 @@ margin:4px 4px 4px 4px;
111
 
112
  </style>
113
  <?php
114
-
 
 
 
115
  if ($option['position'] == 'left'){
116
  $output = '<div id="leftcontainerBox">';
117
  if ($option['active_buttons']['facebook_like']==true) {
118
  $output .= '
119
  <div class="buttons">
120
- <iframe src="http://www.facebook.com/plugins/like.php?href=' . rawurlencode(get_permalink()) . '&layout=box_count&show_faces=false&action=like&font=verdana
121
- &colorscheme=light" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:60px;" allowTransparency="true"></iframe>
122
  </div>';
123
  }
124
 
@@ -126,12 +198,12 @@ margin:4px 4px 4px 4px;
126
  if ($option['twitter_id'] != ''){
127
  $output .= '
128
  <div class="buttons">
129
- <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-via="'. $option['twitter_id'] . '">Tweet</a>
130
  </div>';
131
  } else {
132
  $output .= '
133
  <div class="buttons">
134
- <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical">Tweet</a>
135
  </div>';
136
  }
137
  }
@@ -139,13 +211,13 @@ margin:4px 4px 4px 4px;
139
  if ($option['active_buttons']['Google_plusone']==true) {
140
  $output .= '
141
  <div class="buttons">
142
- <g:plusone size="tall"></g:plusone>
143
  </div>';
144
  }
145
 
146
  if ($option['active_buttons']['stumbleupon']==true) {
147
  $output .= '
148
- <div class="buttons"><script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script></div>';
149
  }
150
  $output .= '</div><div style="clear:both"></div>';
151
  return $output;
@@ -157,32 +229,32 @@ margin:4px 4px 4px 4px;
157
  $output = '<div id="bottomcontainerBox">';
158
  if ($option['active_buttons']['facebook_like']==true) {
159
  $output .= '
160
- <div class="buttons"><iframe src="http://www.facebook.com/plugins/like.php?href=' . rawurlencode(get_permalink()) . '&layout=button_count&show_faces=false&width=100&action=like&font=verdana
161
- &colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>';
162
  }
163
 
164
  if ($option['active_buttons']['Google_plusone']==true) {
165
  $output .= '
166
  <div class="buttons">
167
- <g:plusone size="medium"></g:plusone>
168
  </div>';
169
  }
170
 
171
  if ($option['active_buttons']['stumbleupon']==true) {
172
  $output .= '
173
- <div class="buttons"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1"></script></div>';
174
  }
175
 
176
  if ($option['active_buttons']['twitter']==true) {
177
  if ($option['twitter_id'] != ''){
178
  $output .= '
179
  <div class="buttons">
180
- <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="'. $option['twitter_id'] . '">Tweet</a>
181
  </div>';
182
  } else {
183
  $output .= '
184
  <div class="buttons">
185
- <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical">Tweet</a>
186
  </div>';
187
  }
188
  }
29
  {
30
  global $single;
31
  $output = kc_social_share();
32
+ $option = twitter_facebook_share_get_options_stored();
33
+ if (is_single() && ($option['show_in']['posts'])) {
34
+ if ($option['position'] == 'above')
35
+ return $output . $content;
36
+ if ($option['position'] == 'below')
37
+ return $content . $output;
38
+ if ($option['position'] == 'left')
39
+ return $output . $content;
40
+ if ($option['position'] == 'both')
41
+ return $output . $content . $output;
42
+ }
43
+ if (is_home() && ($option['show_in']['home_page'])){
44
+ $option = twitter_facebook_share_get_options_stored();
45
  if ($option['position'] == 'above')
46
  return $output . $content;
47
  if ($option['position'] == 'below')
50
  return $output . $content;
51
  if ($option['position'] == 'both')
52
  return $output . $content . $output;
53
+ }
54
+ if (is_singular() && ($option['show_in']['pages'])) {
55
+ if ($option['position'] == 'above')
56
+ return $output . $content;
57
+ if ($option['position'] == 'below')
58
+ return $content . $output;
59
+ if ($option['position'] == 'left')
60
+ return $output . $content;
61
+ if ($option['position'] == 'both')
62
+ return $output . $content . $output;
63
+ }
64
+ if (is_category() && ($option['show_in']['categories'])) {
65
+ if ($option['position'] == 'above')
66
+ return $output . $content;
67
+ if ($option['position'] == 'below')
68
+ return $content . $output;
69
+ if ($option['position'] == 'left')
70
+ return $output . $content;
71
+ if ($option['position'] == 'both')
72
+ return $output . $content . $output;
73
+ }
74
+ if (is_tag() && ($option['show_in']['tags'])) {
75
+ if ($option['position'] == 'above')
76
+ return $output . $content;
77
+ if ($option['position'] == 'below')
78
+ return $content . $output;
79
+ if ($option['position'] == 'left')
80
+ return $output . $content;
81
+ if ($option['position'] == 'both')
82
+ return $output . $content . $output;
83
+ }
84
+ if (is_author() && ($option['show_in']['authors'])) {
85
+ if ($option['position'] == 'above')
86
+ return $output . $content;
87
+ if ($option['position'] == 'below')
88
+ return $content . $output;
89
+ if ($option['position'] == 'left')
90
+ return $output . $content;
91
+ if ($option['position'] == 'both')
92
+ return $output . $content . $output;
93
+ }
94
+ if (is_search() && ($option['show_in']['search'])) {
95
+ if ($option['position'] == 'above')
96
+ return $output . $content;
97
+ if ($option['position'] == 'below')
98
+ return $content . $output;
99
+ if ($option['position'] == 'left')
100
+ return $output . $content;
101
+ if ($option['position'] == 'both')
102
+ return $output . $content . $output;
103
+ }
104
+ if (is_date() && ($option['show_in']['date_arch'])) {
105
+ if ($option['position'] == 'above')
106
+ return $output . $content;
107
+ if ($option['position'] == 'below')
108
+ return $content . $output;
109
+ if ($option['position'] == 'left')
110
+ return $output . $content;
111
+ if ($option['position'] == 'both')
112
+ return $output . $content . $output;
113
+ }
114
+ return $content;
115
  }
116
 
117
  // Function to manually display related posts.
181
 
182
  </style>
183
  <?php
184
+ $post_link = esc_url(get_permalink());
185
+ $post_title = get_the_title();
186
+ if ($option['position'] == 'left' && ( !is_single() || !is_singular()))
187
+ $option['position'] = 'above';
188
  if ($option['position'] == 'left'){
189
  $output = '<div id="leftcontainerBox">';
190
  if ($option['active_buttons']['facebook_like']==true) {
191
  $output .= '
192
  <div class="buttons">
193
+ <iframe src="http://www.facebook.com/plugins/like.php?href=' . rawurlencode(get_permalink()) . '&amp;layout=box_count&amp;show_faces=false&amp;action=like&amp;font=verdana&amp;colorscheme=light" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:60px;" allowTransparency="true"></iframe>
 
194
  </div>';
195
  }
196
 
198
  if ($option['twitter_id'] != ''){
199
  $output .= '
200
  <div class="buttons">
201
+ <a href="http://twitter.com/share" class="twitter-share-button" data-url="'. $post_link .'" data-text="'. $post_title . '" data-count="vertical" data-via="'. $option['twitter_id'] . '">Tweet</a>
202
  </div>';
203
  } else {
204
  $output .= '
205
  <div class="buttons">
206
+ <a href="http://twitter.com/share" class="twitter-share-button" data-url="'. $post_link .'" data-text="'. $post_title . '" data-count="vertical">Tweet</a>
207
  </div>';
208
  }
209
  }
211
  if ($option['active_buttons']['Google_plusone']==true) {
212
  $output .= '
213
  <div class="buttons">
214
+ <g:plusone size="tall" href="'. $post_link .'"></g:plusone>
215
  </div>';
216
  }
217
 
218
  if ($option['active_buttons']['stumbleupon']==true) {
219
  $output .= '
220
+ <div class="buttons"><script src="http://www.stumbleupon.com/hostedbadge.php?s=5&amp;r='.$post_link.'"></script></div>';
221
  }
222
  $output .= '</div><div style="clear:both"></div>';
223
  return $output;
229
  $output = '<div id="bottomcontainerBox">';
230
  if ($option['active_buttons']['facebook_like']==true) {
231
  $output .= '
232
+ <div class="buttons">
233
+ <iframe src="http://www.facebook.com/plugins/like.php?href=' . rawurlencode(get_permalink()) . '&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>';
234
  }
235
 
236
  if ($option['active_buttons']['Google_plusone']==true) {
237
  $output .= '
238
  <div class="buttons">
239
+ <g:plusone size="medium" href="' . $post_link . '"></g:plusone>
240
  </div>';
241
  }
242
 
243
  if ($option['active_buttons']['stumbleupon']==true) {
244
  $output .= '
245
+ <div class="buttons"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r='.$post_link.'"></script></div>';
246
  }
247
 
248
  if ($option['active_buttons']['twitter']==true) {
249
  if ($option['twitter_id'] != ''){
250
  $output .= '
251
  <div class="buttons">
252
+ <a href="http://twitter.com/share" class="twitter-share-button" data-url="'. $post_link .'" data-text="'. $post_title . '" data-count="horizontal" data-via="'. $option['twitter_id'] . '">Tweet</a>
253
  </div>';
254
  } else {
255
  $output .= '
256
  <div class="buttons">
257
+ <a href="http://twitter.com/share" class="twitter-share-button" data-url="'. $post_link .'" data-text="'. $post_title . '" data-count="horizontal">Tweet</a>
258
  </div>';
259
  }
260
  }
twitter-facebook-share.php CHANGED
@@ -5,7 +5,7 @@ Description: WordPress plugin for twitter, facebook, Google +1 (plus one) and ot
5
  Author: Kunal Chichkar
6
  Author URI: http://www.searchtechword.com
7
  Plugin URI: http://www.searchtechword.com/2011/06/wordpress-plugin-add-twitter-facebook-google-plus-one-share
8
- Version: 1.0.0
9
  License: GPL
10
  */
11
  /*
@@ -57,6 +57,7 @@ else
57
  if($option['auto'] == true)
58
  {
59
  add_filter('the_content', 'kc_twitter_facebook_contents');
 
60
  }
61
  }
62
  ?>
5
  Author: Kunal Chichkar
6
  Author URI: http://www.searchtechword.com
7
  Plugin URI: http://www.searchtechword.com/2011/06/wordpress-plugin-add-twitter-facebook-google-plus-one-share
8
+ Version: 1.1.0
9
  License: GPL
10
  */
11
  /*
57
  if($option['auto'] == true)
58
  {
59
  add_filter('the_content', 'kc_twitter_facebook_contents');
60
+ add_filter('the_excerpt', 'kc_twitter_facebook_contents');
61
  }
62
  }
63
  ?>