Social Media Share Buttons | MashShare - Version 3.6.6

Version Description

  • Tweak: Added an extra check for HTTP_HOST to make it more compliant with cron jobs and/or API workers
Download this release

Release Info

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

Code changes from version 3.6.4 to 3.6.6

includes/admin/feedback.php CHANGED
@@ -75,6 +75,11 @@ function mashsb_send_feedback() {
75
  $subject = isset( $form['mashsb_disable_reason'] ) ? $form['mashsb_disable_reason'] : '(no reason given)';
76
 
77
  $success = wp_mail( 'makebetter@mashshare.net', $subject, $text, $headers );
 
 
 
 
 
78
 
79
  //error_log(print_r($success, true));
80
  //error_log($from . $subject . var_dump($form));
75
  $subject = isset( $form['mashsb_disable_reason'] ) ? $form['mashsb_disable_reason'] : '(no reason given)';
76
 
77
  $success = wp_mail( 'makebetter@mashshare.net', $subject, $text, $headers );
78
+
79
+ if ($success){
80
+ wp_die(1);
81
+ }
82
+ wp_die(0);
83
 
84
  //error_log(print_r($success, true));
85
  //error_log($from . $subject . var_dump($form));
includes/scripts.php CHANGED
@@ -72,8 +72,8 @@ function mashsb_load_scripts( $hook ) {
72
 
73
  $status = apply_filters('mashsbStatus', false);
74
 
75
- //$refresh = mashsb_is_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,
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/template-functions.php CHANGED
@@ -1328,7 +1328,7 @@ function mashsb_get_twitter_username() {
1328
  }
1329
 
1330
  // If plugin is not running on mashshare.net or dev environment replace @mashshare
1331
- if( $_SERVER['HTTP_HOST'] !== 'www.mashshare.net' && $_SERVER['HTTP_HOST'] !== 'src.wordpress-develop.dev' ) {
1332
  //Sanitize it
1333
  $replace_first = str_ireplace( 'mashshare', '', $mashsb_options['mashsharer_hashtag'] );
1334
  $replace_second = str_ireplace( '@', '', $replace_first );
1328
  }
1329
 
1330
  // If plugin is not running on mashshare.net or dev environment replace @mashshare
1331
+ if ( empty( $_SERVER['HTTP_HOST'] ) || ( $_SERVER['HTTP_HOST'] !== 'www.mashshare.net' && $_SERVER['HTTP_HOST'] !== 'src.wordpress-develop.dev' ) ){
1332
  //Sanitize it
1333
  $replace_first = str_ireplace( 'mashshare', '', $mashsb_options['mashsharer_hashtag'] );
1334
  $replace_second = str_ireplace( '@', '', $replace_first );
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.4
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.4' );
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.6.6
10
  * Text Domain: mashsb
11
  * Domain Path: /languages
12
 
35
 
36
  // Plugin version
37
  if( !defined( 'MASHSB_VERSION' ) ) {
38
+ define( 'MASHSB_VERSION', '3.6.6' );
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.4
13
  Requires PHP: 5.2
14
 
15
  Social Media Share Buttons for Twitter, Facebook and other social networks. Highly customizable Social Media ecosystem
@@ -250,7 +250,13 @@ Read here more about this: http://docs.mashshare.net/article/10-facebook-is-show
250
 
251
  == Changelog ==
252
 
253
- = 3.6.4 =
 
 
 
 
 
 
254
  * New: Compatible up to WordPress 5.2
255
  * Fix: Do not call the facebook api directly any longer
256
  * Fix: Undefined variable notice after uninstallation and deleting all MashShare settings an installation again
@@ -320,9 +326,7 @@ https://www.mashshare.net/changelog/
320
 
321
  == Upgrade Notice ==
322
 
323
- = 3.6.4 =
324
- * New: Compatible up to WordPress 5.2
325
- * Fix: Do not call the facebook api directly any longer
326
- * Fix: Undefined variable notice after uninstallation and deleting all MashShare settings an installation again
327
 
328
 
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.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
 
251
  == Changelog ==
252
 
253
+ = 3.6.6 =
254
+ * Tweak: Added an extra check for HTTP_HOST to make it more compliant with cron jobs and/or API workers
255
+
256
+ = 3.6.5 =
257
+ * Fix: Share count not collected with async caching method
258
+
259
+ = 3.6.5 =
260
  * New: Compatible up to WordPress 5.2
261
  * Fix: Do not call the facebook api directly any longer
262
  * Fix: Undefined variable notice after uninstallation and deleting all MashShare settings an installation again
326
 
327
  == Upgrade Notice ==
328
 
329
+ = 3.6.6 =
330
+ * Tweak: Added an extra check for HTTP_HOST to make it more compliant with cron jobs and/or API workers
 
 
331
 
332