Simple Social Media Share Buttons – Social Sharing for Everyone - Version 2.0.18

Version Description

  • Please upgrade immediately. Releasing New features, few bugfixes and improvements.

=

Download this release

Release Info

Developer hiddenpearls
Plugin Icon 128x128 Simple Social Media Share Buttons – Social Sharing for Everyone
Version 2.0.18
Comparing to
See all releases

Code changes from version 2.0.17 to 2.0.18

Files changed (2) hide show
  1. readme.txt +5 -2
  2. simple-social-buttons.php +87 -29
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpbrigade.com/
4
  Tags: Social share, Social buttons, Whatsapp, Viber, LinkedIn, facebook, google, twitter, pinterest, plus one
5
  Requires at least: 4.0
6
  Tested up to: 4.9
7
- Stable tag: 2.0.17
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -146,11 +146,14 @@ like_button_size = small(default), large
146
 
147
  == Upgrade Notice ==
148
 
149
- = 2.0.17 =
150
  * Please upgrade immediately. Releasing New features, few bugfixes and improvements.
151
 
152
 
153
  == Changelog ==
 
 
 
154
  = 2.0.17 - 2018-08-25 =
155
  * New Feature: Tumblr Button Added.
156
  * Enhancement: Getting Facebook share count algorithm,
4
  Tags: Social share, Social buttons, Whatsapp, Viber, LinkedIn, facebook, google, twitter, pinterest, plus one
5
  Requires at least: 4.0
6
  Tested up to: 4.9
7
+ Stable tag: 2.0.18
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
146
 
147
  == Upgrade Notice ==
148
 
149
+ = 2.0.18 =
150
  * Please upgrade immediately. Releasing New features, few bugfixes and improvements.
151
 
152
 
153
  == Changelog ==
154
+ = 2.0.18 - 2018-09-13 =
155
+ * Bug Fix: Above the content network excerpt issue.
156
+
157
  = 2.0.17 - 2018-08-25 =
158
  * New Feature: Tumblr Button Added.
159
  * Enhancement: Getting Facebook share count algorithm,
simple-social-buttons.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Social Buttons
4
  * Plugin URI: http://www.WPBrigade.com/wordpress/plugins/simple-social-buttons/
5
  * Description: Simple Social Buttons adds an advanced set of social media sharing buttons to your WordPress sites, such as: Google +1, Facebook, WhatsApp, Viber, Twitter, Reddit, LinkedIn and Pinterest. This makes it the most <code>Flexible Social Sharing Plugin ever for Everyone.</code>
6
- * Version: 2.0.17
7
  * Author: WPBrigade
8
  * Author URI: http://www.WPBrigade.com/
9
  * Text Domain: simple-social-buttons
@@ -30,7 +30,7 @@
30
 
31
  class SimpleSocialButtonsPR {
32
  public $pluginName = 'Simple Social Buttons';
33
- public $pluginVersion = '2.0.17';
34
  public $pluginPrefix = 'ssb_pr_';
35
  public $hideCustomMetaKey = '_ssb_hide';
36
  private $fb_app_id = '891268654262273';
@@ -87,7 +87,7 @@ class SimpleSocialButtonsPR {
87
  add_action( 'plugins_loaded', array( $this, 'load_plugin_domain' ) );
88
 
89
  /**
90
- * Filter hooks
91
  */
92
  add_filter( 'the_content', array( $this, 'insert_buttons' ) );
93
 
@@ -95,6 +95,8 @@ class SimpleSocialButtonsPR {
95
 
96
  add_filter( 'plugin_row_meta', array( $this, '_row_meta' ), 10, 2 );
97
 
 
 
98
  add_action( 'wp_enqueue_scripts', array( $this, 'front_enqueue_scripts' ) );
99
 
100
  // Queue up our hook function
@@ -115,7 +117,6 @@ class SimpleSocialButtonsPR {
115
  add_shortcode( 'SSB', array( $this, 'short_code_content' ) );
116
  add_action( 'wp_head', array( $this, 'add_meta_tags' ) );
117
 
118
-
119
  add_action( 'wp_ajax_ssb_facebook_shares_update', array( $this, 'facebook_shares_update' ) );
120
  add_action( 'wp_ajax_nopriv_ssb_facebook_shares_update', array( $this, 'facebook_shares_update' ) );
121
 
@@ -256,7 +257,7 @@ class SimpleSocialButtonsPR {
256
  public function facebook_shares_update() {
257
 
258
  $activity = $_POST['share_counts'];
259
- $post_id = $_POST['post_id'];
260
 
261
  $previous_activity = get_post_meta( $post_id, 'ssb_fbshare_counts', true );
262
 
@@ -542,9 +543,8 @@ class SimpleSocialButtonsPR {
542
  $ssb_buttonscode = '';
543
  // get post permalink and title
544
  $permalink = get_permalink();
545
- $title = urlencode( html_entity_decode( get_the_title(), ENT_COMPAT, 'UTF-8' ) );
546
  // $title = urlencode( get_the_title() );
547
-
548
  // Sorting the buttons
549
  $arrButtons = array();
550
  foreach ( $this->arrKnownButtons as $button_name ) {
@@ -838,12 +838,11 @@ class SimpleSocialButtonsPR {
838
  $arrButtonsCode[] = '<button onclick="javascript:window.print();return false;" class="simplesocial-print-share" ><span class="simplesocialtxt">Print</span></button>';
839
  }
840
  break;
841
- case 'tumblr':
842
-
843
  $tumblr_score = $share_counts['tumblr'] ? $share_counts['tumblr'] : 0;
844
-
845
- $link = urlencode( $permalink );
846
- $tumblr_share_url = "http://tumblr.com/widgets/share/tool?canonicalUrl=$link";
847
  if ( $this->selected_theme == 'simple-icons' ) {
848
  $_html = '<button class="ssb_tumblr-icon" data-href="' . $tumblr_share_url . '" onclick="javascript:window.open(this.dataset.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600\');return false;">
849
  <span class="icon"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
@@ -1061,10 +1060,10 @@ class SimpleSocialButtonsPR {
1061
 
1062
  $selected_theme = shortcode_atts(
1063
  array(
1064
- 'theme' => '',
1065
- 'order' => null,
1066
- 'align' => '',
1067
- 'counter' => 'false',
1068
  'like_button_size' => 'small',
1069
  ), $atts
1070
  );
@@ -1119,8 +1118,8 @@ class SimpleSocialButtonsPR {
1119
  $show_count = false;
1120
  }
1121
 
1122
- //set fb like button size
1123
- $like_button_size = $selected_theme['like_button_size'];
1124
 
1125
  $extra_class .= ' simplesocialbuttons-inline-' . $this->_get_settings( 'inline', 'animation', 'no-animation' );
1126
 
@@ -1189,10 +1188,9 @@ class SimpleSocialButtonsPR {
1189
  $non_exist_post_record = true;
1190
  }
1191
 
1192
-
1193
  // Reset the cache timestamp if needed
1194
  // if false fetch the new share counts.
1195
- if ( ( isset( $this->settings['cache'] ) && $this->settings['cache'] == 'off' ) || ( $non_exist_post_record ) ) {
1196
 
1197
  $_share_links = array();
1198
  $_alt_share_links = array();
@@ -1204,8 +1202,8 @@ class SimpleSocialButtonsPR {
1204
 
1205
  }
1206
  $_alt_share_links = $this->http_or_https_link_generate( $permalink );
1207
- $result = ssb_fetch_shares_via_curl_multi( array_filter( $_share_links ) );
1208
- $share_counts = ssb_fetch_fresh_counts( $result, $post_id, $_alt_share_links );
1209
  // update_post_meta( $post_id,'ssb_cache_timestamp',floor( ( ( date( 'U' ) / 60) / 60 ) ) );
1210
  } else {
1211
  $share_counts = ssb_fetch_cached_counts( array_flip( $arrButtons ), $post_id );
@@ -1403,7 +1401,7 @@ class SimpleSocialButtonsPR {
1403
  break;
1404
 
1405
  case 'fblike':
1406
- $_html = '<div class="fb-like ssb-fb-like" data-href="' . $permalink . '" data-layout="button_count" data-action="like" data-size="'. $like_button_size .'" data-show-faces="false" data-share="false"></div>';
1407
  $arrButtonsCode[] = $_html;
1408
 
1409
  break;
@@ -1453,14 +1451,13 @@ class SimpleSocialButtonsPR {
1453
  $arrButtonsCode[] = '<button onclick="javascript:window.print();return false;" class="simplesocial-print-share" ><span class="simplesocialtxt">Print</span></button>';
1454
  }
1455
  break;
1456
- case 'tumblr':
1457
-
1458
  $tumblr_score = $share_counts['tumblr'] ? $share_counts['tumblr'] : 0;
1459
-
1460
- $link = urlencode( $permalink );
1461
- $tumblr_share_url = "http://tumblr.com/widgets/share/tool?canonicalUrl=$link";
1462
  if ( $this->selected_theme == 'simple-icons' ) {
1463
- $_html ='<button class="ssb_tumblr-icon" data-href="' . $tumblr_share_url . '" onclick="javascript:window.open(this.dataset.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600\');return false;">
1464
  <span class="icon"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
1465
  width="12.6px" height="17.8px" viewBox="-299.1 388.3 12.6 17.8" style="enable-background:new -299.1 388.3 12.6 17.8;" xml:space="preserve"><g> <path fill="#FFFFFF" d="M-294.7,388.3c1.1,0,2.1,0,3.2,0c0,1.5,0,2.9,0,4.4c1.7,0,3.3,0,5,0c0,1.1,0,2.2,0,3.4c-1.7,0-3.3,0-5,0 c0,0.1,0,0.2,0,0.2c0,1.6,0,3.2,0,4.8c0,1.2,0.6,1.8,1.8,2c1.1,0.1,2.1,0,3-0.5c0.1,0,0.1-0.1,0.2-0.1c0,0.1,0,0.1,0,0.2 c0,0.8,0,1.5,0,2.3c0,0.1,0,0.2-0.2,0.3c-1.6,0.6-3.2,0.9-5,0.8c-1-0.1-2-0.3-2.9-0.8c-1.2-0.7-1.8-1.7-1.8-3.1c0-2.1,0-4.1,0-6.2 c0-0.1,0-0.2,0-0.3c-0.9,0-1.8,0-2.7,0c0-0.1,0-0.1,0-0.2c0-0.7,0-1.5,0-2.2c0-0.1,0-0.2,0.2-0.2c0.3-0.1,0.7-0.2,1-0.3 c1.6-0.6,2.6-1.8,3-3.5c0-0.1,0.1-0.3,0.1-0.4C-294.8,388.6-294.7,388.4-294.7,388.3z"/> </g> </svg> </span>
1466
  <span class="simplesocialtxt">tumblr </span>';
@@ -1727,6 +1724,67 @@ class SimpleSocialButtonsPR {
1727
  return $_alt_share_links;
1728
  }
1729
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1730
  } // end class
1731
 
1732
 
3
  * Plugin Name: Simple Social Buttons
4
  * Plugin URI: http://www.WPBrigade.com/wordpress/plugins/simple-social-buttons/
5
  * Description: Simple Social Buttons adds an advanced set of social media sharing buttons to your WordPress sites, such as: Google +1, Facebook, WhatsApp, Viber, Twitter, Reddit, LinkedIn and Pinterest. This makes it the most <code>Flexible Social Sharing Plugin ever for Everyone.</code>
6
+ * Version: 2.0.18
7
  * Author: WPBrigade
8
  * Author URI: http://www.WPBrigade.com/
9
  * Text Domain: simple-social-buttons
30
 
31
  class SimpleSocialButtonsPR {
32
  public $pluginName = 'Simple Social Buttons';
33
+ public $pluginVersion = '2.0.18';
34
  public $pluginPrefix = 'ssb_pr_';
35
  public $hideCustomMetaKey = '_ssb_hide';
36
  private $fb_app_id = '891268654262273';
87
  add_action( 'plugins_loaded', array( $this, 'load_plugin_domain' ) );
88
 
89
  /**
90
+ * Filter hooks
91
  */
92
  add_filter( 'the_content', array( $this, 'insert_buttons' ) );
93
 
95
 
96
  add_filter( 'plugin_row_meta', array( $this, '_row_meta' ), 10, 2 );
97
 
98
+ add_filter( 'wp_trim_words', array( $this, 'on_excerpt_content' ), 11, 4 );
99
+
100
  add_action( 'wp_enqueue_scripts', array( $this, 'front_enqueue_scripts' ) );
101
 
102
  // Queue up our hook function
117
  add_shortcode( 'SSB', array( $this, 'short_code_content' ) );
118
  add_action( 'wp_head', array( $this, 'add_meta_tags' ) );
119
 
 
120
  add_action( 'wp_ajax_ssb_facebook_shares_update', array( $this, 'facebook_shares_update' ) );
121
  add_action( 'wp_ajax_nopriv_ssb_facebook_shares_update', array( $this, 'facebook_shares_update' ) );
122
 
257
  public function facebook_shares_update() {
258
 
259
  $activity = $_POST['share_counts'];
260
+ $post_id = $_POST['post_id'];
261
 
262
  $previous_activity = get_post_meta( $post_id, 'ssb_fbshare_counts', true );
263
 
543
  $ssb_buttonscode = '';
544
  // get post permalink and title
545
  $permalink = get_permalink();
546
+ $title = urlencode( html_entity_decode( get_the_title(), ENT_COMPAT, 'UTF-8' ) );
547
  // $title = urlencode( get_the_title() );
 
548
  // Sorting the buttons
549
  $arrButtons = array();
550
  foreach ( $this->arrKnownButtons as $button_name ) {
838
  $arrButtonsCode[] = '<button onclick="javascript:window.print();return false;" class="simplesocial-print-share" ><span class="simplesocialtxt">Print</span></button>';
839
  }
840
  break;
841
+ case 'tumblr':
 
842
  $tumblr_score = $share_counts['tumblr'] ? $share_counts['tumblr'] : 0;
843
+
844
+ $link = urlencode( $permalink );
845
+ $tumblr_share_url = "http://tumblr.com/widgets/share/tool?canonicalUrl=$link";
846
  if ( $this->selected_theme == 'simple-icons' ) {
847
  $_html = '<button class="ssb_tumblr-icon" data-href="' . $tumblr_share_url . '" onclick="javascript:window.open(this.dataset.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600\');return false;">
848
  <span class="icon"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
1060
 
1061
  $selected_theme = shortcode_atts(
1062
  array(
1063
+ 'theme' => '',
1064
+ 'order' => null,
1065
+ 'align' => '',
1066
+ 'counter' => 'false',
1067
  'like_button_size' => 'small',
1068
  ), $atts
1069
  );
1118
  $show_count = false;
1119
  }
1120
 
1121
+ // set fb like button size
1122
+ $like_button_size = $selected_theme['like_button_size'];
1123
 
1124
  $extra_class .= ' simplesocialbuttons-inline-' . $this->_get_settings( 'inline', 'animation', 'no-animation' );
1125
 
1188
  $non_exist_post_record = true;
1189
  }
1190
 
 
1191
  // Reset the cache timestamp if needed
1192
  // if false fetch the new share counts.
1193
+ if ( ( isset( $this->settings['cache'] ) && $this->settings['cache'] == 'off' ) || ( $non_exist_post_record ) ) {
1194
 
1195
  $_share_links = array();
1196
  $_alt_share_links = array();
1202
 
1203
  }
1204
  $_alt_share_links = $this->http_or_https_link_generate( $permalink );
1205
+ $result = ssb_fetch_shares_via_curl_multi( array_filter( $_share_links ) );
1206
+ $share_counts = ssb_fetch_fresh_counts( $result, $post_id, $_alt_share_links );
1207
  // update_post_meta( $post_id,'ssb_cache_timestamp',floor( ( ( date( 'U' ) / 60) / 60 ) ) );
1208
  } else {
1209
  $share_counts = ssb_fetch_cached_counts( array_flip( $arrButtons ), $post_id );
1401
  break;
1402
 
1403
  case 'fblike':
1404
+ $_html = '<div class="fb-like ssb-fb-like" data-href="' . $permalink . '" data-layout="button_count" data-action="like" data-size="' . $like_button_size . '" data-show-faces="false" data-share="false"></div>';
1405
  $arrButtonsCode[] = $_html;
1406
 
1407
  break;
1451
  $arrButtonsCode[] = '<button onclick="javascript:window.print();return false;" class="simplesocial-print-share" ><span class="simplesocialtxt">Print</span></button>';
1452
  }
1453
  break;
1454
+ case 'tumblr':
 
1455
  $tumblr_score = $share_counts['tumblr'] ? $share_counts['tumblr'] : 0;
1456
+
1457
+ $link = urlencode( $permalink );
1458
+ $tumblr_share_url = "http://tumblr.com/widgets/share/tool?canonicalUrl=$link";
1459
  if ( $this->selected_theme == 'simple-icons' ) {
1460
+ $_html = '<button class="ssb_tumblr-icon" data-href="' . $tumblr_share_url . '" onclick="javascript:window.open(this.dataset.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600\');return false;">
1461
  <span class="icon"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
1462
  width="12.6px" height="17.8px" viewBox="-299.1 388.3 12.6 17.8" style="enable-background:new -299.1 388.3 12.6 17.8;" xml:space="preserve"><g> <path fill="#FFFFFF" d="M-294.7,388.3c1.1,0,2.1,0,3.2,0c0,1.5,0,2.9,0,4.4c1.7,0,3.3,0,5,0c0,1.1,0,2.2,0,3.4c-1.7,0-3.3,0-5,0 c0,0.1,0,0.2,0,0.2c0,1.6,0,3.2,0,4.8c0,1.2,0.6,1.8,1.8,2c1.1,0.1,2.1,0,3-0.5c0.1,0,0.1-0.1,0.2-0.1c0,0.1,0,0.1,0,0.2 c0,0.8,0,1.5,0,2.3c0,0.1,0,0.2-0.2,0.3c-1.6,0.6-3.2,0.9-5,0.8c-1-0.1-2-0.3-2.9-0.8c-1.2-0.7-1.8-1.7-1.8-3.1c0-2.1,0-4.1,0-6.2 c0-0.1,0-0.2,0-0.3c-0.9,0-1.8,0-2.7,0c0-0.1,0-0.1,0-0.2c0-0.7,0-1.5,0-2.2c0-0.1,0-0.2,0.2-0.2c0.3-0.1,0.7-0.2,1-0.3 c1.6-0.6,2.6-1.8,3-3.5c0-0.1,0.1-0.3,0.1-0.4C-294.8,388.6-294.7,388.4-294.7,388.3z"/> </g> </svg> </span>
1463
  <span class="simplesocialtxt">tumblr </span>';
1724
  return $_alt_share_links;
1725
  }
1726
 
1727
+ /**
1728
+ * Function use to remove button names on excerpt if above the content selecetd .
1729
+ *
1730
+ * @param [string] $text already excertp set.
1731
+ * @param [int] $num_words word in excerpt.
1732
+ * @param [string $more more srting apprend in last of the excerpt sring.
1733
+ * @param [string] $original_text original text of the string.
1734
+ * @return [string] $text string of excerpt;
1735
+ */
1736
+ function on_excerpt_content( $text, $num_words, $more, $original_text ) {
1737
+
1738
+ if ( empty( $text ) ) {
1739
+ return $text;
1740
+ }
1741
+
1742
+ $dom = new DOMDocument();
1743
+ $dom->loadHTML( mb_convert_encoding( $original_text, 'HTML-ENTITIES', 'UTF-8' ) );
1744
+
1745
+ $xpath = new DOMXPath( $dom );
1746
+ $xpath->registerNamespace( 'h', 'http://www.w3.org/1999/xhtml' );
1747
+ // using a loop in case there are multiple occurrences
1748
+ foreach ( $xpath->query( "//div[contains(@class, 'simplesocialbuttons')]" ) as $node ) {
1749
+
1750
+ $paragraph_node = $node->parentNode;
1751
+ // echo '<pre>';
1752
+ // print_r( $paragraph_node );
1753
+ $node->parentNode->removeChild( $node );
1754
+
1755
+ }
1756
+ $text = wp_strip_all_tags( $dom->saveHTML() );
1757
+
1758
+ /*
1759
+ * wp_trim_words() for more detail
1760
+ * translators: If your word count is based on single characters (e.g. East Asian characters),
1761
+ * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
1762
+ * Do not translate into your own language.
1763
+ */
1764
+ if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
1765
+ $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
1766
+ preg_match_all( '/./u', $text, $words_array );
1767
+ $words_array = array_slice( $words_array[0], 0, $num_words + 1 );
1768
+ $sep = '';
1769
+ } else {
1770
+ $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
1771
+
1772
+ $sep = ' ';
1773
+ }
1774
+
1775
+ if ( count( $words_array ) > $num_words ) {
1776
+ array_pop( $words_array );
1777
+ $text = implode( $sep, $words_array );
1778
+ $text = $text . $more;
1779
+ } else {
1780
+ $text = implode( $sep, $words_array );
1781
+ }
1782
+
1783
+ return $text;
1784
+ }
1785
+
1786
+
1787
+
1788
  } // end class
1789
 
1790