Social Media Share Buttons | MashShare - Version 3.7.0

Version Description

  • Fix: PHP Warning: Invalid argument supplied for foreach() in meta-box.php
  • Fix: Set the share count query rate limit to 1req/5min
  • New: Compatible up to WordPress 5.2.4
Download this release

Release Info

Developer ReneHermi
Plugin Icon 128x128 Social Media Share Buttons | MashShare
Version 3.7.0
Comparing to
See all releases

Code changes from version 3.6.9 to 3.7.0

assets/js/mashsb.js CHANGED
@@ -1,488 +1,488 @@
1
- var strict;
2
-
3
- jQuery(document).ready(function ($) {
4
-
5
- /* Show Whatsapp button on mobile devices iPhones and Android only */
6
- if (navigator.userAgent.match(/(iPhone)/i) || navigator.userAgent.match(/(Android)/i)) {
7
- $('.mashicon-whatsapp').show();
8
- }
9
-
10
- /**
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
- {
19
-
20
-
21
- if (document.querySelector('.mashsb-buttons') === null) {
22
- return false;
23
- }
24
-
25
- if ('undefined' !== typeof (mashsb.refresh) && mashsb.refresh === '0') {
26
- return false;
27
- }
28
-
29
- if ('undefined' === typeof (mashsb.share_url) && mashsb.share_url !== '') {
30
- return false;
31
- }
32
-
33
- if ('undefined' === typeof (mashsb.postid) && mashsb.postid !== '') {
34
- return false;
35
- }
36
-
37
- if (mashsb_is_rate_limit()) {
38
- return false;
39
- }
40
-
41
- //mashsb.share_url = 'https://www.google.de';
42
-
43
- var facebookGraphURL = 'https://graph.facebook.com/?id=' + mashsb.share_url;
44
- $.ajax({
45
- type: 'GET',
46
- url: facebookGraphURL,
47
- dataType: 'json',
48
- success: function (data) {
49
- mashsb_set_fb_sharecount(data);
50
- console.log(data);
51
- },
52
- error: function (e) {
53
- console.log(e)
54
- }
55
- })
56
-
57
-
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
65
- * @returns {Boolean}
66
- */
67
- function mashsb_is_rate_limit() {
68
-
69
- if ("undefined" === typeof (mashsb.servertime)) {
70
- return true;
71
- }
72
-
73
- var serverTime = Number(mashsb.servertime);
74
- var clientTime = Math.floor(Date.now() / 1000);
75
-
76
- if (clientTime > (serverTime + 30)) {
77
- console.log('rate limited: ' + (serverTime + 30));
78
- return true;
79
- } else {
80
- console.log('not rate limited: ' + (serverTime + 30));
81
- return false;
82
- }
83
- }
84
-
85
- /**
86
- * Store FB return data in mashshare cache vi js client request
87
- * @returns {undefined}
88
- */
89
- function mashsb_set_fb_sharecount(result) {
90
-
91
- if ('undefined' === typeof (result.share)) {
92
- console.log('No valid result' + result);
93
- return false;
94
- }
95
-
96
- var data = {
97
- action: 'mashsb_set_fb_shares',
98
- shares: result.share,
99
- postid: mashsb.postid,
100
- url: mashsb.share_url,
101
- nonce: mashsb.nonce
102
- }
103
-
104
- $.ajax({
105
- type: "post",
106
- url: mashsb.ajaxurl,
107
- data: data,
108
- success: function (res) {
109
- console.log('Save fb results: ' + res);
110
- },
111
- error: function (e) {
112
- console.log('Unknown error ' + e)
113
- }
114
- })
115
- }
116
-
117
-
118
- // pinterest button logic
119
- $('body')
120
- .off('click', '.mashicon-pinterest')
121
- .on('click', '.mashicon-pinterest', function (e) {
122
- e.preventDefault();
123
- console.log('preventDefault:' + e);
124
- winWidth = 520;
125
- winHeight = 350;
126
- var winTop = (screen.height / 2) - (winHeight / 2);
127
- var winLeft = (screen.width / 2) - (winWidth / 2);
128
- var url = $(this).attr('data-mashsb-url');
129
-
130
- window.open(url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight + ',resizable=yes');
131
-
132
- });
133
-
134
- /* Load Pinterest Popup window
135
- *
136
- * @param string html container
137
- * @returns void
138
- */
139
- function load_pinterest(html) {
140
-
141
- mashnet_load_pinterest_body();
142
-
143
- jQuery('.mashnet_pinterest_header').fadeIn(500);
144
- jQuery('.mashnet_pinterest_inner').html(html);
145
-
146
- /* Close Pinterest popup*/
147
- jQuery('.mashnet_pinterest_close').click(function (e) {
148
- e.preventDefault();
149
- jQuery('.mashnet_pinterest_header').hide();
150
- });
151
- }
152
-
153
- /**
154
- * Load pinterest wrapper
155
- *
156
- * @returns voids
157
- */
158
- function load_pinterest_body() {
159
- var winWidth = window.innerWidth;
160
- var popupWidth = 350;
161
- var popupHeight = 310;
162
-
163
- /* Load Pinterest popup into body of page */
164
- if (winWidth <= 330)
165
- var popupWidth = 310;
166
- if (winWidth > 400)
167
- var popupWidth = 390;
168
- if (winWidth > 500)
169
- var popupWidth = 490;
170
-
171
- var winTop = (window.innerHeight / 2) - (popupHeight / 2);
172
- var winLeft = (window.innerWidth / 2) - (popupWidth / 2);
173
- var struct = '<div class="mashnet_pinterest_header" style="position:fixed;z-index:999999;max-width:' + popupWidth + 'px; margin-left:' + winLeft + 'px;top:' + winTop + 'px;">\n\
174
- <div class="mashnet_pinit_wrapper" style="background-color:white;"><span class="mashnet_pin_it">Pin it! </span><span class="mashnet_pinicon"></span> \n\
175
- <div class="mashnet_pinterest_close" style="float:right;"><a href="#">X</a></div></div>\n\
176
- <div class="mashnet_pinterest_inner"></div>\n\
177
- </div>\n\
178
- ';
179
-
180
- jQuery('body').append(struct);
181
- }
182
-
183
- /* Get all images on site
184
- *
185
- * @return html
186
- * */
187
- function get_images(url) {
188
-
189
- var allImages = jQuery('img').not("[nopin='nopin']");
190
- var html = '';
191
- var url = '';
192
-
193
- var largeImages = allImages.filter(function () {
194
- return (jQuery(this).width() > 70) || (jQuery(this).height() > 70)
195
- })
196
- for (i = 0; i < largeImages.length; i++) {
197
- html += '<li><a target="_blank" rel="" id="mashnetPinterestPopup" href="https://pinterest.com/pin/create/button/?url=' + encodeURIComponent(window.location.href) + '%2F&media=' + largeImages[i].src + '&description=' + largeImages[i].alt + '"><img src="' + largeImages[i].src + '"></a></li>';
198
- }
199
- }
200
-
201
-
202
-
203
-
204
- // Fix for the inline post plugin which removes the zero share count
205
- if ($('.mashsbcount').text() == '') {
206
- $('.mashsbcount').text(0);
207
- }
208
-
209
- // check the sharecount caching method
210
- mashsb_check_cache();
211
-
212
- /**
213
- * Check Cache
214
- *
215
- */
216
- function mashsb_check_cache() {
217
-
218
- if (mashsb_is_rate_limit()) {
219
- return false;
220
- }
221
-
222
- setTimeout(function () {
223
- if (typeof (mashsb) && mashsb.refresh == "1") {
224
- mashsb_update_cache();
225
- }
226
-
227
- }, 6000);
228
- }
229
-
230
- function mashsb_update_cache() {
231
- var mashsb_url = window.location.href;
232
- if (mashsb_url.indexOf("?") > -1) {
233
- mashsb_url += "&mashsb-refresh";
234
- } else {
235
- mashsb_url += "?mashsb-refresh";
236
- }
237
- var xhr = new XMLHttpRequest();
238
- xhr.open("GET", mashsb_url, true);
239
- xhr.send();
240
- }
241
-
242
- /* Opens a new minus button when plus sign is clicked */
243
- /* Toogle function for more services */
244
- $('.onoffswitch').on('click', function () {
245
- var $parent = $(this).parents('.mashsb-container');
246
- $parent.find('.onoffswitch').hide();
247
- $parent.find('.secondary-shares').show();
248
- $parent.find('.onoffswitch2').show();
249
- });
250
- $('.onoffswitch2').on('click', function () {
251
- var $parent = $(this).parents('.mashsb-container');
252
- $parent.find('.onoffswitch').show();
253
- $parent.find('.secondary-shares').hide();
254
- });
255
-
256
- /* Network sharer scripts */
257
- /* deactivate FB sharer when likeaftershare is enabled */
258
- if (typeof lashare_fb == "undefined" && typeof mashsb !== 'undefined') {
259
- $('.mashicon-facebook').click(function (e) {
260
- winWidth = 520;
261
- winHeight = 550;
262
- var winTop = (screen.height / 2) - (winHeight / 2);
263
- var winLeft = (screen.width / 2) - (winWidth / 2);
264
- var url = $(this).attr('href');
265
-
266
- window.open(url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
267
- e.preventDefault();
268
- return false;
269
- });
270
- }
271
-
272
- if (typeof mashsb !== 'undefined') {
273
- $('.mashicon-twitter').click(function (e) {
274
- winWidth = 520;
275
- winHeight = 350;
276
- var winTop = (screen.height / 2) - (winHeight / 2);
277
- var winLeft = (screen.width / 2) - (winWidth / 2);
278
- var url = $(this).attr('href');
279
-
280
- // deprecated and removed because TW popup opens twice
281
- if (mashsb.twitter_popup === '1') {
282
- window.open(url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
283
- }
284
- e.preventDefault();
285
- return false;
286
- });
287
- }
288
-
289
- if (typeof mashsb !== 'undefined' && mashsb.subscribe === 'content') {
290
- /* Toogle container display:none */
291
- $('.mashicon-subscribe').not('.trigger_active').nearest('.mashsb-toggle-container').hide();
292
- $('.mashicon-subscribe').click(function () {
293
- var trig = $(this);
294
- if (trig.hasClass('trigger_active')) {
295
- $(trig).nearest('.mashsb-toggle-container').slideToggle('fast');
296
- trig.removeClass('trigger_active');
297
- //$(".mashicon-subscribe").css({"padding-bottom":"10px"});
298
- } else {
299
- $('.trigger_active').nearest('.mashsb-toggle-container').slideToggle('slow');
300
- $('.trigger_active').removeClass('trigger_active');
301
- $(trig).nearest('.mashsb-toggle-container').slideToggle('fast');
302
- trig.addClass('trigger_active');
303
- //$(".mashicon-subscribe").css({"padding-bottom":"13px"});
304
- }
305
- ;
306
- return false;
307
- });
308
- }
309
-
310
- if (typeof mashsb !== 'undefined' && mashsb.subscribe === 'link') {
311
- $('.mashicon-subscribe').click(function () {
312
- var href = mashsb.subscribe_url;
313
- $(this).attr("href", href);
314
- });
315
- }
316
- ;
317
-
318
-
319
- /* Round the shares callback function
320
- *
321
- * @param {type} value
322
- * @returns {String|@exp;value@call;toFixed}
323
- */
324
- function roundShares(value) {
325
- if (typeof mashsb !== "undefined" && mashsb.round_shares == 1) {
326
- if (value > 1000000) {
327
- shares = Math.round((value / 1000000) * 10) / 10 + 'M';
328
- return shares;
329
-
330
- }
331
- if (value > 1000) {
332
- shares = Math.round((value / 1000) * 10) / 10 + 'k';
333
- return shares;
334
-
335
- }
336
- }
337
- /* zero decimals */
338
- return value.toFixed(0);
339
- }
340
-
341
-
342
-
343
- /* Count up script jquery-countTo
344
- * by mhuggins
345
- *
346
- * Source: https://github.com/mhuggins/jquery-countTo
347
- */
348
- (function ($) {
349
- $.fn.countTo = function (options) {
350
- options = options || {};
351
-
352
- return $(this).each(function () {
353
- // set options for current element
354
- var settings = $.extend({}, $.fn.countTo.defaults, {
355
- from: $(this).data('from'),
356
- to: $(this).data('to'),
357
- speed: $(this).data('speed'),
358
- refreshInterval: $(this).data('refresh-interval'),
359
- decimals: $(this).data('decimals')
360
- }, options);
361
-
362
- // how many times to update the value, and how much to increment the value on each update
363
- var loops = Math.ceil(settings.speed / settings.refreshInterval),
364
- increment = (settings.to - settings.from) / loops;
365
-
366
- // references & variables that will change with each update
367
- var self = this,
368
- $self = $(this),
369
- loopCount = 0,
370
- value = settings.from,
371
- data = $self.data('countTo') || {};
372
-
373
- $self.data('countTo', data);
374
-
375
- // if an existing interval can be found, clear it first
376
- if (data.interval) {
377
- clearInterval(data.interval);
378
- }
379
- data.interval = setInterval(updateTimer, settings.refreshInterval);
380
-
381
- // initialize the element with the starting value
382
- render(value);
383
-
384
- function updateTimer() {
385
- value += increment;
386
- loopCount++;
387
-
388
- render(value);
389
-
390
- if (typeof (settings.onUpdate) == 'function') {
391
- settings.onUpdate.call(self, value);
392
- }
393
-
394
- if (loopCount >= loops) {
395
- // remove the interval
396
- $self.removeData('countTo');
397
- clearInterval(data.interval);
398
- value = settings.to;
399
-
400
- if (typeof (settings.onComplete) == 'function') {
401
- settings.onComplete.call(self, value);
402
- }
403
- }
404
- }
405
-
406
- function render(value) {
407
- var formattedValue = settings.formatter.call(self, value, settings);
408
- $self.text(formattedValue);
409
- }
410
- });
411
- };
412
-
413
- $.fn.countTo.defaults = {
414
- from: 0, // the number the element should start at
415
- to: 0, // the number the element should end at
416
- speed: 1000, // how long it should take to count between the target numbers
417
- refreshInterval: 100, // how often the element should be updated
418
- decimals: 0, // the number of decimal places to show
419
- //formatter: formatter, // handler for formatting the value before rendering
420
- formatter: roundShares,
421
- onUpdate: null, // callback method for every time the element is updated
422
- onComplete: null // callback method for when the element finishes updating
423
- };
424
-
425
- function formatter(value, settings) {
426
- return value.toFixed(settings.decimals);
427
- }
428
-
429
-
430
- }(jQuery));
431
-
432
- /*
433
- * Start the counter
434
- *
435
- */
436
- if (typeof mashsb !== 'undefined' && mashsb.animate_shares == 1 && $('.mashsbcount').length) {
437
- $('.mashsbcount').countTo({from: 0, to: mashsb.shares, speed: 1000, refreshInterval: 100});
438
- }
439
- });
440
-
441
-
442
- /*!------------------------------------------------------
443
- * jQuery nearest v1.0.3
444
- * http://github.com/jjenzz/jQuery.nearest
445
- * ------------------------------------------------------
446
- * Copyright (c) 2012 J. Smith (@jjenzz)
447
- * Dual licensed under the MIT and GPL licenses:
448
- * http://www.opensource.org/licenses/mit-license.php
449
- * http://www.gnu.org/licenses/gpl.html
450
- */
451
- (function ($, d) {
452
- $.fn.nearest = function (selector) {
453
- var self, nearest, el, s, p,
454
- hasQsa = d.querySelectorAll;
455
-
456
- function update(el) {
457
- nearest = nearest ? nearest.add(el) : $(el);
458
- }
459
-
460
- this.each(function () {
461
- self = this;
462
-
463
- $.each(selector.split(','), function () {
464
- s = $.trim(this);
465
-
466
- if (!s.indexOf('#')) {
467
- // selector starts with an ID
468
- update((hasQsa ? d.querySelectorAll(s) : $(s)));
469
- } else {
470
- // is a class or tag selector
471
- // so need to traverse
472
- p = self.parentNode;
473
- while (p) {
474
- el = hasQsa ? p.querySelectorAll(s) : $(p).find(s);
475
- if (el.length) {
476
- update(el);
477
- break;
478
- }
479
- p = p.parentNode;
480
- }
481
- }
482
- });
483
-
484
- });
485
-
486
- return nearest || $();
487
- };
488
- }(jQuery, document));
1
+ var strict;
2
+
3
+ jQuery(document).ready(function ($) {
4
+
5
+ /* Show Whatsapp button on mobile devices iPhones and Android only */
6
+ if (navigator.userAgent.match(/(iPhone)/i) || navigator.userAgent.match(/(Android)/i)) {
7
+ $('.mashicon-whatsapp').show();
8
+ }
9
+
10
+ /**
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
+ {
19
+
20
+
21
+ if (document.querySelector('.mashsb-buttons') === null) {
22
+ return false;
23
+ }
24
+
25
+ if ('undefined' !== typeof (mashsb.refresh) && mashsb.refresh === '0') {
26
+ return false;
27
+ }
28
+
29
+ if ('undefined' === typeof (mashsb.share_url) && mashsb.share_url !== '') {
30
+ return false;
31
+ }
32
+
33
+ if ('undefined' === typeof (mashsb.postid) && mashsb.postid !== '') {
34
+ return false;
35
+ }
36
+
37
+ if (mashsb_is_rate_limit()) {
38
+ return false;
39
+ }
40
+
41
+ //mashsb.share_url = 'https://www.google.de';
42
+
43
+ var facebookGraphURL = 'https://graph.facebook.com/?id=' + mashsb.share_url;
44
+ $.ajax({
45
+ type: 'GET',
46
+ url: facebookGraphURL,
47
+ dataType: 'json',
48
+ success: function (data) {
49
+ mashsb_set_fb_sharecount(data);
50
+ console.log(data);
51
+ },
52
+ error: function (e) {
53
+ console.log(e)
54
+ }
55
+ })
56
+
57
+
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
65
+ * @returns {Boolean}
66
+ */
67
+ function mashsb_is_rate_limit() {
68
+
69
+ if ("undefined" === typeof (mashsb.servertime)) {
70
+ return true;
71
+ }
72
+
73
+ var serverTime = Number(mashsb.servertime);
74
+ var clientTime = Math.floor(Date.now() / 1000);
75
+
76
+ if (clientTime > (serverTime + 30)) {
77
+ console.log('rate limited: ' + (serverTime + 30));
78
+ return true;
79
+ } else {
80
+ console.log('not rate limited: ' + (serverTime + 30));
81
+ return false;
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Store FB return data in mashshare cache vi js client request
87
+ * @returns {undefined}
88
+ */
89
+ function mashsb_set_fb_sharecount(result) {
90
+
91
+ if ('undefined' === typeof (result.share)) {
92
+ console.log('No valid result' + result);
93
+ return false;
94
+ }
95
+
96
+ var data = {
97
+ action: 'mashsb_set_fb_shares',
98
+ shares: result.share,
99
+ postid: mashsb.postid,
100
+ url: mashsb.share_url,
101
+ nonce: mashsb.nonce
102
+ }
103
+
104
+ $.ajax({
105
+ type: "post",
106
+ url: mashsb.ajaxurl,
107
+ data: data,
108
+ success: function (res) {
109
+ console.log('Save fb results: ' + res);
110
+ },
111
+ error: function (e) {
112
+ console.log('Unknown error ' + e)
113
+ }
114
+ })
115
+ }
116
+
117
+
118
+ // pinterest button logic
119
+ $('body')
120
+ .off('click', '.mashicon-pinterest')
121
+ .on('click', '.mashicon-pinterest', function (e) {
122
+ e.preventDefault();
123
+ console.log('preventDefault:' + e);
124
+ winWidth = 520;
125
+ winHeight = 350;
126
+ var winTop = (screen.height / 2) - (winHeight / 2);
127
+ var winLeft = (screen.width / 2) - (winWidth / 2);
128
+ var url = $(this).attr('data-mashsb-url');
129
+
130
+ window.open(url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight + ',resizable=yes');
131
+
132
+ });
133
+
134
+ /* Load Pinterest Popup window
135
+ *
136
+ * @param string html container
137
+ * @returns void
138
+ */
139
+ function load_pinterest(html) {
140
+
141
+ mashnet_load_pinterest_body();
142
+
143
+ jQuery('.mashnet_pinterest_header').fadeIn(500);
144
+ jQuery('.mashnet_pinterest_inner').html(html);
145
+
146
+ /* Close Pinterest popup*/
147
+ jQuery('.mashnet_pinterest_close').click(function (e) {
148
+ e.preventDefault();
149
+ jQuery('.mashnet_pinterest_header').hide();
150
+ });
151
+ }
152
+
153
+ /**
154
+ * Load pinterest wrapper
155
+ *
156
+ * @returns voids
157
+ */
158
+ function load_pinterest_body() {
159
+ var winWidth = window.innerWidth;
160
+ var popupWidth = 350;
161
+ var popupHeight = 310;
162
+
163
+ /* Load Pinterest popup into body of page */
164
+ if (winWidth <= 330)
165
+ var popupWidth = 310;
166
+ if (winWidth > 400)
167
+ var popupWidth = 390;
168
+ if (winWidth > 500)
169
+ var popupWidth = 490;
170
+
171
+ var winTop = (window.innerHeight / 2) - (popupHeight / 2);
172
+ var winLeft = (window.innerWidth / 2) - (popupWidth / 2);
173
+ var struct = '<div class="mashnet_pinterest_header" style="position:fixed;z-index:999999;max-width:' + popupWidth + 'px; margin-left:' + winLeft + 'px;top:' + winTop + 'px;">\n\
174
+ <div class="mashnet_pinit_wrapper" style="background-color:white;"><span class="mashnet_pin_it">Pin it! </span><span class="mashnet_pinicon"></span> \n\
175
+ <div class="mashnet_pinterest_close" style="float:right;"><a href="#">X</a></div></div>\n\
176
+ <div class="mashnet_pinterest_inner"></div>\n\
177
+ </div>\n\
178
+ ';
179
+
180
+ jQuery('body').append(struct);
181
+ }
182
+
183
+ /* Get all images on site
184
+ *
185
+ * @return html
186
+ * */
187
+ function get_images(url) {
188
+
189
+ var allImages = jQuery('img').not("[nopin='nopin']");
190
+ var html = '';
191
+ var url = '';
192
+
193
+ var largeImages = allImages.filter(function () {
194
+ return (jQuery(this).width() > 70) || (jQuery(this).height() > 70)
195
+ })
196
+ for (i = 0; i < largeImages.length; i++) {
197
+ html += '<li><a target="_blank" rel="" id="mashnetPinterestPopup" href="https://pinterest.com/pin/create/button/?url=' + encodeURIComponent(window.location.href) + '%2F&media=' + largeImages[i].src + '&description=' + largeImages[i].alt + '"><img src="' + largeImages[i].src + '"></a></li>';
198
+ }
199
+ }
200
+
201
+
202
+
203
+
204
+ // Fix for the inline post plugin which removes the zero share count
205
+ if ($('.mashsbcount').text() == '') {
206
+ $('.mashsbcount').text(0);
207
+ }
208
+
209
+ // check the sharecount caching method
210
+ mashsb_check_cache();
211
+
212
+ /**
213
+ * Check Cache
214
+ *
215
+ */
216
+ function mashsb_check_cache() {
217
+
218
+ if (mashsb_is_rate_limit()) {
219
+ return false;
220
+ }
221
+
222
+ setTimeout(function () {
223
+ if (typeof (mashsb) && mashsb.refresh == "1") {
224
+ mashsb_update_cache();
225
+ }
226
+
227
+ }, 6000);
228
+ }
229
+
230
+ function mashsb_update_cache() {
231
+ var mashsb_url = window.location.href;
232
+ if (mashsb_url.indexOf("?") > -1) {
233
+ mashsb_url += "&mashsb-refresh";
234
+ } else {
235
+ mashsb_url += "?mashsb-refresh";
236
+ }
237
+ var xhr = new XMLHttpRequest();
238
+ xhr.open("GET", mashsb_url, true);
239
+ xhr.send();
240
+ }
241
+
242
+ /* Opens a new minus button when plus sign is clicked */
243
+ /* Toogle function for more services */
244
+ $('.onoffswitch').on('click', function () {
245
+ var $parent = $(this).parents('.mashsb-container');
246
+ $parent.find('.onoffswitch').hide();
247
+ $parent.find('.secondary-shares').show();
248
+ $parent.find('.onoffswitch2').show();
249
+ });
250
+ $('.onoffswitch2').on('click', function () {
251
+ var $parent = $(this).parents('.mashsb-container');
252
+ $parent.find('.onoffswitch').show();
253
+ $parent.find('.secondary-shares').hide();
254
+ });
255
+
256
+ /* Network sharer scripts */
257
+ /* deactivate FB sharer when likeaftershare is enabled */
258
+ if (typeof lashare_fb == "undefined" && typeof mashsb !== 'undefined') {
259
+ $('.mashicon-facebook').click(function (e) {
260
+ winWidth = 520;
261
+ winHeight = 550;
262
+ var winTop = (screen.height / 2) - (winHeight / 2);
263
+ var winLeft = (screen.width / 2) - (winWidth / 2);
264
+ var url = $(this).attr('href');
265
+
266
+ window.open(url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
267
+ e.preventDefault();
268
+ return false;
269
+ });
270
+ }
271
+
272
+ if (typeof mashsb !== 'undefined') {
273
+ $('.mashicon-twitter').click(function (e) {
274
+ winWidth = 520;
275
+ winHeight = 350;
276
+ var winTop = (screen.height / 2) - (winHeight / 2);
277
+ var winLeft = (screen.width / 2) - (winWidth / 2);
278
+ var url = $(this).attr('href');
279
+
280
+ // deprecated and removed because TW popup opens twice
281
+ if (mashsb.twitter_popup === '1') {
282
+ window.open(url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
283
+ }
284
+ e.preventDefault();
285
+ return false;
286
+ });
287
+ }
288
+
289
+ if (typeof mashsb !== 'undefined' && mashsb.subscribe === 'content') {
290
+ /* Toogle container display:none */
291
+ $('.mashicon-subscribe').not('.trigger_active').nearest('.mashsb-toggle-container').hide();
292
+ $('.mashicon-subscribe').click(function () {
293
+ var trig = $(this);
294
+ if (trig.hasClass('trigger_active')) {
295
+ $(trig).nearest('.mashsb-toggle-container').slideToggle('fast');
296
+ trig.removeClass('trigger_active');
297
+ //$(".mashicon-subscribe").css({"padding-bottom":"10px"});
298
+ } else {
299
+ $('.trigger_active').nearest('.mashsb-toggle-container').slideToggle('slow');
300
+ $('.trigger_active').removeClass('trigger_active');
301
+ $(trig).nearest('.mashsb-toggle-container').slideToggle('fast');
302
+ trig.addClass('trigger_active');
303
+ //$(".mashicon-subscribe").css({"padding-bottom":"13px"});
304
+ }
305
+ ;
306
+ return false;
307
+ });
308
+ }
309
+
310
+ if (typeof mashsb !== 'undefined' && mashsb.subscribe === 'link') {
311
+ $('.mashicon-subscribe').click(function () {
312
+ var href = mashsb.subscribe_url;
313
+ $(this).attr("href", href);
314
+ });
315
+ }
316
+ ;
317
+
318
+
319
+ /* Round the shares callback function
320
+ *
321
+ * @param {type} value
322
+ * @returns {String|@exp;value@call;toFixed}
323
+ */
324
+ function roundShares(value) {
325
+ if (typeof mashsb !== "undefined" && mashsb.round_shares == 1) {
326
+ if (value > 1000000) {
327
+ shares = Math.round((value / 1000000) * 10) / 10 + 'M';
328
+ return shares;
329
+
330
+ }
331
+ if (value > 1000) {
332
+ shares = Math.round((value / 1000) * 10) / 10 + 'k';
333
+ return shares;
334
+
335
+ }
336
+ }
337
+ /* zero decimals */
338
+ return value.toFixed(0);
339
+ }
340
+
341
+
342
+
343
+ /* Count up script jquery-countTo
344
+ * by mhuggins
345
+ *
346
+ * Source: https://github.com/mhuggins/jquery-countTo
347
+ */
348
+ (function ($) {
349
+ $.fn.countTo = function (options) {
350
+ options = options || {};
351
+
352
+ return $(this).each(function () {
353
+ // set options for current element
354
+ var settings = $.extend({}, $.fn.countTo.defaults, {
355
+ from: $(this).data('from'),
356
+ to: $(this).data('to'),
357
+ speed: $(this).data('speed'),
358
+ refreshInterval: $(this).data('refresh-interval'),
359
+ decimals: $(this).data('decimals')
360
+ }, options);
361
+
362
+ // how many times to update the value, and how much to increment the value on each update
363
+ var loops = Math.ceil(settings.speed / settings.refreshInterval),
364
+ increment = (settings.to - settings.from) / loops;
365
+
366
+ // references & variables that will change with each update
367
+ var self = this,
368
+ $self = $(this),
369
+ loopCount = 0,
370
+ value = settings.from,
371
+ data = $self.data('countTo') || {};
372
+
373
+ $self.data('countTo', data);
374
+
375
+ // if an existing interval can be found, clear it first
376
+ if (data.interval) {
377
+ clearInterval(data.interval);
378
+ }
379
+ data.interval = setInterval(updateTimer, settings.refreshInterval);
380
+
381
+ // initialize the element with the starting value
382
+ render(value);
383
+
384
+ function updateTimer() {
385
+ value += increment;
386
+ loopCount++;
387
+
388
+ render(value);
389
+
390
+ if (typeof (settings.onUpdate) == 'function') {
391
+ settings.onUpdate.call(self, value);
392
+ }
393
+
394
+ if (loopCount >= loops) {
395
+ // remove the interval
396
+ $self.removeData('countTo');
397
+ clearInterval(data.interval);
398
+ value = settings.to;
399
+
400
+ if (typeof (settings.onComplete) == 'function') {
401
+ settings.onComplete.call(self, value);
402
+ }
403
+ }
404
+ }
405
+
406
+ function render(value) {
407
+ var formattedValue = settings.formatter.call(self, value, settings);
408
+ $self.text(formattedValue);
409
+ }
410
+ });
411
+ };
412
+
413
+ $.fn.countTo.defaults = {
414
+ from: 0, // the number the element should start at
415
+ to: 0, // the number the element should end at
416
+ speed: 1000, // how long it should take to count between the target numbers
417
+ refreshInterval: 100, // how often the element should be updated
418
+ decimals: 0, // the number of decimal places to show
419
+ //formatter: formatter, // handler for formatting the value before rendering
420
+ formatter: roundShares,
421
+ onUpdate: null, // callback method for every time the element is updated
422
+ onComplete: null // callback method for when the element finishes updating
423
+ };
424
+
425
+ function formatter(value, settings) {
426
+ return value.toFixed(settings.decimals);
427
+ }
428
+
429
+
430
+ }(jQuery));
431
+
432
+ /*
433
+ * Start the counter
434
+ *
435
+ */
436
+ if (typeof mashsb !== 'undefined' && mashsb.animate_shares == 1 && $('.mashsbcount').length) {
437
+ $('.mashsbcount').countTo({from: 0, to: mashsb.shares, speed: 1000, refreshInterval: 100});
438
+ }
439
+ });
440
+
441
+
442
+ /*!------------------------------------------------------
443
+ * jQuery nearest v1.0.3
444
+ * http://github.com/jjenzz/jQuery.nearest
445
+ * ------------------------------------------------------
446
+ * Copyright (c) 2012 J. Smith (@jjenzz)
447
+ * Dual licensed under the MIT and GPL licenses:
448
+ * http://www.opensource.org/licenses/mit-license.php
449
+ * http://www.gnu.org/licenses/gpl.html
450
+ */
451
+ (function ($, d) {
452
+ $.fn.nearest = function (selector) {
453
+ var self, nearest, el, s, p,
454
+ hasQsa = d.querySelectorAll;
455
+
456
+ function update(el) {
457
+ nearest = nearest ? nearest.add(el) : $(el);
458
+ }
459
+
460
+ this.each(function () {
461
+ self = this;
462
+
463
+ $.each(selector.split(','), function () {
464
+ s = $.trim(this);
465
+
466
+ if (!s.indexOf('#')) {
467
+ // selector starts with an ID
468
+ update((hasQsa ? d.querySelectorAll(s) : $(s)));
469
+ } else {
470
+ // is a class or tag selector
471
+ // so need to traverse
472
+ p = self.parentNode;
473
+ while (p) {
474
+ el = hasQsa ? p.querySelectorAll(s) : $(p).find(s);
475
+ if (el.length) {
476
+ update(el);
477
+ break;
478
+ }
479
+ p = p.parentNode;
480
+ }
481
+ }
482
+ });
483
+
484
+ });
485
+
486
+ return nearest || $();
487
+ };
488
+ }(jQuery, document));
includes/admin/meta-box/inc/meta-box.php CHANGED
@@ -343,6 +343,10 @@ class MASHSB_RW_Meta_Box
343
  */
344
  static function normalize_fields( $fields )
345
  {
 
 
 
 
346
  foreach ( $fields as $k => $field )
347
  {
348
  $class = self::get_class_name( $field );
343
  */
344
  static function normalize_fields( $fields )
345
  {
346
+
347
+ if (empty($fields)){
348
+ return array();
349
+ }
350
  foreach ( $fields as $k => $field )
351
  {
352
  $class = self::get_class_name( $field );
includes/sharecount-functions.php CHANGED
@@ -176,16 +176,16 @@ function mashsb_rate_limit_exceeded(){
176
 
177
 
178
  /**
179
- * Make sure that requests do not exceed 1req / 60second
180
  * @return boolean
181
  */
182
  function mashsb_is_req_limited() {
183
  global $mashsb_debug;
184
 
185
- $data_timeout = get_option('_transient_timeout_mashsb_limit_req');
186
 
187
- if (false === $data_timeout || empty($data_timeout) || $data_timeout < time() ){
188
- set_transient('mashsb_limit_req', '1', 5);
189
  $mashsb_debug[] = 'Temp Rate Limit not exceeded';
190
  return false;
191
  }
176
 
177
 
178
  /**
179
+ * Make sure that requests do not exceed 1req / 300sec(5min)
180
  * @return boolean
181
  */
182
  function mashsb_is_req_limited() {
183
  global $mashsb_debug;
184
 
185
+ $data_timeout = get_transient('mashsb_limit_req');
186
 
187
+ if (false === $data_timeout || empty($data_timeout) ){
188
+ set_transient('mashsb_limit_req', '1', 300);
189
  $mashsb_debug[] = 'Temp Rate Limit not exceeded';
190
  return false;
191
  }
includes/template-functions.php CHANGED
@@ -203,8 +203,14 @@ function getSharedcount( $url ) {
203
  * - deprecated: admin pages (we need to remove this for themes which are using a bad infinite scroll implementation where is_admin() is always true)
204
  */
205
 
206
- //|| mashsb_rate_limit_exceeded()
207
-
 
 
 
 
 
 
208
  if( is_404() || is_search() || empty($url) || !mashsb_is_enabled_permalinks() || isset($mashsb_options['disable_sharecount']) || isset($_GET['preview_id']) ) {
209
  $mashsb_debug[] = 'MashShare: Share count (temporary) disabled';
210
  return apply_filters( 'filter_get_sharedcount', 0 );
203
  * - deprecated: admin pages (we need to remove this for themes which are using a bad infinite scroll implementation where is_admin() is always true)
204
  */
205
 
206
+
207
+ // Request is rate limited
208
+ if (mashsb_is_req_limited()) {
209
+ $mashsb_debug[] = 'Rate limit reached: Return Share from custom meta field.';
210
+ return (int) get_post_meta($post->ID, 'mashsb_shares', true) + getFakecount();
211
+ }
212
+
213
+
214
  if( is_404() || is_search() || empty($url) || !mashsb_is_enabled_permalinks() || isset($mashsb_options['disable_sharecount']) || isset($_GET['preview_id']) ) {
215
  $mashsb_debug[] = 'MashShare: Share count (temporary) disabled';
216
  return apply_filters( 'filter_get_sharedcount', 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.9
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.9' );
39
  }
40
 
41
  // Debug mode
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.7.0
10
  * Text Domain: mashsb
11
  * Domain Path: /languages
12
 
35
 
36
  // Plugin version
37
  if( !defined( 'MASHSB_VERSION' ) ) {
38
+ define( 'MASHSB_VERSION', '3.7.0' );
39
  }
40
 
41
  // Debug mode
readme.txt CHANGED
@@ -9,7 +9,7 @@ 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.9
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,11 @@ Read here more about this: http://docs.mashshare.net/article/10-facebook-is-show
250
 
251
  == Changelog ==
252
 
 
 
 
 
 
253
  = 3.6.8 =
254
  * New: Add new filter mashsb_allowed_post_types for allowing or disabling share counts on particular posts types to lower the api requests to sharedcount.com
255
  * Tweak: sharedcount.com lowered their free api limit to 500 daily requests. Change description in MashShare!
@@ -310,32 +315,14 @@ Read here more about this: http://docs.mashshare.net/article/10-facebook-is-show
310
  = 3.5.6 =
311
  * Fix: Security fix to prevent XSS attacks
312
 
313
- = 3.5.5 =
314
- * Tweak: Explain better sharedcount and opensharecount integration
315
- * Fix: Error array_merge is not an array
316
- * Fix: MashShare social media meta box not shown if another plugin is using the same meta-box library
317
- * Fix: Incompatibility with meta-box add-ons
318
- * Fix: Whatsapp Button not visible on AMP pages
319
- * Tweak: Change welcome message
320
-
321
- = 3.5.4 =
322
- * New: Support for Yoast custom variables e.g. %%title%%
323
- * New: Add sharedcount.com 500 free daily api requests
324
- * New: Switch from newsharecount to opensharecount.com to collect twitter shares
325
- * New: Collect twitter shares with social network add-on
326
-
327
- = 3.5.3 =
328
- * New: Disable share count for new installations as default setting
329
- * New: Admin notice to recommend to disable the share count agregation to be complicant with upcoming GDPR
330
- * New: Compatible with WordPress 4.9.6
331
- * Tweak: Google short urls are not longer supported and removed
332
-
333
  See release notes and complete changelog at:
334
  https://www.mashshare.net/changelog/
335
 
336
  == Upgrade Notice ==
337
 
338
- = 3.6.7 =
339
- * Fix: Whatsapp sharing does not work
 
 
340
 
341
 
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.7.0
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.7.0 =
254
+ * Fix: PHP Warning: Invalid argument supplied for foreach() in meta-box.php
255
+ * Fix: Set the share count query rate limit to 1req/5min
256
+ * New: Compatible up to WordPress 5.2.4
257
+
258
  = 3.6.8 =
259
  * New: Add new filter mashsb_allowed_post_types for allowing or disabling share counts on particular posts types to lower the api requests to sharedcount.com
260
  * Tweak: sharedcount.com lowered their free api limit to 500 daily requests. Change description in MashShare!
315
  = 3.5.6 =
316
  * Fix: Security fix to prevent XSS attacks
317
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  See release notes and complete changelog at:
319
  https://www.mashshare.net/changelog/
320
 
321
  == Upgrade Notice ==
322
 
323
+ = 3.7.0 =
324
+ * Fix: PHP Warning: Invalid argument supplied for foreach() in meta-box.php
325
+ * Fix: Set the share count query rate limit to 1req/5min
326
+ * New: Compatible up to WordPress 5.2.4
327
 
328