Social Share WordPress Plugin – AccessPress Social Share - Version 4.1.8

Version Description

  • Improved the facebook share counter using the facebook app. Now the user need to create facebook app to fetch share counts if old method is not working.
Download this release

Release Info

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

Code changes from version 4.1.7 to 4.1.8

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
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.1.7
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.1.7' );
34
  }
35
 
36
  if ( !defined( 'APSS_TEXT_DOMAIN' ) ) {
@@ -435,6 +435,89 @@ if ( !class_exists( 'APSS_Class' ) ) {
435
  return $facebook_count;
436
  }
437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  //for twitter url share count
439
  function get_tweets( $url ) {
440
  $apss_settings = $this->apss_settings;
@@ -620,7 +703,7 @@ if ( !class_exists( 'APSS_Class' ) ) {
620
  function get_count( $profile_name, $url ) {
621
  switch ( $profile_name ) {
622
  case 'facebook':
623
- $count = $this->get_fb( $url );
624
  break;
625
 
626
  case 'twitter':
4
  Plugin name: Social Share WordPress Plugin - AccessPress Social Share
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.1.8
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.1.8' );
34
  }
35
 
36
  if ( !defined( 'APSS_TEXT_DOMAIN' ) ) {
435
  return $facebook_count;
436
  }
437
 
438
+ /**
439
+ * Get Facebook Access Token
440
+ * */
441
+ function get_fb_access_token(){
442
+ $apss_settings = $this->apss_settings;
443
+ $app_id = $apss_settings['api_configuration']['facebook']['app_id'];
444
+ $app_secret = $apss_settings['api_configuration']['facebook']['app_secret'];
445
+ $api_url = 'https://graph.facebook.com/';
446
+ $app_id= $apss_settings['api_configuration']['facebook']['app_id']; // '1779750458903669' ;
447
+ $app_secret = $apss_settings['api_configuration']['facebook']['app_secret']; // 'd9adea962115a185d6ab275b33a8fef8';
448
+ $url = sprintf(
449
+ '%soauth/access_token?client_id=%s&client_secret=%s&grant_type=client_credentials',
450
+ $api_url,
451
+ $app_id ,
452
+ $app_secret
453
+ );
454
+
455
+ $access_token = wp_remote_get( $url, array( 'timeout' => 60 ) );
456
+ if ( is_wp_error( $access_token ) || ( isset( $access_token['response']['code'] ) && 200 != $access_token['response']['code'] ) ) {
457
+ return '';
458
+ } else {
459
+ return sanitize_text_field( $access_token['body'] );
460
+ }
461
+ }
462
+
463
+ function new_get_fb($url){
464
+ $apss_settings = $this->apss_settings;
465
+
466
+ if(isset($apss_settings['api_configuration']['facebook']['app_id']) && $apss_settings['api_configuration']['facebook']['app_id'] !='' ){
467
+ $fb_app_id = $apss_settings['api_configuration']['facebook']['app_id'];
468
+ }
469
+
470
+ if(isset($apss_settings['api_configuration']['facebook']['app_secret']) && $apss_settings['api_configuration']['facebook']['app_secret'] !='' ){
471
+ $fb_app_secret = $apss_settings['api_configuration']['facebook']['app_id'];
472
+ }
473
+
474
+ if(!isset($fb_app_id) || !isset($fb_app_secret)){
475
+ $facebook_count = self:: get_fb($url);
476
+ return $facebook_count;
477
+ }else{
478
+ $access_token = self:: get_fb_access_token();
479
+ $api_url = 'https://graph.facebook.com/v2.6/';
480
+ $facebook_count = sprintf(
481
+ '%s?%s&id=%s',
482
+ $api_url,
483
+ $access_token,
484
+ $url
485
+ );
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 );
493
+
494
+ //for setting the counter transient in separate options value
495
+ $apss_social_counts_transients = get_option( APSS_COUNT_TRANSIENTS );
496
+ if ( false === $fb_transient_count ) {
497
+ $json_string = $this->get_json_values($facebook_count);
498
+ $json = json_decode( $json_string, true );
499
+ $facebook_count = isset( $json['share']['share_count'] ) ? intval( $json['share']['share_count'] ) : 0;
500
+ set_transient( $fb_transient, $facebook_count, $cache_period * HOUR_IN_SECONDS );
501
+ if ( !in_array( $fb_transient, $apss_social_counts_transients ) ) {
502
+ $apss_social_counts_transients[] = $fb_transient;
503
+ update_option( APSS_COUNT_TRANSIENTS, $apss_social_counts_transients );
504
+ }
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
+ $facebook_count = isset( $json['share']['share_count'] ) ? intval( $json['share']['share_count'] ) : 0;
513
+ }
514
+ return $facebook_count;
515
+
516
+ }
517
+
518
+
519
+ }
520
+
521
  //for twitter url share count
522
  function get_tweets( $url ) {
523
  $apss_settings = $this->apss_settings;
703
  function get_count( $profile_name, $url ) {
704
  switch ( $profile_name ) {
705
  case 'facebook':
706
+ $count = $this->new_get_fb( $url );
707
  break;
708
 
709
  case 'twitter':
inc/backend/activation.php CHANGED
@@ -24,6 +24,10 @@ $apss_share_settings['share_text'] = '';
24
  $apss_share_settings['twitter_username'] = '';
25
  $apss_share_settings['counter_enable_options'] = '0';
26
  $apss_share_settings['twitter_counter_api'] = '1';
 
 
 
 
27
  $apss_share_settings['total_counter_enable_options'] = '0';
28
  $apss_share_settings['enable_cache'] = '1';
29
  $apss_share_settings['cache_period'] = '24';
24
  $apss_share_settings['twitter_username'] = '';
25
  $apss_share_settings['counter_enable_options'] = '0';
26
  $apss_share_settings['twitter_counter_api'] = '1';
27
+ $apss_share_settings['api_configuration']['facebook'] = array(
28
+ 'app_id'=> '',
29
+ 'app_secret'=>''
30
+ );
31
  $apss_share_settings['total_counter_enable_options'] = '0';
32
  $apss_share_settings['enable_cache'] = '1';
33
  $apss_share_settings['cache_period'] = '24';
inc/backend/main-page.php CHANGED
@@ -199,6 +199,15 @@
199
  <div class="apss_notes_cache_settings"> To use opensharecount public API, you have to sign up and register your website url <?php echo site_url(); ?> at their <a href='http://opensharecount.com/' target='_blank'>website</a>. </div>
200
  </div>
201
  <div class="apss_notes_cache_settings"> Note: If you switch the API please don't forget to clear cache for fetching new share counts.</div>
 
 
 
 
 
 
 
 
 
202
  </div>
203
 
204
  <div class="apss-total-counter-settings clearfix">
199
  <div class="apss_notes_cache_settings"> To use opensharecount public API, you have to sign up and register your website url <?php echo site_url(); ?> at their <a href='http://opensharecount.com/' target='_blank'>website</a>. </div>
200
  </div>
201
  <div class="apss_notes_cache_settings"> Note: If you switch the API please don't forget to clear cache for fetching new share counts.</div>
202
+
203
+ <div class="apss_counter-api">
204
+ <h4>If facebook counter is not working. Please setup the facebook APP and enter required details below.</h4>
205
+ <label for=apss_facebook_app_id"">APP ID: </label><input type='text' id="apss_facebook_app_id" name='apss_share_settings[api_configuration][facebook][app_id]' value="<?php if ( isset( $options['api_configuration']['facebook']['app_id'] ) ) { echo $options['api_configuration']['facebook']['app_id']; } ?>" />
206
+ <div class="apss_notes_cache_settings">Please go to <a href="https://developers.facebook.com/" target="_blank">https://developers.facebook.com/</a> and create an app and get the App ID</div>
207
+ <label for=apss_facebook_app_secret"">APP Secret: </label><input type='text' id="apss_facebook_app_secret" name='apss_share_settings[api_configuration][facebook][app_secret]' value="<?php if ( isset( $options['api_configuration']['facebook']['app_secret'] ) ) { echo $options['api_configuration']['facebook']['app_secret']; } ?>" />
208
+ <div class="apss_notes_cache_settings">Please go to <a href="https://developers.facebook.com/" target="_blank">https://developers.facebook.com/</a> and create an app and get the App Secret</div>
209
+ <div class="apss_notes_cache_settings">Please not that you should make your APP live.</div>
210
+ </div>
211
  </div>
212
 
213
  <div class="apss-total-counter-settings clearfix">
inc/backend/save-settings.php CHANGED
@@ -24,6 +24,14 @@ $apss_share_settings['share_text'] = sanitize_text_field( $_POST['apss_shar
24
  $apss_share_settings['twitter_username'] = stripslashes_deep( $_POST['apss_share_settings']['twitter_username'] );
25
  $apss_share_settings['counter_enable_options'] = $_POST['apss_share_settings']['counter_enable_options'];
26
  $apss_share_settings['twitter_counter_api'] = $_POST['apss_share_settings']['twitter_counter_api'];
 
 
 
 
 
 
 
 
27
  $apss_share_settings['total_counter_enable_options'] = $_POST['apss_share_settings']['total_counter_enable_options'];
28
  $apss_share_settings['enable_cache'] = $_POST['apss_share_settings']['enable_cache'];
29
  $apss_share_settings['cache_period'] = is_numeric( $_POST['apss_share_settings']['cache_settings'] ) ? $_POST['apss_share_settings']['cache_settings'] : '24';
24
  $apss_share_settings['twitter_username'] = stripslashes_deep( $_POST['apss_share_settings']['twitter_username'] );
25
  $apss_share_settings['counter_enable_options'] = $_POST['apss_share_settings']['counter_enable_options'];
26
  $apss_share_settings['twitter_counter_api'] = $_POST['apss_share_settings']['twitter_counter_api'];
27
+
28
+ $fb_app_id = isset( $_POST['apss_share_settings']['api_configuration']['facebook']['app_id'] ) ? $_POST['apss_share_settings']['api_configuration']['facebook']['app_id'] : '';
29
+ $fb_app_secret = isset( $_POST['apss_share_settings']['api_configuration']['facebook']['app_secret'] ) ? $_POST['apss_share_settings']['api_configuration']['facebook']['app_secret'] : '';
30
+ $apss_share_settings['api_configuration']['facebook'] = array(
31
+ 'app_id'=> $fb_app_id,
32
+ 'app_secret'=>$fb_app_secret
33
+ );
34
+
35
  $apss_share_settings['total_counter_enable_options'] = $_POST['apss_share_settings']['total_counter_enable_options'];
36
  $apss_share_settings['enable_cache'] = $_POST['apss_share_settings']['enable_cache'];
37
  $apss_share_settings['cache_period'] = is_numeric( $_POST['apss_share_settings']['cache_settings'] ) ? $_POST['apss_share_settings']['cache_settings'] : '24';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: social share counter, social share, social media share, social network sha
4
  Donate link: http://accesspressthemes.com/donation/
5
  Requires at least: 3.8
6
  Tested up to: 4.6
7
- Stable tag: 4.1.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -133,6 +133,9 @@ Yes. You can use the AccessPress social share by using shortcode anywhere you wa
133
  6. Backend Miscellaneous Settings Section
134
 
135
  == Changelog ==
 
 
 
136
  = 4.1.7 =
137
  * Fixed the facebook share count issue.
138
 
4
  Donate link: http://accesspressthemes.com/donation/
5
  Requires at least: 3.8
6
  Tested up to: 4.6
7
+ Stable tag: 4.1.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
133
  6. Backend Miscellaneous Settings Section
134
 
135
  == Changelog ==
136
+ = 4.1.8 =
137
+ * Improved the facebook share counter using the facebook app. Now the user need to create facebook app to fetch share counts if old method is not working.
138
+
139
  = 4.1.7 =
140
  * Fixed the facebook share count issue.
141