Version Description
- Fix: Share count not collected with async caching method
Download this release
Release Info
Developer | ReneHermi |
Plugin | Social Media Share Buttons | MashShare |
Version | 3.6.5 |
Comparing to | |
See all releases |
Code changes from version 3.6.3 to 3.6.5
- assets/js/mashsb.js +3 -1
- assets/js/mashsb.min.js +1 -1
- includes/admin/settings/register-settings.php +1 -1
- includes/install.php +3 -1
- includes/scripts.php +2 -1
- includes/sharecount-functions.php +86 -1
- includes/sharedcount.class.php +1 -1
- mashshare.php +3 -3
- readme.txt +12 -4
assets/js/mashsb.js
CHANGED
@@ -11,6 +11,8 @@ jQuery(document).ready(function ($) {
|
|
11 |
* Get facebook share count vi js client request
|
12 |
*
|
13 |
* @returns {undefined}
|
|
|
|
|
14 |
*/
|
15 |
var mashsb_get_fb_shares = function ()
|
16 |
{
|
@@ -56,7 +58,7 @@ jQuery(document).ready(function ($) {
|
|
56 |
}
|
57 |
// Make sure page has been loaded completely before requesting any shares via ajax
|
58 |
// This also prevents hitting the server too often
|
59 |
-
setTimeout(mashsb_get_fb_shares, 3000);
|
60 |
|
61 |
/**
|
62 |
* If page is older than 30 second it's cached. So do not call FB API again
|
11 |
* Get facebook share count vi js client request
|
12 |
*
|
13 |
* @returns {undefined}
|
14 |
+
*
|
15 |
+
* not used any longer
|
16 |
*/
|
17 |
var mashsb_get_fb_shares = function ()
|
18 |
{
|
58 |
}
|
59 |
// Make sure page has been loaded completely before requesting any shares via ajax
|
60 |
// This also prevents hitting the server too often
|
61 |
+
//setTimeout(mashsb_get_fb_shares, 3000);
|
62 |
|
63 |
/**
|
64 |
* If page is older than 30 second it's cached. So do not call FB API again
|
assets/js/mashsb.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var strict;jQuery(document).ready(function(a){function b(){if("undefined"==typeof mashsb.servertime)return!0;var a=Number(mashsb.servertime),b=Math.floor(Date.now()/1e3);return b>a+30?(console.log("rate limited: "+(a+30)),!0):(console.log("not rate limited: "+(a+30)),!1)}function c(
|
1 |
+
var strict;jQuery(document).ready(function(a){function b(){if("undefined"==typeof mashsb.servertime)return!0;var a=Number(mashsb.servertime),b=Math.floor(Date.now()/1e3);return b>a+30?(console.log("rate limited: "+(a+30)),!0):(console.log("not rate limited: "+(a+30)),!1)}function c(){return b()?!1:void setTimeout(function(){"1"==mashsb.refresh&&d()},6e3)}function d(){var a=window.location.href;a+=a.indexOf("?")>-1?"&mashsb-refresh":"?mashsb-refresh";var b=new XMLHttpRequest;b.open("GET",a,!0),b.send()}function e(a){if("undefined"!=typeof mashsb&&1==mashsb.round_shares){if(a>1e6)return shares=Math.round(a/1e6*10)/10+"M",shares;if(a>1e3)return shares=Math.round(a/1e3*10)/10+"k",shares}return a.toFixed(0)}(navigator.userAgent.match(/(iPhone)/i)||navigator.userAgent.match(/(Android)/i))&&a(".mashicon-whatsapp").show();a("body").off("click",".mashicon-pinterest").on("click",".mashicon-pinterest",function(b){b.preventDefault(),console.log("preventDefault:"+b),winWidth=520,winHeight=350;var c=screen.height/2-winHeight/2,d=screen.width/2-winWidth/2,e=a(this).attr("data-mashsb-url");window.open(e,"sharer","top="+c+",left="+d+",toolbar=0,status=0,width="+winWidth+",height="+winHeight+",resizable=yes")}),""==a(".mashsbcount").text()&&a(".mashsbcount").text(0),c(),a(".onoffswitch").on("click",function(){var b=a(this).parents(".mashsb-container");b.find(".onoffswitch").hide(),b.find(".secondary-shares").show(),b.find(".onoffswitch2").show()}),a(".onoffswitch2").on("click",function(){var b=a(this).parents(".mashsb-container");b.find(".onoffswitch").show(),b.find(".secondary-shares").hide()}),"undefined"==typeof lashare_fb&&"undefined"!=typeof mashsb&&a(".mashicon-facebook").click(function(b){winWidth=520,winHeight=550;var c=screen.height/2-winHeight/2,d=screen.width/2-winWidth/2,e=a(this).attr("href");return window.open(e,"sharer","top="+c+",left="+d+",toolbar=0,status=0,width="+winWidth+",height="+winHeight),b.preventDefault(),!1}),"undefined"!=typeof mashsb&&a(".mashicon-twitter").click(function(b){winWidth=520,winHeight=350;var c=screen.height/2-winHeight/2,d=screen.width/2-winWidth/2,e=a(this).attr("href");return"1"===mashsb.twitter_popup&&window.open(e,"sharer","top="+c+",left="+d+",toolbar=0,status=0,width="+winWidth+",height="+winHeight),b.preventDefault(),!1}),"undefined"!=typeof mashsb&&"content"===mashsb.subscribe&&(a(".mashicon-subscribe").not(".trigger_active").nearest(".mashsb-toggle-container").hide(),a(".mashicon-subscribe").click(function(){var b=a(this);return b.hasClass("trigger_active")?(a(b).nearest(".mashsb-toggle-container").slideToggle("fast"),b.removeClass("trigger_active")):(a(".trigger_active").nearest(".mashsb-toggle-container").slideToggle("slow"),a(".trigger_active").removeClass("trigger_active"),a(b).nearest(".mashsb-toggle-container").slideToggle("fast"),b.addClass("trigger_active")),!1})),"undefined"!=typeof mashsb&&"link"===mashsb.subscribe&&a(".mashicon-subscribe").click(function(){var b=mashsb.subscribe_url;a(this).attr("href",b)}),function(a){a.fn.countTo=function(b){return b=b||{},a(this).each(function(){function c(){k+=g,j++,d(k),"function"==typeof e.onUpdate&&e.onUpdate.call(h,k),j>=f&&(i.removeData("countTo"),clearInterval(l.interval),k=e.to,"function"==typeof e.onComplete&&e.onComplete.call(h,k))}function d(a){var b=e.formatter.call(h,a,e);i.text(b)}var e=a.extend({},a.fn.countTo.defaults,{from:a(this).data("from"),to:a(this).data("to"),speed:a(this).data("speed"),refreshInterval:a(this).data("refresh-interval"),decimals:a(this).data("decimals")},b),f=Math.ceil(e.speed/e.refreshInterval),g=(e.to-e.from)/f,h=this,i=a(this),j=0,k=e.from,l=i.data("countTo")||{};i.data("countTo",l),l.interval&&clearInterval(l.interval),l.interval=setInterval(c,e.refreshInterval),d(k)})},a.fn.countTo.defaults={from:0,to:0,speed:1e3,refreshInterval:100,decimals:0,formatter:e,onUpdate:null,onComplete:null}}(jQuery),"undefined"!=typeof mashsb&&1==mashsb.animate_shares&&a(".mashsbcount").length&&a(".mashsbcount").countTo({from:0,to:mashsb.shares,speed:1e3,refreshInterval:100})}),function(a,b){a.fn.nearest=function(c){function d(b){f=f?f.add(b):a(b)}var e,f,g,h,i,j=b.querySelectorAll;return this.each(function(){e=this,a.each(c.split(","),function(){if(h=a.trim(this),h.indexOf("#"))for(i=e.parentNode;i;){if(g=j?i.querySelectorAll(h):a(i).find(h),g.length){d(g);break}i=i.parentNode}else d(j?b.querySelectorAll(h):a(h))})}),f||a()}}(jQuery,document);
|
includes/admin/settings/register-settings.php
CHANGED
@@ -150,7 +150,7 @@ function mashsb_get_registered_settings() {
|
|
150 |
'caching_method' => array(
|
151 |
'id' => 'caching_method',
|
152 |
'name' => __( 'Caching Method', 'mashsb' ),
|
153 |
-
'desc' => sprintf(__( '
|
154 |
'type' => 'select',
|
155 |
'options' => array(
|
156 |
'async_cache' => 'Async Cache Refresh',
|
150 |
'caching_method' => array(
|
151 |
'id' => 'caching_method',
|
152 |
'name' => __( 'Caching Method', 'mashsb' ),
|
153 |
+
'desc' => sprintf(__( '<strong>Async Cache Refresh</strong> <br/>Refreshes the cache asyncronously in the background. <br><br>- New posts are updated at each hour. <br>- Posts older than 3 weeks are updated every 4 hours<br>- Post older than 2 months are updated every 12 hours<br><br> <strong>Refresh while loading</strong> <br/> Rebuilds expired cache while page is loaded after cache expiration time. <br><br><strong>If shares are not updating</strong> or site is heavy cached activate <i>Refresh while loading!</i> <br/>That\'s the default method.<br>Shares still not shown? <a href="%1s" target="_blank">Read this first!</a>', 'mashsb' ), 'http://docs.mashshare.net/article/4-try-this-first-before-troubleshooting'),
|
154 |
'type' => 'select',
|
155 |
'options' => array(
|
156 |
'async_cache' => 'Async Cache Refresh',
|
includes/install.php
CHANGED
@@ -123,7 +123,9 @@ function mashsb_install() {
|
|
123 |
* Setup the default network options
|
124 |
* Store our initial social networks in separate option row.
|
125 |
*/
|
126 |
-
|
|
|
|
|
127 |
$networks = array(
|
128 |
'Facebook',
|
129 |
'Twitter',
|
123 |
* Setup the default network options
|
124 |
* Store our initial social networks in separate option row.
|
125 |
*/
|
126 |
+
|
127 |
+
$networks = get_option('mashsb_networks');
|
128 |
+
if( is_plugin_inactive( 'mashshare-networks/mashshare-networks.php' ) || false === $networks || empty($networks) ) {
|
129 |
$networks = array(
|
130 |
'Facebook',
|
131 |
'Twitter',
|
includes/scripts.php
CHANGED
@@ -72,7 +72,8 @@ function mashsb_load_scripts( $hook ) {
|
|
72 |
|
73 |
$status = apply_filters('mashsbStatus', false);
|
74 |
|
75 |
-
$refresh =
|
|
|
76 |
|
77 |
wp_localize_script( 'mashsb', 'mashsb', array(
|
78 |
'shares' => isset($post->ID) ? mashsb_get_total_shares_post_meta($post->ID) + (int)getFakecount() : false,
|
72 |
|
73 |
$status = apply_filters('mashsbStatus', false);
|
74 |
|
75 |
+
$refresh = mashsb_is_async_cache_refresh() ? 1 : 0;
|
76 |
+
//$refresh = 0;
|
77 |
|
78 |
wp_localize_script( 'mashsb', 'mashsb', array(
|
79 |
'shares' => isset($post->ID) ? mashsb_get_total_shares_post_meta($post->ID) + (int)getFakecount() : false,
|
includes/sharecount-functions.php
CHANGED
@@ -281,6 +281,91 @@ function mashsb_is_cache_refresh() {
|
|
281 |
|
282 |
return false;
|
283 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
/**
|
286 |
* Check via ajax if cache should be updated
|
@@ -321,7 +406,7 @@ function mashsb_get_expiration_method_async() {
|
|
321 |
$seconds = apply_filters('mashsb_refresh_21_days', 14400);
|
322 |
} else {
|
323 |
// expire cache after one hour
|
324 |
-
$seconds = apply_filters('mashsb_refresh_1_hour', 3600)
|
325 |
}
|
326 |
|
327 |
return $seconds;
|
281 |
|
282 |
return false;
|
283 |
}
|
284 |
+
/**
|
285 |
+
* Check if cache time is expired and post must be refreshed
|
286 |
+
* This is used for the caching method async only
|
287 |
+
*
|
288 |
+
* @global array $post
|
289 |
+
* @return boolean
|
290 |
+
*/
|
291 |
+
function mashsb_is_async_cache_refresh() {
|
292 |
+
global $post, $mashsb_options;
|
293 |
+
|
294 |
+
// Never
|
295 |
+
if (isset($mashsb_options['refresh_loading'])){
|
296 |
+
return false;
|
297 |
+
}
|
298 |
+
|
299 |
+
if (isset($mashsb_options['disable_sharecount'])){
|
300 |
+
return false;
|
301 |
+
}
|
302 |
+
|
303 |
+
// Force Cache Reload
|
304 |
+
if( isset( $_GET['mashsb-refresh'] ) ) {
|
305 |
+
return true;
|
306 |
+
}
|
307 |
+
|
308 |
+
// Preview Mode
|
309 |
+
if( isset($_GET['preview_id'] ) ) {
|
310 |
+
return false;
|
311 |
+
}
|
312 |
+
|
313 |
+
|
314 |
+
// Debug mode or cache activated
|
315 |
+
if( MASHSB_DEBUG || isset( $mashsb_options['disable_cache'] ) ) {
|
316 |
+
MASHSB()->logger->info( 'mashsb_is_cache_refresh: MASHSB_DEBUG - refresh Cache' );
|
317 |
+
return true;
|
318 |
+
}
|
319 |
+
|
320 |
+
// if it's a crawl deactivate cache
|
321 |
+
if( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'] ) ) {
|
322 |
+
return false;
|
323 |
+
}
|
324 |
+
|
325 |
+
/*
|
326 |
+
* Deactivate share count on:
|
327 |
+
* - 404 pages
|
328 |
+
* - search page
|
329 |
+
* - empty url
|
330 |
+
* - disabled permalinks
|
331 |
+
* - admin pages
|
332 |
+
*
|
333 |
+
Exit here to save cpu time
|
334 |
+
*/
|
335 |
+
|
336 |
+
if( is_admin() || is_404() || is_search() || !mashsb_is_enabled_permalinks() ) {
|
337 |
+
return false;
|
338 |
+
}
|
339 |
+
|
340 |
+
/*
|
341 |
+
* Refreshing cache on multiple blog posts like categories will lead
|
342 |
+
* to high load and multiple API requests so we only check
|
343 |
+
* the main url
|
344 |
+
*/
|
345 |
+
if( !is_singular() || !isset($post->ID) ) {
|
346 |
+
return false;
|
347 |
+
}
|
348 |
+
$last_updated = 0;
|
349 |
+
$last_updated = get_post_meta( $post->ID, 'mashsb_timestamp', true );
|
350 |
+
|
351 |
+
// No timestamp! So let's create cache for the first time
|
352 |
+
if( empty( $last_updated ) || $last_updated < 0 ) {
|
353 |
+
// Write timestamp (Use this on top of this condition. If this is not on top following return statements will be skipped and ignored - possible bug?)
|
354 |
+
return true;
|
355 |
+
}
|
356 |
+
|
357 |
+
// The caching expiration
|
358 |
+
$expiration = mashsb_get_expiration();
|
359 |
+
$next_update = $last_updated + $expiration;
|
360 |
+
|
361 |
+
// Refresh Cache when last update plus expiration time is older than current time
|
362 |
+
if( ($last_updated + $expiration) <= time() ) {
|
363 |
+
// Write timestamp (Use this on top of this condition. If this is not on top following return statements will be skipped and ignored - possible bug?)
|
364 |
+
return true;
|
365 |
+
}
|
366 |
+
|
367 |
+
return false;
|
368 |
+
}
|
369 |
|
370 |
/**
|
371 |
* Check via ajax if cache should be updated
|
406 |
$seconds = apply_filters('mashsb_refresh_21_days', 14400);
|
407 |
} else {
|
408 |
// expire cache after one hour
|
409 |
+
$seconds = apply_filters('mashsb_refresh_1_hour', 3600);
|
410 |
}
|
411 |
|
412 |
return $seconds;
|
includes/sharedcount.class.php
CHANGED
@@ -107,7 +107,7 @@ class mashsbSharedcount {
|
|
107 |
break;
|
108 |
default:
|
109 |
$counts['shares']['fb'] = $sharecounts['Facebook']['share_count'];
|
110 |
-
$counts['shares']['fb_https'] = $sharecounts['https']['Facebook']['share_count'];
|
111 |
}
|
112 |
isset( $sharecounts['Twitter'] ) ? $counts['shares']['tw'] = $sharecounts['Twitter'] : $counts['shares']['tw'] = 0;
|
113 |
isset( $sharecounts['GooglePlusOne'] ) ? $counts['shares']['gp'] = $sharecounts['GooglePlusOne'] : $counts['shares']['gp'] = 0;
|
107 |
break;
|
108 |
default:
|
109 |
$counts['shares']['fb'] = $sharecounts['Facebook']['share_count'];
|
110 |
+
$counts['shares']['fb_https'] = isset($sharecounts['https']['Facebook']['share_count']) ? $sharecounts['https']['Facebook']['share_count'] : '';
|
111 |
}
|
112 |
isset( $sharecounts['Twitter'] ) ? $counts['shares']['tw'] = $sharecounts['Twitter'] : $counts['shares']['tw'] = 0;
|
113 |
isset( $sharecounts['GooglePlusOne'] ) ? $counts['shares']['gp'] = $sharecounts['GooglePlusOne'] : $counts['shares']['gp'] = 0;
|
mashshare.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Description: Mashshare is a Share functionality inspired by the the great website Mashable for Facebook and Twitter. More networks available.
|
7 |
* Author: René Hermenau
|
8 |
* Author URI: https://www.mashshare.net
|
9 |
-
* Version: 3.6.
|
10 |
* Text Domain: mashsb
|
11 |
* Domain Path: /languages
|
12 |
|
@@ -35,7 +35,7 @@ if( !defined( 'ABSPATH' ) )
|
|
35 |
|
36 |
// Plugin version
|
37 |
if( !defined( 'MASHSB_VERSION' ) ) {
|
38 |
-
define( 'MASHSB_VERSION', '3.6.
|
39 |
}
|
40 |
|
41 |
// Debug mode
|
@@ -44,7 +44,7 @@ if( !defined( 'MASHSB_DEBUG' ) ) {
|
|
44 |
}
|
45 |
|
46 |
|
47 |
-
if( !class_exists( '
|
48 |
|
49 |
/**
|
50 |
* Main mashsb Class
|
6 |
* Description: Mashshare is a Share functionality inspired by the the great website Mashable for Facebook and Twitter. More networks available.
|
7 |
* Author: René Hermenau
|
8 |
* Author URI: https://www.mashshare.net
|
9 |
+
* Version: 3.6.5
|
10 |
* Text Domain: mashsb
|
11 |
* Domain Path: /languages
|
12 |
|
35 |
|
36 |
// Plugin version
|
37 |
if( !defined( 'MASHSB_VERSION' ) ) {
|
38 |
+
define( 'MASHSB_VERSION', '3.6.5' );
|
39 |
}
|
40 |
|
41 |
// Debug mode
|
44 |
}
|
45 |
|
46 |
|
47 |
+
if( !class_exists( 'Mashshare' ) ) :
|
48 |
|
49 |
/**
|
50 |
* Main mashsb Class
|
readme.txt
CHANGED
@@ -8,8 +8,8 @@ License: GPLv2 or later
|
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Tags: Share buttons, Social Sharing, social media, Facebook, Twitter, Subscribe, Traffic posts, pages, widget, social share buttons, analytics, email, dsgvo
|
10 |
Requires at least: 3.6+
|
11 |
-
Tested up to: 5.
|
12 |
-
Stable tag: 3.6.
|
13 |
Requires PHP: 5.2
|
14 |
|
15 |
Social Media Share Buttons for Twitter, Facebook and other social networks. Highly customizable Social Media ecosystem
|
@@ -250,6 +250,14 @@ Read here more about this: http://docs.mashshare.net/article/10-facebook-is-show
|
|
250 |
|
251 |
== Changelog ==
|
252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
= 3.6.3 =
|
254 |
* Fix: Option Cumulate Http(s) Shares not working for sharedcount.com API endpoint
|
255 |
* Fix: Tweets can be requested via opensharecount.com
|
@@ -315,7 +323,7 @@ https://www.mashshare.net/changelog/
|
|
315 |
|
316 |
== Upgrade Notice ==
|
317 |
|
318 |
-
= 3.6.
|
319 |
-
* Fix:
|
320 |
|
321 |
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Tags: Share buttons, Social Sharing, social media, Facebook, Twitter, Subscribe, Traffic posts, pages, widget, social share buttons, analytics, email, dsgvo
|
10 |
Requires at least: 3.6+
|
11 |
+
Tested up to: 5.2
|
12 |
+
Stable tag: 3.6.5
|
13 |
Requires PHP: 5.2
|
14 |
|
15 |
Social Media Share Buttons for Twitter, Facebook and other social networks. Highly customizable Social Media ecosystem
|
250 |
|
251 |
== Changelog ==
|
252 |
|
253 |
+
= 3.6.5 =
|
254 |
+
* Fix: Share count not collected with async caching method
|
255 |
+
|
256 |
+
= 3.6.5 =
|
257 |
+
* New: Compatible up to WordPress 5.2
|
258 |
+
* Fix: Do not call the facebook api directly any longer
|
259 |
+
* Fix: Undefined variable notice after uninstallation and deleting all MashShare settings an installation again
|
260 |
+
|
261 |
= 3.6.3 =
|
262 |
* Fix: Option Cumulate Http(s) Shares not working for sharedcount.com API endpoint
|
263 |
* Fix: Tweets can be requested via opensharecount.com
|
323 |
|
324 |
== Upgrade Notice ==
|
325 |
|
326 |
+
= 3.6.5 =
|
327 |
+
* Fix: Share count not collected with async caching method
|
328 |
|
329 |
|