Shariff Wrapper - Version 4.1.2

Version Description

  • new fallback for share count requests in case pretty permalinks are disabled
  • new filter shariff3UU_render_atts to change options on the fly (thx Ov3rfly)
  • fix share title in cases with html encoded characters
  • fix double counting on ranking tab under certain conditions
  • fix php info notice in admin notices
Download this release

Release Info

Developer starguide
Plugin Icon 128x128 Shariff Wrapper
Version 4.1.2
Comparing to
See all releases

Code changes from version 4.1.1 to 4.1.2

Files changed (5) hide show
  1. admin/admin_notices.php +1 -1
  2. js/shariff.js +3 -3
  3. js/shariff.min.js +1 -1
  4. readme.txt +8 -1
  5. shariff.php +16 -6
admin/admin_notices.php CHANGED
@@ -73,7 +73,7 @@ add_action( 'admin_notices', 'shariff3UU_bitcoin_notice' );
73
 
74
  // display an info notice if mailform is set as a service, but mail form functionality has been disabled
75
  function shariff3UU_mail_notice() {
76
- if ( isset( $GLOBALS["shariff3UU_mailform"]["disable_mailform"] ) && ( strpos( $GLOBALS["shariff3UU_basic"]["services"], 'mailform' ) !== false ) && isset( $GLOBALS["shariff3UU"]["disable_mailform"] ) && $GLOBALS["shariff3UU"]["disable_mailform"] == '1' && current_user_can( 'manage_options' ) ) {
77
  echo "<div class='error'><p>" . __('Please check your ', 'shariff') . "<a href='" . get_bloginfo('wpurl') . "/wp-admin/options-general.php?page=shariff3uu&tab=mailform'>" . __('Shariff-Settings</a> - Mailform has been selected as a service, but mail form functionality is disabled!', 'shariff') . "</span></p></div>";
78
  }
79
  }
73
 
74
  // display an info notice if mailform is set as a service, but mail form functionality has been disabled
75
  function shariff3UU_mail_notice() {
76
+ if ( isset( $GLOBALS["shariff3UU_mailform"]["disable_mailform"] ) && ( isset( $GLOBALS["shariff3UU_basic"]["services"] ) && strpos( $GLOBALS["shariff3UU_basic"]["services"], 'mailform' ) !== false ) && isset( $GLOBALS["shariff3UU"]["disable_mailform"] ) && $GLOBALS["shariff3UU"]["disable_mailform"] == '1' && current_user_can( 'manage_options' ) ) {
77
  echo "<div class='error'><p>" . __('Please check your ', 'shariff') . "<a href='" . get_bloginfo('wpurl') . "/wp-admin/options-general.php?page=shariff3uu&tab=mailform'>" . __('Shariff-Settings</a> - Mailform has been selected as a service, but mail form functionality is disabled!', 'shariff') . "</span></p></div>";
78
  }
79
  }
js/shariff.js CHANGED
@@ -14,10 +14,10 @@ function shariff_share_counts() {
14
  // check if an external share count api is set
15
  var api = containers[c].dataset.backendurl;
16
  if ( typeof api === "undefined" ) {
17
- api = '/wp-json/shariff/v1/share_counts';
18
  }
19
  // build request url
20
- var request_url = api + '?url=' + share_url + '&services=' + services + '&timestamp=' + timestamp;
21
  // check if we have backend services at all
22
  if ( typeof services !== "undefined" ) {
23
  // check if the url is already in requests to avoid duplicated requests
@@ -31,7 +31,7 @@ function shariff_share_counts() {
31
  });
32
  services = service_array.join('|');
33
  // update request url
34
- request_url = api + '?url=' + share_url + '&services=' + services + '&timestamp=' + timestamp;
35
  // add to requests
36
  requests[ share_url ] = [ share_url, services, timestamp, request_url ];
37
  }
14
  // check if an external share count api is set
15
  var api = containers[c].dataset.backendurl;
16
  if ( typeof api === "undefined" ) {
17
+ api = '/wp-json/shariff/v1/share_counts?';
18
  }
19
  // build request url
20
+ var request_url = api + 'url=' + share_url + '&services=' + services + '&timestamp=' + timestamp;
21
  // check if we have backend services at all
22
  if ( typeof services !== "undefined" ) {
23
  // check if the url is already in requests to avoid duplicated requests
31
  });
32
  services = service_array.join('|');
33
  // update request url
34
+ request_url = api + 'url=' + share_url + '&services=' + services + '&timestamp=' + timestamp;
35
  // add to requests
36
  requests[ share_url ] = [ share_url, services, timestamp, request_url ];
37
  }
js/shariff.min.js CHANGED
@@ -1 +1 @@
1
- function shariff_share_counts(){"use strict";for(var e=document.getElementsByClassName("shariff"),t={},s=0;e[s];s++){var a=e[s].dataset.url,n=e[s].dataset.services,r=e[s].dataset.timestamp,f=e[s].dataset.backendurl;"undefined"==typeof f&&(f="/wp-json/shariff/v1/share_counts");var i=f+"?url="+a+"&services="+n+"&timestamp="+r;if("undefined"!=typeof n)if(t[a]){n=t[a][1]+"|"+n;var o=n.split("|");o=o.filter(function(e,t,s){return s.indexOf(e)==t}),n=o.join("|"),i=f+"?url="+a+"&services="+n+"&timestamp="+r,t[a]=[a,n,r,i]}else t[a]=[a,n,r,i]}for(var u in t)t.hasOwnProperty(u)&&shariff_get_share_counts(t[u][0],t[u][3],e)}function shariff_get_share_counts(e,t,s){var a=new XMLHttpRequest;a.open("GET",t,!0),a.onload=function(){a.status>=200&&a.status<400&&shariff_add_share_counts(e,JSON.parse(a.responseText),s)},a.send()}function shariff_add_share_counts(e,t,s){for(var a=0;s[a];a++)if(s[a].dataset.url==e){for(var n=s[a].getElementsByClassName("shariff-totalnumber"),r=0;n[r];r++)null!==t&&"undefined"!=typeof t.total&&(n[r].innerHTML=t.total);for(var f=s[a].getElementsByClassName("shariff-total"),i=0;f[i];i++)null!==t&&"undefined"!=typeof t.total&&(f[i].innerHTML=t.total);for(var o=s[a].getElementsByClassName("shariff-count"),u=0;o[u];u++)null!==t&&"undefined"!=typeof t[o[u].dataset.service]&&(o[u].innerHTML=t[o[u].dataset.service],o[u].style.opacity="1")}}document.addEventListener("DOMContentLoaded",shariff_share_counts,!1);
1
+ function shariff_share_counts(){"use strict";for(var e=document.getElementsByClassName("shariff"),t={},s=0;e[s];s++){var a=e[s].dataset.url,n=e[s].dataset.services,r=e[s].dataset.timestamp,f=e[s].dataset.backendurl;"undefined"==typeof f&&(f="/wp-json/shariff/v1/share_counts?");var i=f+"url="+a+"&services="+n+"&timestamp="+r;if("undefined"!=typeof n)if(t[a]){n=t[a][1]+"|"+n;var o=n.split("|");o=o.filter(function(e,t,s){return s.indexOf(e)==t}),n=o.join("|"),i=f+"url="+a+"&services="+n+"&timestamp="+r,t[a]=[a,n,r,i]}else t[a]=[a,n,r,i]}for(var u in t)t.hasOwnProperty(u)&&shariff_get_share_counts(t[u][0],t[u][3],e)}function shariff_get_share_counts(e,t,s){var a=new XMLHttpRequest;a.open("GET",t,!0),a.onload=function(){a.status>=200&&a.status<400&&shariff_add_share_counts(e,JSON.parse(a.responseText),s)},a.send()}function shariff_add_share_counts(e,t,s){for(var a=0;s[a];a++)if(s[a].dataset.url==e){for(var n=s[a].getElementsByClassName("shariff-totalnumber"),r=0;n[r];r++)null!==t&&"undefined"!=typeof t.total&&(n[r].innerHTML=t.total);for(var f=s[a].getElementsByClassName("shariff-total"),i=0;f[i];i++)null!==t&&"undefined"!=typeof t.total&&(f[i].innerHTML=t.total);for(var o=s[a].getElementsByClassName("shariff-count"),u=0;o[u];u++)null!==t&&"undefined"!=typeof t[o[u].dataset.service]&&(o[u].innerHTML=t[o[u].dataset.service],o[u].style.opacity="1")}}document.addEventListener("DOMContentLoaded",shariff_share_counts,!1);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: 3UU, starguide
3
  Tags: Shariff, Facebook, Twitter, VKontakte, VK, GooglePlus, WhatsApp, share buttons, sharing, privacy, social
4
  Requires at least: 4.4
5
  Tested up to: 4.5
6
- Stable tag: 4.1.1
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
  Donate link: http://folge.link/?bitcoin=1Ritz1iUaLaxuYcXhUCoFhkVRH6GWiMTP
@@ -172,6 +172,13 @@ fixed in the future - if we have time to spend or you provide us with a lot of "
172
 
173
  == Changelog ==
174
 
 
 
 
 
 
 
 
175
  = 4.1.1 =
176
  - new option to disable the Shariff buttons outside of the main loop
177
  - fix Facebook App ID request
3
  Tags: Shariff, Facebook, Twitter, VKontakte, VK, GooglePlus, WhatsApp, share buttons, sharing, privacy, social
4
  Requires at least: 4.4
5
  Tested up to: 4.5
6
+ Stable tag: 4.1.2
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
  Donate link: http://folge.link/?bitcoin=1Ritz1iUaLaxuYcXhUCoFhkVRH6GWiMTP
172
 
173
  == Changelog ==
174
 
175
+ = 4.1.2 =
176
+ - new fallback for share count requests in case pretty permalinks are disabled
177
+ - new filter shariff3UU_render_atts to change options on the fly (thx Ov3rfly)
178
+ - fix share title in cases with html encoded characters
179
+ - fix double counting on ranking tab under certain conditions
180
+ - fix php info notice in admin notices
181
+
182
  = 4.1.1 =
183
  - new option to disable the Shariff buttons outside of the main loop
184
  - fix Facebook App ID request
shariff.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Shariff Wrapper
4
  * Plugin URI: https://de.wordpress.org/plugins/shariff/
5
  * Description: The Shariff Wrapper provides share buttons that respect the privacy of your visitors and are compliant to the German data protection laws.
6
- * Version: 4.1.1
7
  * Author: Jan-Peter Lambeck & 3UU
8
  * Author URI: https://de.wordpress.org/plugins/shariff/
9
  * License: MIT
@@ -26,7 +26,7 @@ $shariff3UU = array_merge( $shariff3UU_basic, $shariff3UU_design, $shariff3UU_ad
26
  // update function to perform tasks _once_ after an update, based on version number to work for automatic as well as manual updates
27
  function shariff3UU_update() {
28
  /******************** ADJUST VERSION ********************/
29
- $code_version = "4.1.1"; // set code version - needs to be adjusted for every new version!
30
  /******************** ADJUST VERSION ********************/
31
 
32
  // get options
@@ -194,6 +194,9 @@ function shariff3UU_share_counts( WP_REST_Request $request ) {
194
 
195
  // explode services
196
  $service_array = explode( '|', $real_services );
 
 
 
197
 
198
  // get old share counts
199
  if ( get_transient( $post_hash ) !== false ) $old_share_counts = get_transient( $post_hash );
@@ -506,6 +509,9 @@ function shariff3UU_render( $atts, $content = null ) {
506
  if ( empty( $atts ) ) $atts = $backend_options;
507
  else $atts = array_merge( $backend_options, $atts );
508
 
 
 
 
509
  // remove empty elements
510
  $atts = array_filter( $atts );
511
 
@@ -542,8 +548,8 @@ function shariff3UU_render( $atts, $content = null ) {
542
  else $share_url = urlencode( get_permalink() );
543
 
544
  // share title
545
- if ( array_key_exists( 'title', $atts ) ) $share_title = urlencode( $atts['title'] );
546
- else $share_title = urlencode( strip_tags( get_the_title() ) );
547
 
548
  // set transient name
549
  $post_hash = 'shariff' . hash( "md5", $share_url );
@@ -631,7 +637,11 @@ function shariff3UU_render( $atts, $content = null ) {
631
  }
632
  // elseif WP is installed in a subdirectory and the api is only reachable in there -> adjust path
633
  elseif ( isset( $shariff3UU["subapi"] ) && $shariff3UU["subapi"] == '1' ) {
634
- $output .= ' data-backendurl="' . get_bloginfo( 'wpurl' ) . '/wp-json/shariff/v1/share_counts' . '"';
 
 
 
 
635
  }
636
  }
637
  $output .= '>';
@@ -1067,7 +1077,7 @@ function sharif3UU_procSentMail( $content ) {
1067
  // include selected language
1068
  include( plugin_dir_path( __FILE__ ) . '/locale/mailform-' . $lang . '.php' );
1069
 
1070
- $subject = html_entity_decode( get_the_title() );
1071
 
1072
  // The following post was suggested to you by
1073
  $message[ $lang ] = $mf_mailbody1[ $lang ];
3
  * Plugin Name: Shariff Wrapper
4
  * Plugin URI: https://de.wordpress.org/plugins/shariff/
5
  * Description: The Shariff Wrapper provides share buttons that respect the privacy of your visitors and are compliant to the German data protection laws.
6
+ * Version: 4.1.2
7
  * Author: Jan-Peter Lambeck & 3UU
8
  * Author URI: https://de.wordpress.org/plugins/shariff/
9
  * License: MIT
26
  // update function to perform tasks _once_ after an update, based on version number to work for automatic as well as manual updates
27
  function shariff3UU_update() {
28
  /******************** ADJUST VERSION ********************/
29
+ $code_version = "4.1.2"; // set code version - needs to be adjusted for every new version!
30
  /******************** ADJUST VERSION ********************/
31
 
32
  // get options
194
 
195
  // explode services
196
  $service_array = explode( '|', $real_services );
197
+
198
+ // remove duplicated entries
199
+ $service_array = array_unique( $service_array );
200
 
201
  // get old share counts
202
  if ( get_transient( $post_hash ) !== false ) $old_share_counts = get_transient( $post_hash );
509
  if ( empty( $atts ) ) $atts = $backend_options;
510
  else $atts = array_merge( $backend_options, $atts );
511
 
512
+ // Ov3rfly: make atts configurable from outside, e.g. for language etc.
513
+ $atts = apply_filters( 'shariff3UU_render_atts', $atts );
514
+
515
  // remove empty elements
516
  $atts = array_filter( $atts );
517
 
548
  else $share_url = urlencode( get_permalink() );
549
 
550
  // share title
551
+ if ( array_key_exists( 'title', $atts ) ) $share_title = urlencode( html_entity_decode( get_the_title(), ENT_COMPAT, 'UTF-8' ) );
552
+ else $share_title = urlencode( html_entity_decode( get_the_title(), ENT_COMPAT, 'UTF-8' ) );
553
 
554
  // set transient name
555
  $post_hash = 'shariff' . hash( "md5", $share_url );
637
  }
638
  // elseif WP is installed in a subdirectory and the api is only reachable in there -> adjust path
639
  elseif ( isset( $shariff3UU["subapi"] ) && $shariff3UU["subapi"] == '1' ) {
640
+ $output .= ' data-backendurl="' . get_bloginfo( 'wpurl' ) . '/wp-json/shariff/v1/share_counts?' . '"';
641
+ }
642
+ // elseif pretty permalinks are not activated fall back to manual rest route
643
+ elseif ( ! get_option('permalink_structure') ) {
644
+ $output .= ' data-backendurl="?rest_route=/shariff/v1/share_counts&"';
645
  }
646
  }
647
  $output .= '>';
1077
  // include selected language
1078
  include( plugin_dir_path( __FILE__ ) . '/locale/mailform-' . $lang . '.php' );
1079
 
1080
+ $subject = html_entity_decode( get_the_title(), ENT_COMPAT, 'UTF-8' );
1081
 
1082
  // The following post was suggested to you by
1083
  $message[ $lang ] = $mf_mailbody1[ $lang ];