Social Share WordPress Plugin – AccessPress Social Share - Version 4.4.5

Version Description

  • Bug fix related to Facebook Share Count
Download this release

Release Info

Developer Access Keys
Plugin Icon 128x128 Social Share WordPress Plugin – AccessPress Social Share
Version 4.4.5
Comparing to
See all releases

Code changes from version 4.4.3 to 4.4.5

accesspress-social-share.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) or die( "No script kiddies please!" );
4
  Plugin name: Social Share WordPress Plugin - AccessPress Social Share (Tester)
5
  Plugin URI: https://accesspressthemes.com/wordpress-plugins/accesspress-social-share/
6
  Description: A plugin to add various social media shares to a site with dynamic configuration options.
7
- Version: 4.4.3
8
  Author: AccessPress Themes
9
  Author URI: http://accesspressthemes.com
10
  Text Domain: accesspress-social-share
@@ -30,7 +30,7 @@ if ( ! defined( 'APSS_LANG_DIR' ) ) {
30
  }
31
 
32
  if ( ! defined( 'APSS_VERSION' ) ) {
33
- define( 'APSS_VERSION', '4.4.3' );
34
  }
35
 
36
  if ( ! defined( 'APSS_TEXT_DOMAIN' ) ) {
@@ -392,17 +392,14 @@ if ( ! class_exists( 'APSS_Class' ) ) {
392
  echo "</pre>";
393
  }
394
 
395
- ////////////////////////////////////for count //////////////////////////////////////////////////////
396
  //for facebook url share count
397
  function get_fb( $url ){
398
  $apss_settings = $this -> apss_settings;
399
  if ( ! isset( $apss_settings[ 'enable_cache' ] ) || $apss_settings[ 'enable_cache' ] == '1' ) {
400
- ////////////////////////for transient//////////////////////////////
401
  $cache_period = $apss_settings[ 'cache_period' ];
402
  $fb_transient = 'fb_' . md5( $url );
403
  $fb_transient_count = get_transient( $fb_transient );
404
-
405
- //for setting the counter transient in separate options value
406
  $apss_social_counts_transients = get_option( APSS_COUNT_TRANSIENTS );
407
  if ( false === $fb_transient_count ) {
408
  $json_string = $this -> get_json_values( 'https://graph.facebook.com/?id=' . $url );
@@ -416,14 +413,10 @@ if ( ! class_exists( 'APSS_Class' ) ) {
416
  } else {
417
  $facebook_count = $fb_transient_count;
418
  }
419
- ////////////////////////for transient ends ///////////////////////////
420
  } else {
421
  $json_string = $this -> get_json_values( 'https://graph.facebook.com/?id=' . $url );
422
  $json = json_decode( $json_string, true );
423
-
424
- // echo"<pre>";
425
- // print_r($json);
426
- // echo"</pre>";
427
  $facebook_count = isset( $json[ 'share' ][ 'share_count' ] ) ? intval( $json[ 'share' ][ 'share_count' ] ) : 0;
428
  }
429
  return $facebook_count;
@@ -434,29 +427,20 @@ if ( ! class_exists( 'APSS_Class' ) ) {
434
  * */
435
  function get_fb_access_token(){
436
  $apss_settings = $this -> apss_settings;
437
-
438
- // echo"<pre>";
439
- // print_r($apss_settings);
440
- // echo"</pre>";
441
-
442
  $app_id = $apss_settings[ 'api_configuration' ][ 'facebook' ][ 'app_id' ];
443
  $app_secret = $apss_settings[ 'api_configuration' ][ 'facebook' ][ 'app_secret' ];
444
  $api_url = 'https://graph.facebook.com/';
445
- $url = sprintf(
446
- '%soauth/access_token?client_id=%s&client_secret=%s&grant_type=client_credentials', $api_url, $app_id, $app_secret
447
- );
448
-
449
- $access_token = wp_remote_get( $url, array( 'timeout' => 60 ) );
450
- // echo "Access Token:"
451
- // echo"<pre>";
452
- // print_r($access_token);
453
- // echo"</pre>";
454
  if ( is_wp_error( $access_token ) || ( isset( $access_token[ 'response' ][ 'code' ] ) && 200 != $access_token[ 'response' ][ 'code' ] ) ) {
455
- //echo 1;
456
  return '';
457
  } else {
458
  $json_decode = json_decode( $access_token[ 'body' ] );
459
- //echo 2;
460
  return sanitize_text_field( $json_decode -> access_token );
461
  }
462
  }
@@ -486,7 +470,6 @@ if ( ! class_exists( 'APSS_Class' ) ) {
486
 
487
  $apss_settings = $this -> apss_settings;
488
  if ( isset( $apss_settings[ 'enable_cache' ] ) && $apss_settings[ 'enable_cache' ] == '1' ) {
489
- ////////////////////////for transient//////////////////////////////
490
  $cache_period = $apss_settings[ 'cache_period' ];
491
  $fb_transient = 'fb_' . md5( $url );
492
  $fb_transient_count = get_transient( $fb_transient );
@@ -505,20 +488,47 @@ if ( ! class_exists( 'APSS_Class' ) ) {
505
  } else {
506
  $facebook_count = $fb_transient_count;
507
  }
508
- ////////////////////////for transient ends ///////////////////////////
509
  } else {
510
- $json_string = $this -> get_json_values( $facebook_count );
511
- $json = json_decode( $json_string, true );
512
- // echo"<pre>";
513
- // print_r($json);
514
- // echo"</pre>";
515
- $facebook_count = isset( $json[ 'share' ][ 'share_count' ] ) ? intval( $json[ 'share' ][ 'share_count' ] ) : 0 ;
516
  }
517
  return $facebook_count;
518
  die();
519
  }
520
  }
521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  //for twitter url share count
523
  function get_tweets( $url ){
524
  $apss_settings = $this -> apss_settings;
@@ -732,10 +742,6 @@ if ( ! class_exists( 'APSS_Class' ) ) {
732
  public static function get_http_url( $url ){
733
  return preg_replace( '/https:/i', 'http:', $url );
734
  }
735
-
736
  }
737
-
738
- //APSS_Class termination
739
-
740
  $GLOBALS[ 'apss_object' ] = new APSS_Class();
741
  }
4
  Plugin name: Social Share WordPress Plugin - AccessPress Social Share (Tester)
5
  Plugin URI: https://accesspressthemes.com/wordpress-plugins/accesspress-social-share/
6
  Description: A plugin to add various social media shares to a site with dynamic configuration options.
7
+ Version: 4.4.5
8
  Author: AccessPress Themes
9
  Author URI: http://accesspressthemes.com
10
  Text Domain: accesspress-social-share
30
  }
31
 
32
  if ( ! defined( 'APSS_VERSION' ) ) {
33
+ define( 'APSS_VERSION', '4.4.4' );
34
  }
35
 
36
  if ( ! defined( 'APSS_TEXT_DOMAIN' ) ) {
392
  echo "</pre>";
393
  }
394
 
395
+ //////////////////////////////////// for count //////////////////////////////////////
396
  //for facebook url share count
397
  function get_fb( $url ){
398
  $apss_settings = $this -> apss_settings;
399
  if ( ! isset( $apss_settings[ 'enable_cache' ] ) || $apss_settings[ 'enable_cache' ] == '1' ) {
 
400
  $cache_period = $apss_settings[ 'cache_period' ];
401
  $fb_transient = 'fb_' . md5( $url );
402
  $fb_transient_count = get_transient( $fb_transient );
 
 
403
  $apss_social_counts_transients = get_option( APSS_COUNT_TRANSIENTS );
404
  if ( false === $fb_transient_count ) {
405
  $json_string = $this -> get_json_values( 'https://graph.facebook.com/?id=' . $url );
413
  } else {
414
  $facebook_count = $fb_transient_count;
415
  }
416
+
417
  } else {
418
  $json_string = $this -> get_json_values( 'https://graph.facebook.com/?id=' . $url );
419
  $json = json_decode( $json_string, true );
 
 
 
 
420
  $facebook_count = isset( $json[ 'share' ][ 'share_count' ] ) ? intval( $json[ 'share' ][ 'share_count' ] ) : 0;
421
  }
422
  return $facebook_count;
427
  * */
428
  function get_fb_access_token(){
429
  $apss_settings = $this -> apss_settings;
 
 
 
 
 
430
  $app_id = $apss_settings[ 'api_configuration' ][ 'facebook' ][ 'app_id' ];
431
  $app_secret = $apss_settings[ 'api_configuration' ][ 'facebook' ][ 'app_secret' ];
432
  $api_url = 'https://graph.facebook.com/';
433
+ // $url = sprintf(
434
+ // '%soauth/access_token?client_id=%s&client_secret=%s&grant_type=client_credentials', $api_url, $app_id, $app_secret
435
+ // );
436
+
437
+ $get_token = "https://graph.facebook.com/oauth/access_token?client_id=$app_id&client_secret=$app_secret&grant_type=client_credentials&&redirect_uri=$url";
438
+
439
+ $access_token = wp_remote_get( $get_token, array( 'timeout' => 60 ) );
 
 
440
  if ( is_wp_error( $access_token ) || ( isset( $access_token[ 'response' ][ 'code' ] ) && 200 != $access_token[ 'response' ][ 'code' ] ) ) {
 
441
  return '';
442
  } else {
443
  $json_decode = json_decode( $access_token[ 'body' ] );
 
444
  return sanitize_text_field( $json_decode -> access_token );
445
  }
446
  }
470
 
471
  $apss_settings = $this -> apss_settings;
472
  if ( isset( $apss_settings[ 'enable_cache' ] ) && $apss_settings[ 'enable_cache' ] == '1' ) {
 
473
  $cache_period = $apss_settings[ 'cache_period' ];
474
  $fb_transient = 'fb_' . md5( $url );
475
  $fb_transient_count = get_transient( $fb_transient );
488
  } else {
489
  $facebook_count = $fb_transient_count;
490
  }
 
491
  } else {
492
+ $facebook_count = APSS_Class :: facebook_new_share_count_api( $url );
 
 
 
 
 
493
  }
494
  return $facebook_count;
495
  die();
496
  }
497
  }
498
 
499
+ static function facebook_new_share_count_api( $url ){
500
+
501
+ $access_token = self::get_fb_access_token( $url );
502
+ $api_url = 'https://graph.facebook.com/';
503
+
504
+ // Not Working --v
505
+ $facebook_count = sprintf( '%s?access_token=%s&id=%s', $api_url, $access_token, $url );
506
+
507
+ // Not Working --v
508
+ $facebook_count = 'https://graph.facebook.com/?id=' . $url . '&access_token=' . sanitize_text_field( $access_token );
509
+
510
+ // Not Working --v
511
+ $facebook_count = 'https://graph.facebook.com/?id=' . $url . '&fields=og_object{engagement}';
512
+ if ( $access_token != '' ) {
513
+ $facebook_count .= '&access_token=' . sanitize_text_field( $access_token );
514
+ }
515
+
516
+ // Not Working -- depreciated for FB App v2.9 and higher
517
+ $facebook_count = 'https://graph.facebook.com/?fields=og_object%7Blikes.summary(true).limit(0)%7D,share&id=' . $url;
518
+
519
+ // Working
520
+ $facebook_count = "https://graph.facebook.com/?id=$url&fields=engagement&access_token=$access_token";
521
+
522
+ $json_string = self::get_json_values( $facebook_count );
523
+ $json = json_decode( $json_string, true );
524
+ if ( is_wp_error( $access_token ) || ( isset( $access_token[ 'response' ][ 'code' ] ) && 200 != $access_token[ 'response' ][ 'code' ] ) ) {
525
+ return '0';
526
+ } else {
527
+ $facebook_count = isset( $json[ 'engagement' ][ 'share_count' ] ) ? intval( $json[ 'engagement' ][ 'share_count' ] ) : 0;
528
+ return $facebook_count;
529
+ }
530
+ }
531
+
532
  //for twitter url share count
533
  function get_tweets( $url ){
534
  $apss_settings = $this -> apss_settings;
742
  public static function get_http_url( $url ){
743
  return preg_replace( '/https:/i', 'http:', $url );
744
  }
 
745
  }
 
 
 
746
  $GLOBALS[ 'apss_object' ] = new APSS_Class();
747
  }
inc/backend/activation.php CHANGED
@@ -34,7 +34,6 @@ $apss_share_settings['enable_cache'] = '1';
34
  $apss_share_settings['cache_period'] = '24';
35
  $apss_share_settings['apss_social_counts_transients'] = array();
36
  $apss_share_settings['dialog_box_options'] = '1';
37
- // $apss_share_settings['footer_javascript'] = '1';
38
  $apss_share_settings['apss_email_subject'] = 'Please visit this link %%url%%';
39
  $apss_share_settings['apss_email_body'] = 'Hey Buddy!, I found this information for you: "%%title%%". Here is the website link: %%permalink%%. Thank you.';
40
  update_option( APSS_SETTING_NAME, $apss_share_settings );
34
  $apss_share_settings['cache_period'] = '24';
35
  $apss_share_settings['apss_social_counts_transients'] = array();
36
  $apss_share_settings['dialog_box_options'] = '1';
 
37
  $apss_share_settings['apss_email_subject'] = 'Please visit this link %%url%%';
38
  $apss_share_settings['apss_email_body'] = 'Hey Buddy!, I found this information for you: "%%title%%". Here is the website link: %%permalink%%. Thank you.';
39
  update_option( APSS_SETTING_NAME, $apss_share_settings );
inc/backend/main-page.php CHANGED
@@ -443,4 +443,4 @@
443
  <div class="clear"></div>
444
  </form>
445
  </div>
446
- </div>
443
  <div class="clear"></div>
444
  </form>
445
  </div>
446
+ </div>
inc/backend/save-settings.php CHANGED
@@ -52,5 +52,4 @@ if ( $status == TRUE ) {
52
  } else {
53
  wp_redirect( admin_url() . 'admin.php?page=accesspress-social-share&message=2' );
54
  }
55
- exit;
56
-
52
  } else {
53
  wp_redirect( admin_url() . 'admin.php?page=accesspress-social-share&message=2' );
54
  }
55
+ exit;
 
inc/frontend/content-filter.php CHANGED
@@ -43,9 +43,9 @@ foreach ( $options['social_networks'] as $key => $value ) {
43
  if(isset($http_url_checked) && $http_url_checked=='1'){
44
  $url_check = parse_url($url);
45
  if($url_check['scheme'] == 'https'){
46
- $flag=TRUE;
47
  }else{
48
- $flag=FALSE;
49
  }
50
 
51
  if($flag == TRUE){
@@ -69,9 +69,9 @@ foreach ( $options['social_networks'] as $key => $value ) {
69
  if(isset($http_url_checked) && $http_url_checked=='1'){
70
  $url_check = parse_url($url);
71
  if($url_check['scheme'] == 'https'){
72
- $flag=TRUE;
73
  }else{
74
- $flag=FALSE;
75
  }
76
  if($flag == TRUE){
77
  $url1 = APSS_Class:: get_http_url($url);
@@ -111,9 +111,9 @@ foreach ( $options['social_networks'] as $key => $value ) {
111
  if(isset($http_url_checked) && $http_url_checked=='1'){
112
  $url_check = parse_url($url);
113
  if($url_check['scheme'] == 'https'){
114
- $flag=TRUE;
115
  }else{
116
- $flag=FALSE;
117
  }
118
 
119
  if($flag == TRUE){
@@ -180,12 +180,12 @@ foreach ( $options['social_networks'] as $key => $value ) {
180
  case 'pinterest':
181
  $count = $this->get_count( $key, $url );
182
 
183
- if(isset($http_url_checked) && $http_url_checked=='1'){
184
  $url_check = parse_url($url);
185
  if($url_check['scheme'] == 'https'){
186
- $flag=TRUE;
187
  }else{
188
- $flag=FALSE;
189
  }
190
 
191
  if($flag == TRUE){
@@ -239,9 +239,7 @@ foreach ( $options['social_networks'] as $key => $value ) {
239
  }
240
  }
241
  }
242
-
243
  ?>
244
-
245
  <div class='apss-linkedin apss-single-icon'>
246
  <a rel='nofollow' <?php if($apss_link_open_option_value == 2){ ?> onclick="apss_open_in_popup_window(event, '<?php echo $link; ?>');" <?php } ?> title="<?php _e( 'Share on LinkedIn', 'accesspress-social-share' ); ?>" target='<?php echo $apss_link_open_option; ?>' href='<?php echo $link; ?>'>
247
  <div class='apss-icon-block clearfix'><i class='fa fa-linkedin'></i>
43
  if(isset($http_url_checked) && $http_url_checked=='1'){
44
  $url_check = parse_url($url);
45
  if($url_check['scheme'] == 'https'){
46
+ $flag = TRUE;
47
  }else{
48
+ $flag = FALSE;
49
  }
50
 
51
  if($flag == TRUE){
69
  if(isset($http_url_checked) && $http_url_checked=='1'){
70
  $url_check = parse_url($url);
71
  if($url_check['scheme'] == 'https'){
72
+ $flag = TRUE;
73
  }else{
74
+ $flag = FALSE;
75
  }
76
  if($flag == TRUE){
77
  $url1 = APSS_Class:: get_http_url($url);
111
  if(isset($http_url_checked) && $http_url_checked=='1'){
112
  $url_check = parse_url($url);
113
  if($url_check['scheme'] == 'https'){
114
+ $flag = TRUE;
115
  }else{
116
+ $flag = FALSE;
117
  }
118
 
119
  if($flag == TRUE){
180
  case 'pinterest':
181
  $count = $this->get_count( $key, $url );
182
 
183
+ if(isset($http_url_checked) && $http_url_checked == '1'){
184
  $url_check = parse_url($url);
185
  if($url_check['scheme'] == 'https'){
186
+ $flag = TRUE;
187
  }else{
188
+ $flag = FALSE;
189
  }
190
 
191
  if($flag == TRUE){
239
  }
240
  }
241
  }
 
242
  ?>
 
243
  <div class='apss-linkedin apss-single-icon'>
244
  <a rel='nofollow' <?php if($apss_link_open_option_value == 2){ ?> onclick="apss_open_in_popup_window(event, '<?php echo $link; ?>');" <?php } ?> title="<?php _e( 'Share on LinkedIn', 'accesspress-social-share' ); ?>" target='<?php echo $apss_link_open_option; ?>' href='<?php echo $link; ?>'>
245
  <div class='apss-icon-block clearfix'><i class='fa fa-linkedin'></i>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Access Keys
3
  Tags: social share counter, social share, social media share, social network share, social media, social network, share counter, social share count, social url share, social icons
4
  Donate link: http://accesspressthemes.com/donation/
5
  Requires at least: 3.8
6
- Tested up to: 5.0
7
- Stable tag: 4.4.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -157,6 +157,12 @@ Yes. You can use the AccessPress social share by using shortcode anywhere you wa
157
 
158
  == Changelog ==
159
 
 
 
 
 
 
 
160
 
161
  = 4.4.3 =
162
  *General Bug Fixes in the plugin.
3
  Tags: social share counter, social share, social media share, social network share, social media, social network, share counter, social share count, social url share, social icons
4
  Donate link: http://accesspressthemes.com/donation/
5
  Requires at least: 3.8
6
+ Tested up to: 5.2.1
7
+ Stable tag: 4.4.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
157
 
158
  == Changelog ==
159
 
160
+ = 4.4.5 =
161
+ * Bug fix related to Facebook Share Count
162
+
163
+ = 4.4.4 =
164
+ * Refinement in the code
165
+ * Checked plugin compactibility with wordpress version 5.2x
166
 
167
  = 4.4.3 =
168
  *General Bug Fixes in the plugin.