Version Description
- Fix: Option Cumulate Http(s) Shares not working for sharedcount.com API endpoint
- Fix: Tweets can be requested via opensharecount.com
- Fix: Async cache refresh not fired
- New: Performance Improvements in collecting sharecount
- New: Switch default share method to refresh while loading
- New: If yoast twitter title and description is populated the mashshare generated twitter card will use this settings but still allows to define a custom tweet text.
Download this release
Release Info
Developer | ReneHermi |
Plugin | Social Media Share Buttons | MashShare |
Version | 3.6.3 |
Comparing to | |
See all releases |
Code changes from version 3.6.2 to 3.6.3
- assets/js/mashsb.js +9 -2
- assets/js/mashsb.min.js +1 -1
- includes/admin/settings/register-settings.php +8 -8
- includes/header-meta-tags.php +59 -58
- includes/install.php +1 -1
- includes/sharecount-functions.php +0 -44
- includes/sharedcount.class.php +210 -170
- mashshare.php +2 -2
- readme.txt +11 -6
assets/js/mashsb.js
CHANGED
@@ -197,19 +197,26 @@ jQuery(document).ready(function ($) {
|
|
197 |
}
|
198 |
|
199 |
|
200 |
-
|
201 |
-
//mashsb_check_cache();
|
202 |
|
203 |
// Fix for the inline post plugin which removes the zero share count
|
204 |
if ($('.mashsbcount').text() == '') {
|
205 |
$('.mashsbcount').text(0);
|
206 |
}
|
207 |
|
|
|
|
|
|
|
208 |
/**
|
209 |
* Check Cache
|
210 |
*
|
211 |
*/
|
212 |
function mashsb_check_cache() {
|
|
|
|
|
|
|
|
|
|
|
213 |
setTimeout(function () {
|
214 |
if (typeof (mashsb) && mashsb.refresh == "1") {
|
215 |
mashsb_update_cache();
|
197 |
}
|
198 |
|
199 |
|
200 |
+
|
|
|
201 |
|
202 |
// Fix for the inline post plugin which removes the zero share count
|
203 |
if ($('.mashsbcount').text() == '') {
|
204 |
$('.mashsbcount').text(0);
|
205 |
}
|
206 |
|
207 |
+
// check the sharecount caching method
|
208 |
+
mashsb_check_cache();
|
209 |
+
|
210 |
/**
|
211 |
* Check Cache
|
212 |
*
|
213 |
*/
|
214 |
function mashsb_check_cache() {
|
215 |
+
|
216 |
+
if (mashsb_is_rate_limit()) {
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
|
220 |
setTimeout(function () {
|
221 |
if (typeof (mashsb) && mashsb.refresh == "1") {
|
222 |
mashsb_update_cache();
|
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(b){if("undefined"==typeof b.share)return console.log("No valid result"+b),!1;var c={action:"mashsb_set_fb_shares",shares:b.share,postid:mashsb.postid,url:mashsb.share_url,nonce:mashsb.nonce};a.ajax({type:"post",url:mashsb.ajaxurl,data:c,success:function(a){console.log("Save fb results: "+a)},error:function(a){console.log("Unknown error "+a)}})}function d(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();var
|
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(b){if("undefined"==typeof b.share)return console.log("No valid result"+b),!1;var c={action:"mashsb_set_fb_shares",shares:b.share,postid:mashsb.postid,url:mashsb.share_url,nonce:mashsb.nonce};a.ajax({type:"post",url:mashsb.ajaxurl,data:c,success:function(a){console.log("Save fb results: "+a)},error:function(a){console.log("Unknown error "+a)}})}function d(){return b()?!1:void setTimeout(function(){"1"==mashsb.refresh&&e()},6e3)}function e(){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 f(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();var g=function(){if(null===document.querySelector(".mashsb-buttons"))return!1;if("undefined"!=typeof mashsb.refresh&&"0"===mashsb.refresh)return!1;if("undefined"==typeof mashsb.share_url&&""!==mashsb.share_url)return!1;if("undefined"==typeof mashsb.postid&&""!==mashsb.postid)return!1;if(b())return!1;var d="https://graph.facebook.com/?id="+mashsb.share_url;a.ajax({type:"GET",url:d,dataType:"json",success:function(a){c(a),console.log(a)},error:function(a){console.log(a)}})};setTimeout(g,3e3),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),d(),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:f,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
@@ -125,7 +125,7 @@ function mashsb_get_registered_settings() {
|
|
125 |
'id' => 'mashsb_sharemethod',
|
126 |
'name' => __( 'Share Count', 'mashsb' ),
|
127 |
//'desc' => __( '- <i>MashEngine</i> collects shares by direct request to social networks.<br><br><i>SharedCount.com</i> is a third party service free for up to 10.000 daily requests. It collects shares for Facebook, Pinterest, Stumbleupon. (For GDPR compliance you should select the sharedcount.com service.)<br><br>Twitter count is aggreagated via <a href="https://twitcount.com" target="_blank" rel="external nofollow">https://twitcount.com</a>. You must sign up with your Twitter account for this free service to get the twitter share count. Visit the site http://twitcount.com, fill in your website domain and click on <i>Sign up</i>. <br><br><strong>Note: You need <a href="https://mashshare.net/downloads/mashshare-social-networks-addon/" target="_blank">MashShare Social Network Add-On</a> for enabling Twitter count.</strong>', 'mashsb' ),
|
128 |
-
'desc' => __( '- <i>SharedCount.com</i> is a third party service free for up to 10.000 daily requests. It collects shares for Facebook.<br><br>Twitter count is aggreagated via <a href="https://
|
129 |
'type' => 'select',
|
130 |
'options' => array(
|
131 |
//'mashengine' => 'MashEngine',
|
@@ -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(__( 'The <i>Async Cache Refresh</i> method never adds additonal load time for a visitor and 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> <i>Refresh while loading</i> rebuilds expired cache while page is loading and adds a little extra time during inital page load. <br><br><strong>If shares are not updating</strong> or site is heavy cached try <i>Refresh while loading!</i> That\'s the default method
|
154 |
'type' => 'select',
|
155 |
'options' => array(
|
156 |
'async_cache' => 'Async Cache Refresh',
|
@@ -188,12 +188,12 @@ function mashsb_get_registered_settings() {
|
|
188 |
'type' => 'text',
|
189 |
'size' => 'medium'
|
190 |
),
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
'hide_sharecount' => array(
|
198 |
'id' => 'hide_sharecount',
|
199 |
'name' => __( 'Hide Sharecount', 'mashsb' ),
|
125 |
'id' => 'mashsb_sharemethod',
|
126 |
'name' => __( 'Share Count', 'mashsb' ),
|
127 |
//'desc' => __( '- <i>MashEngine</i> collects shares by direct request to social networks.<br><br><i>SharedCount.com</i> is a third party service free for up to 10.000 daily requests. It collects shares for Facebook, Pinterest, Stumbleupon. (For GDPR compliance you should select the sharedcount.com service.)<br><br>Twitter count is aggreagated via <a href="https://twitcount.com" target="_blank" rel="external nofollow">https://twitcount.com</a>. You must sign up with your Twitter account for this free service to get the twitter share count. Visit the site http://twitcount.com, fill in your website domain and click on <i>Sign up</i>. <br><br><strong>Note: You need <a href="https://mashshare.net/downloads/mashshare-social-networks-addon/" target="_blank">MashShare Social Network Add-On</a> for enabling Twitter count.</strong>', 'mashsb' ),
|
128 |
+
'desc' => __( '- <i>SharedCount.com</i> is a third party service free for up to 10.000 daily requests. It collects shares for Facebook.<br><br>Twitter count is aggreagated via <a href="https://opensharecount.com" target="_blank" rel="external nofollow">https://opensharecount.com</a>. You must sign up with your Twitter account for this free service to get the twitter share count. Visit the site https://opensharecount.com, fill in your website domain and click on <i>Sign up</i>. <br><br><strong>Note: You need <a href="https://mashshare.net/downloads/mashshare-social-networks-addon/" target="_blank">MashShare Social Network Add-On</a> for enabling Twitter count.</strong>', 'mashsb' ),
|
129 |
'type' => 'select',
|
130 |
'options' => array(
|
131 |
//'mashengine' => 'MashEngine',
|
150 |
'caching_method' => array(
|
151 |
'id' => 'caching_method',
|
152 |
'name' => __( 'Caching Method', 'mashsb' ),
|
153 |
+
'desc' => sprintf(__( 'The <i>Async Cache Refresh</i> method never adds additonal load time for a visitor and 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> <i>Refresh while loading</i> rebuilds expired cache while page is loading and adds a little extra time during inital page load. <br><br><strong>If shares are not updating</strong> or site is heavy cached try <i>Refresh while loading!</i> 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',
|
188 |
'type' => 'text',
|
189 |
'size' => 'medium'
|
190 |
),
|
191 |
+
'disable_sharecount' => array(
|
192 |
+
'id' => 'disable_sharecount',
|
193 |
+
'name' => __( 'Disable Sharecount', 'mashsb' ),
|
194 |
+
'desc' => __( 'Use this if share should not be counted. Default: false', 'mashsb' ),
|
195 |
+
'type' => 'checkbox'
|
196 |
+
),
|
197 |
'hide_sharecount' => array(
|
198 |
'id' => 'hide_sharecount',
|
199 |
'name' => __( 'Hide Sharecount', 'mashsb' ),
|
includes/header-meta-tags.php
CHANGED
@@ -10,7 +10,7 @@ if( !defined( 'ABSPATH' ) )
|
|
10 |
|
11 |
class MASHSB_HEADER_META_TAGS {
|
12 |
|
13 |
-
protected $postID
|
14 |
protected $imageURL;
|
15 |
protected $post_title;
|
16 |
protected $post_featured_image;
|
@@ -39,7 +39,7 @@ class MASHSB_HEADER_META_TAGS {
|
|
39 |
protected $yoast_twitter_image;
|
40 |
protected $yoast_twitter_creator;
|
41 |
// yoast social settings
|
42 |
-
protected $yoast
|
43 |
protected $post;
|
44 |
|
45 |
public function __construct() {
|
@@ -54,12 +54,12 @@ class MASHSB_HEADER_META_TAGS {
|
|
54 |
return false;
|
55 |
}
|
56 |
|
57 |
-
$this->post
|
58 |
-
$this->postID
|
59 |
-
$this->post_title
|
60 |
-
$this->post_featured_image
|
61 |
-
$this->post_description
|
62 |
-
$this->pinterest_image
|
63 |
$this->pinterest_description = $this->get_pinterest_description();
|
64 |
|
65 |
$this->get_og_data();
|
@@ -77,20 +77,18 @@ class MASHSB_HEADER_META_TAGS {
|
|
77 |
* @return void
|
78 |
*/
|
79 |
public function get_og_data() {
|
80 |
-
$this->og_title
|
81 |
-
$this->og_description
|
82 |
-
$this->og_image
|
83 |
-
$this->og_type
|
84 |
-
$this->twitter_title
|
85 |
$this->twitter_creator = $this->get_twitter_creator();
|
86 |
-
$this->twitter_site
|
87 |
-
}
|
88 |
-
|
89 |
-
public function sanitize_data($string){
|
90 |
-
//return $string;
|
91 |
-
return htmlspecialchars(preg_replace( "/\r|\n/", " ", $string ));
|
92 |
}
|
93 |
|
|
|
|
|
|
|
94 |
|
95 |
/**
|
96 |
* Get Yoast open graph and social data
|
@@ -104,33 +102,33 @@ class MASHSB_HEADER_META_TAGS {
|
|
104 |
}
|
105 |
|
106 |
global $wpseo_og;
|
107 |
-
if( has_action( 'wpseo_head', array($wpseo_og, 'opengraph') ) && function_exists('wpseo_replace_vars') ) {
|
108 |
// Yoast open graph tags
|
109 |
-
$this->yoast_og_title
|
110 |
$this->yoast_og_description = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-description', true );
|
111 |
-
$this->yoast_og_image
|
112 |
-
|
113 |
-
$this->yoast_og_title
|
114 |
-
$this->yoast_og_description = wpseo_replace_vars($this->yoast_og_description, $this->post);
|
115 |
-
$this->yoast_og_image
|
116 |
-
|
117 |
-
|
118 |
|
119 |
// Yoast twitter card data
|
120 |
-
$this->yoast_twitter_title
|
121 |
$this->yoast_twitter_description = get_post_meta( $this->postID, '_yoast_wpseo_twitter-description', true );
|
122 |
-
$this->yoast_twitter_image
|
123 |
-
|
124 |
-
$this->yoast_twitter_title
|
125 |
$this->yoast_twitter_description = wpseo_replace_vars( $this->yoast_twitter_description, $this->post );
|
126 |
-
$this->yoast_twitter_image
|
127 |
|
128 |
// Yoast SEO title and description
|
129 |
-
$this->yoast_seo_title
|
130 |
$this->yoast_seo_description = get_post_meta( $this->postID, '_yoast_wpseo_metadesc', true );
|
131 |
-
|
132 |
-
$this->yoast_seo_title
|
133 |
-
$this->yoast_seo_description =
|
134 |
|
135 |
// Remove Yoast open graph and twitter cards data from head of site
|
136 |
if( $this->is_open_graph() ) {
|
@@ -188,6 +186,7 @@ class MASHSB_HEADER_META_TAGS {
|
|
188 |
// Default return value
|
189 |
return $this->post_title;
|
190 |
}
|
|
|
191 |
/**
|
192 |
* Get the og type
|
193 |
*
|
@@ -237,11 +236,11 @@ class MASHSB_HEADER_META_TAGS {
|
|
237 |
return trim( get_the_excerpt() );
|
238 |
}
|
239 |
|
240 |
-
$the_post
|
241 |
-
$the_excerpt
|
242 |
$excerpt_length = 35; //Sets excerpt length by words
|
243 |
-
$the_excerpt
|
244 |
-
$words
|
245 |
if( count( $words ) > $excerpt_length ) {
|
246 |
array_pop( $words );
|
247 |
$the_excerpt = implode( ' ', $words );
|
@@ -279,13 +278,13 @@ class MASHSB_HEADER_META_TAGS {
|
|
279 |
if( empty( $og_image ) ) {
|
280 |
return;
|
281 |
}
|
282 |
-
|
283 |
$upload_dir = wp_upload_dir();
|
284 |
-
$img_src
|
285 |
-
|
286 |
-
$imagesize = is_readable($img_src) ? getimagesize( $img_src ) : '';
|
287 |
|
288 |
-
|
|
|
|
|
289 |
return $imagesize;
|
290 |
}
|
291 |
}
|
@@ -455,10 +454,7 @@ class MASHSB_HEADER_META_TAGS {
|
|
455 |
* @return string
|
456 |
*/
|
457 |
public function get_twitter_title() {
|
458 |
-
|
459 |
-
return $this->twitter_title;
|
460 |
-
}
|
461 |
-
|
462 |
if( defined( 'WPSEO_VERSION' ) ) {
|
463 |
if( !empty( $this->yoast_twitter_title ) ) {
|
464 |
return $this->yoast_twitter_title;
|
@@ -467,6 +463,11 @@ class MASHSB_HEADER_META_TAGS {
|
|
467 |
return $this->yoast_seo_title;
|
468 |
}
|
469 |
}
|
|
|
|
|
|
|
|
|
|
|
470 |
// Default return value
|
471 |
return $this->post_title;
|
472 |
}
|
@@ -492,7 +493,7 @@ class MASHSB_HEADER_META_TAGS {
|
|
492 |
* @global array $ob_wp_simplepodcastpress
|
493 |
*/
|
494 |
public function remove_simple_podcast_press_og() {
|
495 |
-
if(!$this->is_open_graph()){
|
496 |
return;
|
497 |
}
|
498 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
@@ -552,14 +553,14 @@ class MASHSB_HEADER_META_TAGS {
|
|
552 |
* @return string HTML
|
553 |
*/
|
554 |
public function render_open_graph_meta() {
|
555 |
-
|
556 |
if( !$this->is_open_graph() ) {
|
557 |
$html = '';
|
558 |
return $html;
|
559 |
}
|
560 |
|
561 |
$opengraph = PHP_EOL . '<!-- Open Graph Meta Tags generated by MashShare ' . MASHSB_VERSION . ' - https://mashshare.net -->';
|
562 |
-
$opengraph .= PHP_EOL . '<meta property="og:type" content="'
|
563 |
if( $this->get_og_title() ) {
|
564 |
$opengraph .= PHP_EOL . '<meta property="og:title" content="' . $this->get_og_title() . '" />';
|
565 |
}
|
@@ -584,7 +585,7 @@ class MASHSB_HEADER_META_TAGS {
|
|
584 |
$opengraph .= PHP_EOL . '<meta property="article:modified_time" content="' . get_post_modified_time( 'c' ) . '" />';
|
585 |
$opengraph .= PHP_EOL . '<meta property="og:updated_time" content="' . get_post_modified_time( 'c' ) . '" />';
|
586 |
$opengraph .= PHP_EOL . '<!-- Open Graph Meta Tags generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->';
|
587 |
-
|
588 |
return $opengraph;
|
589 |
}
|
590 |
|
@@ -601,9 +602,9 @@ class MASHSB_HEADER_META_TAGS {
|
|
601 |
}
|
602 |
|
603 |
$twittercard = PHP_EOL . '<!-- Twitter Card generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->';
|
604 |
-
|
605 |
$imagesize = $this->get_og_image_size();
|
606 |
-
if( is_array( $imagesize ) && isset($imagesize[0]) && isset($imagesize[1])
|
607 |
$twittercard .= PHP_EOL . '<meta property="og:image:width" content="' . $imagesize[0] . '" />';
|
608 |
$twittercard .= PHP_EOL . '<meta property="og:image:height" content="' . $imagesize[1] . '" />';
|
609 |
}
|
@@ -659,9 +660,9 @@ class MASHSB_HEADER_META_TAGS {
|
|
659 |
*/
|
660 |
function mashsb_meta_tags_init() {
|
661 |
global $mashsb_meta_tags, $mashsb_options;
|
662 |
-
|
663 |
// Do not show meta boxes
|
664 |
-
if(isset($mashsb_options['user_roles_for_sharing_options']) && in_array('disable', $mashsb_options['user_roles_for_sharing_options'])){
|
665 |
return;
|
666 |
}
|
667 |
|
10 |
|
11 |
class MASHSB_HEADER_META_TAGS {
|
12 |
|
13 |
+
protected $postID = 0;
|
14 |
protected $imageURL;
|
15 |
protected $post_title;
|
16 |
protected $post_featured_image;
|
39 |
protected $yoast_twitter_image;
|
40 |
protected $yoast_twitter_creator;
|
41 |
// yoast social settings
|
42 |
+
protected $yoast = array();
|
43 |
protected $post;
|
44 |
|
45 |
public function __construct() {
|
54 |
return false;
|
55 |
}
|
56 |
|
57 |
+
$this->post = $post;
|
58 |
+
$this->postID = get_the_ID();
|
59 |
+
$this->post_title = $this->get_title();
|
60 |
+
$this->post_featured_image = $this->get_featured_image();
|
61 |
+
$this->post_description = $this->sanitize_data( $this->get_excerpt_by_id( $this->postID ) );
|
62 |
+
$this->pinterest_image = $this->get_pinterest_image_url();
|
63 |
$this->pinterest_description = $this->get_pinterest_description();
|
64 |
|
65 |
$this->get_og_data();
|
77 |
* @return void
|
78 |
*/
|
79 |
public function get_og_data() {
|
80 |
+
$this->og_title = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_og_title', true ) );
|
81 |
+
$this->og_description = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_og_description', true ) );
|
82 |
+
$this->og_image = $this->get_image_url();
|
83 |
+
$this->og_type = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_og_type', true ) );
|
84 |
+
$this->twitter_title = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_custom_tweet', true ) );
|
85 |
$this->twitter_creator = $this->get_twitter_creator();
|
86 |
+
$this->twitter_site = mashsb_get_twitter_username();
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
+
public function sanitize_data( $string ) {
|
90 |
+
return htmlspecialchars( preg_replace( "/\r|\n/", " ", $string ) );
|
91 |
+
}
|
92 |
|
93 |
/**
|
94 |
* Get Yoast open graph and social data
|
102 |
}
|
103 |
|
104 |
global $wpseo_og;
|
105 |
+
if( has_action( 'wpseo_head', array($wpseo_og, 'opengraph') ) && function_exists( 'wpseo_replace_vars' ) ) {
|
106 |
// Yoast open graph tags
|
107 |
+
$this->yoast_og_title = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-title', true );
|
108 |
$this->yoast_og_description = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-description', true );
|
109 |
+
$this->yoast_og_image = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-image', true );
|
110 |
+
|
111 |
+
$this->yoast_og_title = wpseo_replace_vars( $this->yoast_og_title, $this->post );
|
112 |
+
$this->yoast_og_description = wpseo_replace_vars( $this->yoast_og_description, $this->post );
|
113 |
+
$this->yoast_og_image = wpseo_replace_vars( $this->yoast_og_image, $this->post );
|
114 |
+
|
115 |
+
|
116 |
|
117 |
// Yoast twitter card data
|
118 |
+
$this->yoast_twitter_title = get_post_meta( $this->postID, '_yoast_wpseo_twitter-title', true );
|
119 |
$this->yoast_twitter_description = get_post_meta( $this->postID, '_yoast_wpseo_twitter-description', true );
|
120 |
+
$this->yoast_twitter_image = get_post_meta( $this->postID, '_yoast_wpseo_twitter-image', true );
|
121 |
+
|
122 |
+
$this->yoast_twitter_title = wpseo_replace_vars( $this->yoast_twitter_title, $this->post );
|
123 |
$this->yoast_twitter_description = wpseo_replace_vars( $this->yoast_twitter_description, $this->post );
|
124 |
+
$this->yoast_twitter_image = wpseo_replace_vars( $this->yoast_twitter_image, $this->post );
|
125 |
|
126 |
// Yoast SEO title and description
|
127 |
+
$this->yoast_seo_title = get_post_meta( $this->postID, '_yoast_wpseo_title', true );
|
128 |
$this->yoast_seo_description = get_post_meta( $this->postID, '_yoast_wpseo_metadesc', true );
|
129 |
+
|
130 |
+
$this->yoast_seo_title = wpseo_replace_vars( $this->yoast_seo_title, $this->post );
|
131 |
+
$this->yoast_seo_description = wpseo_replace_vars( $this->yoast_seo_description, $this->post );
|
132 |
|
133 |
// Remove Yoast open graph and twitter cards data from head of site
|
134 |
if( $this->is_open_graph() ) {
|
186 |
// Default return value
|
187 |
return $this->post_title;
|
188 |
}
|
189 |
+
|
190 |
/**
|
191 |
* Get the og type
|
192 |
*
|
236 |
return trim( get_the_excerpt() );
|
237 |
}
|
238 |
|
239 |
+
$the_post = get_post( $post_id ); //Gets post ID
|
240 |
+
$the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt
|
241 |
$excerpt_length = 35; //Sets excerpt length by words
|
242 |
+
$the_excerpt = strip_tags( strip_shortcodes( $the_excerpt ) ); //Strips tags and images
|
243 |
+
$words = explode( ' ', $the_excerpt, $excerpt_length + 1 );
|
244 |
if( count( $words ) > $excerpt_length ) {
|
245 |
array_pop( $words );
|
246 |
$the_excerpt = implode( ' ', $words );
|
278 |
if( empty( $og_image ) ) {
|
279 |
return;
|
280 |
}
|
281 |
+
|
282 |
$upload_dir = wp_upload_dir();
|
283 |
+
$img_src = str_replace( $upload_dir['baseurl'], $upload_dir['basedir'], $this->get_og_image() );
|
|
|
|
|
284 |
|
285 |
+
$imagesize = is_readable( $img_src ) ? getimagesize( $img_src ) : '';
|
286 |
+
|
287 |
+
if( !empty( $imagesize ) ) {
|
288 |
return $imagesize;
|
289 |
}
|
290 |
}
|
454 |
* @return string
|
455 |
*/
|
456 |
public function get_twitter_title() {
|
457 |
+
// Return Yoast twitter title
|
|
|
|
|
|
|
458 |
if( defined( 'WPSEO_VERSION' ) ) {
|
459 |
if( !empty( $this->yoast_twitter_title ) ) {
|
460 |
return $this->yoast_twitter_title;
|
463 |
return $this->yoast_seo_title;
|
464 |
}
|
465 |
}
|
466 |
+
|
467 |
+
// Return MashShare Twitter title
|
468 |
+
if( !empty( $this->twitter_title ) ) {
|
469 |
+
return $this->twitter_title;
|
470 |
+
}
|
471 |
// Default return value
|
472 |
return $this->post_title;
|
473 |
}
|
493 |
* @global array $ob_wp_simplepodcastpress
|
494 |
*/
|
495 |
public function remove_simple_podcast_press_og() {
|
496 |
+
if( !$this->is_open_graph() ) {
|
497 |
return;
|
498 |
}
|
499 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
553 |
* @return string HTML
|
554 |
*/
|
555 |
public function render_open_graph_meta() {
|
556 |
+
|
557 |
if( !$this->is_open_graph() ) {
|
558 |
$html = '';
|
559 |
return $html;
|
560 |
}
|
561 |
|
562 |
$opengraph = PHP_EOL . '<!-- Open Graph Meta Tags generated by MashShare ' . MASHSB_VERSION . ' - https://mashshare.net -->';
|
563 |
+
$opengraph .= PHP_EOL . '<meta property="og:type" content="' . $this->get_og_type() . '" /> ';
|
564 |
if( $this->get_og_title() ) {
|
565 |
$opengraph .= PHP_EOL . '<meta property="og:title" content="' . $this->get_og_title() . '" />';
|
566 |
}
|
585 |
$opengraph .= PHP_EOL . '<meta property="article:modified_time" content="' . get_post_modified_time( 'c' ) . '" />';
|
586 |
$opengraph .= PHP_EOL . '<meta property="og:updated_time" content="' . get_post_modified_time( 'c' ) . '" />';
|
587 |
$opengraph .= PHP_EOL . '<!-- Open Graph Meta Tags generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->';
|
588 |
+
|
589 |
return $opengraph;
|
590 |
}
|
591 |
|
602 |
}
|
603 |
|
604 |
$twittercard = PHP_EOL . '<!-- Twitter Card generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->';
|
605 |
+
|
606 |
$imagesize = $this->get_og_image_size();
|
607 |
+
if( is_array( $imagesize ) && isset( $imagesize[0] ) && isset( $imagesize[1] ) ) {
|
608 |
$twittercard .= PHP_EOL . '<meta property="og:image:width" content="' . $imagesize[0] . '" />';
|
609 |
$twittercard .= PHP_EOL . '<meta property="og:image:height" content="' . $imagesize[1] . '" />';
|
610 |
}
|
660 |
*/
|
661 |
function mashsb_meta_tags_init() {
|
662 |
global $mashsb_meta_tags, $mashsb_options;
|
663 |
+
|
664 |
// Do not show meta boxes
|
665 |
+
if( isset( $mashsb_options['user_roles_for_sharing_options'] ) && in_array( 'disable', $mashsb_options['user_roles_for_sharing_options'] ) ) {
|
666 |
return;
|
667 |
}
|
668 |
|
includes/install.php
CHANGED
@@ -95,7 +95,7 @@ function mashsb_install() {
|
|
95 |
'twitter_card' => '1',
|
96 |
'open_graph' => '1',
|
97 |
'mashsb_sharemethod' => 'mashengine',
|
98 |
-
'caching_method' => '
|
99 |
'mashsu_methods' => 'disabled',
|
100 |
'responsive_buttons' => '1',
|
101 |
'button_margin' => '1',
|
95 |
'twitter_card' => '1',
|
96 |
'open_graph' => '1',
|
97 |
'mashsb_sharemethod' => 'mashengine',
|
98 |
+
'caching_method' => 'refresh_loading',
|
99 |
'mashsu_methods' => 'disabled',
|
100 |
'responsive_buttons' => '1',
|
101 |
'button_margin' => '1',
|
includes/sharecount-functions.php
CHANGED
@@ -280,50 +280,6 @@ function mashsb_is_cache_refresh() {
|
|
280 |
}
|
281 |
|
282 |
return false;
|
283 |
-
|
284 |
-
|
285 |
-
// New cache on singular pages
|
286 |
-
//
|
287 |
-
// Refreshing cache on blog posts like categories will lead
|
288 |
-
// to high load and multiple API requests so we only check
|
289 |
-
// the main url on these other pages
|
290 |
-
// if( is_singular() && isset($post->ID) ) {
|
291 |
-
// // last updated timestamp
|
292 |
-
// $last_updated = get_post_meta( $post->ID, 'mashsb_timestamp', true );
|
293 |
-
// if( !empty( $last_updated ) ) {
|
294 |
-
// MASHSB()->logger->info( 'mashsb_is_cache_refresh - is_singular() url: ' . get_permalink($post->ID) . ' : last updated:' . date( 'Y-m-d H:i:s', $last_updated ) );
|
295 |
-
// }
|
296 |
-
// } else if( mashsb_get_main_url() ) {
|
297 |
-
//
|
298 |
-
// // Get transient timeout and calculate last update time
|
299 |
-
// $url = mashsb_get_main_url();
|
300 |
-
// $transient = '_transient_timeout_mashcount_' . md5( $url );
|
301 |
-
// $last_updated = get_option( $transient ) - mashsb_get_expiration();
|
302 |
-
// if( !empty( $last_updated ) ) {
|
303 |
-
// MASHSB()->logger->info( 'mashsb_is_cache_refresh() mashsb_get_main_url() url: ' . $url . ' last updated:' . date( 'Y-m-d H:i:s', $last_updated ) );
|
304 |
-
// }
|
305 |
-
// } else {
|
306 |
-
// // No valid URL so do not refresh cache
|
307 |
-
// MASHSB()->logger->info( 'mashsb_is_cache_refresh: No valid URL - do not refresh cache' );
|
308 |
-
// return false;
|
309 |
-
// }
|
310 |
-
//
|
311 |
-
// // No timestamp so let's create cache for the first time
|
312 |
-
// if( empty( $last_updated ) ) {
|
313 |
-
// MASHSB()->logger->info( 'mashsb_is_cache_refresh: No Timestamp. Refresh Cache' );
|
314 |
-
// return true;
|
315 |
-
// }
|
316 |
-
//
|
317 |
-
// // The caching expiration
|
318 |
-
// $expiration = mashsb_get_expiration();
|
319 |
-
// $next_update = $last_updated + $expiration;
|
320 |
-
// MASHSB()->logger->info( 'mashsb_is_cache_refresh. Next update ' . date( 'Y-m-d H:i:s', $next_update ) . ' current time: ' . date( 'Y-m-d H:i:s', time() ) );
|
321 |
-
//
|
322 |
-
// // Refresh Cache when last update plus expiration time is older than current time
|
323 |
-
// if( ($last_updated + $expiration) <= time() ) {
|
324 |
-
// MASHSB()->logger->info( 'mashsb_is_cache_refresh: Refresh Cache!' );
|
325 |
-
// return true;
|
326 |
-
// }
|
327 |
}
|
328 |
|
329 |
/**
|
280 |
}
|
281 |
|
282 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
}
|
284 |
|
285 |
/**
|
includes/sharedcount.class.php
CHANGED
@@ -12,177 +12,217 @@
|
|
12 |
*/
|
13 |
class mashsbSharedcount {
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
return 0;
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
if( empty( $this->apikey ) ) {
|
136 |
-
return 0; //quit early if there's no API key.
|
137 |
-
}
|
138 |
-
|
139 |
-
$domain = isset( $mashsb_options['mashsharer_sharecount_domain'] ) ? trim( $mashsb_options['mashsharer_sharecount_domain'] ) : '';
|
140 |
-
if( !isset( $domain ) || empty( $domain ) ) {
|
141 |
-
$domain = "free.sharedcount.com";
|
142 |
-
$this->update_sharedcount_domain( $domain );
|
143 |
-
}
|
144 |
-
|
145 |
-
try {
|
146 |
-
$counts = array();
|
147 |
-
//$counts = $this->_curl( 'http://' . $domain . "/?url=" . $this->url . "&apikey=" . $this->apikey );
|
148 |
-
$counts = $this->_curl( 'https://api.sharedcount.com/v1.0/?url=' . $this->url . "&apikey=" . $this->apikey );
|
149 |
-
|
150 |
-
if( isset( $counts["Error"] ) && isset( $counts['Domain'] ) && $counts["Type"] === "domain_apikey_mismatch" ) {
|
151 |
-
$this->update_sharedcount_domain( $counts['Domain'] );
|
152 |
-
return 0;
|
153 |
-
} else if( isset( $counts["Error"] ) && isset( $counts['Type'] ) && $counts['Type'] === 'invalid_api_key' ) {
|
154 |
-
$this->update_sharedcount_domain();
|
155 |
-
return 0;
|
156 |
-
}
|
157 |
-
|
158 |
-
mashdebug()->error( "Facebook total count: " . $counts['Facebook']['total_count'] );
|
159 |
-
MASHSB()->logger->info( "URL: " . urldecode( $this->url ) . " API Key:" . $this->apikey . " sharedcount.com FB total_count: " . $counts['Facebook']['total_count'] . " FB share_count:" . $counts['Facebook']['share_count'] . " G+:" . $counts['GooglePlusOne'] . " Linkedin:" . $counts['LinkedIn'] . " Stumble: " . $counts['StumbleUpon'] . " Pinterest: " . $counts['Pinterest'] );
|
160 |
-
|
161 |
-
$return = is_array($counts) ? array_merge($counts, array('Twitter' => $this->getTwitterShares())) : array('Twitter' => $this->getTwitterShares());
|
162 |
-
|
163 |
-
|
164 |
-
return $return;
|
165 |
-
} catch ( Exception $e ) {
|
166 |
-
mashdebug()->error( "error: " . $counts );
|
167 |
-
MASHSB()->logger->info( 'ERROR: Curl()' . $counts );
|
168 |
-
return 0;
|
169 |
-
}
|
170 |
-
mashdebug()->error( "error2: " . $counts );
|
171 |
-
MASHSB()->logger->info( 'ERROR 2: Curl()' . $counts );
|
172 |
-
return 0;
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Get twitter tweet count if social network add-on is installed
|
177 |
-
* @return int
|
178 |
-
*/
|
179 |
-
private function getTwitterShares(){
|
180 |
-
if ( class_exists( 'mashnetTwitter')){
|
181 |
-
$twitter = new mashnetTwitter($this->url);
|
182 |
-
return empty($twitter->getTwitterShares()) ? 0 : $twitter->getTwitterShares();
|
183 |
-
}
|
184 |
-
return 0;
|
185 |
-
}
|
186 |
|
187 |
}
|
188 |
|
12 |
*/
|
13 |
class mashsbSharedcount {
|
14 |
|
15 |
+
private $url, $timeout;
|
16 |
+
private $http_scheme_url;
|
17 |
+
private $https_scheme_url;
|
18 |
+
|
19 |
+
function __construct( $url, $timeout = 10, $apikey = '' ) {
|
20 |
+
global $mashsb_options;
|
21 |
+
|
22 |
+
// Uncomment for testing
|
23 |
+
//$url = 'https://google.com';
|
24 |
+
|
25 |
+
// remove http and https
|
26 |
+
$url_host_path = preg_replace( "(^https?://)", "", $url );
|
27 |
+
|
28 |
+
// build new urls
|
29 |
+
$this->http_scheme_url = rawurlencode( 'http://' . $url_host_path );
|
30 |
+
$this->https_scheme_url = rawurlencode( 'https://' . $url_host_path );
|
31 |
+
|
32 |
+
$this->url = rawurlencode( $url );
|
33 |
+
$this->timeout = $timeout;
|
34 |
+
$this->apikey = trim( $apikey );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Collect shares for facebook and twitter (Twitter not supported any longer)
|
39 |
+
* @global array $mashsb_options
|
40 |
+
* @return type
|
41 |
+
*/
|
42 |
+
public function getFBTWCounts() {
|
43 |
+
global $mashsb_options;
|
44 |
+
|
45 |
+
isset( $mashsb_options['facebook_count_mode'] ) ? $fb_mode = $mashsb_options['facebook_count_mode'] : $fb_mode = '';
|
46 |
+
|
47 |
+
$sharecounts = $this->get_sharedcount();
|
48 |
+
|
49 |
+
if( !$sharecounts ) {
|
50 |
+
$this->sharecount = new stdClass;
|
51 |
+
$this->sharecount->total = 0;
|
52 |
+
return $this->sharecount;
|
53 |
+
}
|
54 |
+
$counts = array('shares' => array(), 'total' => 0);
|
55 |
+
switch ( $fb_mode ) {
|
56 |
+
case $fb_mode === 'likes':
|
57 |
+
$counts['shares']['fb'] = $sharecounts['Facebook']['like_count'];
|
58 |
+
$counts['shares']['fb_https'] = $sharecounts['https']['Facebook']['like_count'];
|
59 |
+
|
60 |
+
break;
|
61 |
+
case $fb_mode === 'total':
|
62 |
+
$counts['shares']['fb'] = $sharecounts['Facebook']['total_count'];
|
63 |
+
$counts['shares']['fb_https'] = $sharecounts['https']['Facebook']['total_count'];
|
64 |
+
break;
|
65 |
+
default:
|
66 |
+
$counts['shares']['fb'] = $sharecounts['Facebook']['share_count'];
|
67 |
+
$counts['shares']['fb_https'] = $sharecounts['https']['Facebook']['share_count'];
|
68 |
+
}
|
69 |
+
$counts['shares']['tw'] = $sharecounts['Twitter'];
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
foreach ( $counts['shares'] as $mashsbcounts => $sharecount ) {
|
74 |
+
$counts['total'] += ( int ) $sharecount;
|
75 |
+
}
|
76 |
+
|
77 |
+
mashdebug()->error( "sharedcount.com getFBTWCounts: " . $counts['total'] );
|
78 |
+
|
79 |
+
$totalArr = array('total' => $counts['total']);
|
80 |
+
$objMerged = ( object ) array_merge( ( array ) $sharecounts, ( array ) $totalArr );
|
81 |
+
return $objMerged;
|
82 |
+
}
|
83 |
+
|
84 |
+
/* Only used when mashshare-networks is enabled */
|
85 |
+
|
86 |
+
function getAllCounts() {
|
87 |
+
global $mashsb_options;
|
88 |
+
|
89 |
+
isset( $mashsb_options['facebook_count_mode'] ) ? $fb_mode = $mashsb_options['facebook_count_mode'] : $fb_mode = '';
|
90 |
+
|
91 |
+
$sharecounts = $this->get_sharedcount();
|
92 |
+
if( !$sharecounts ) {
|
93 |
+
$this->sharecount = new stdClass;
|
94 |
+
$this->sharecount->total = 0;
|
95 |
+
return $this->sharecount;
|
96 |
+
}
|
97 |
+
|
98 |
+
$counts = array('shares' => array(), 'total' => 0);
|
99 |
+
switch ( $fb_mode ) {
|
100 |
+
case $fb_mode === 'likes':
|
101 |
+
$counts['shares']['fb'] = $sharecounts['Facebook']['like_count'];
|
102 |
+
$counts['shares']['fb_https'] = $sharecounts['https']['Facebook']['like_count'];
|
103 |
+
break;
|
104 |
+
case $fb_mode === 'total':
|
105 |
+
$counts['shares']['fb'] = $sharecounts['Facebook']['total_count'];
|
106 |
+
$counts['shares']['fb_https'] = $sharecounts['https']['Facebook']['total_count'];
|
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;
|
114 |
+
isset( $sharecounts['LinkedIn'] ) ? $counts['shares']['li'] = $sharecounts['LinkedIn'] : $counts['shares']['li'] = 0;
|
115 |
+
isset( $sharecounts['StumbleUpon'] ) ? $counts['shares']['st'] = $sharecounts['StumbleUpon'] : $counts['shares']['st'] = 0;
|
116 |
+
isset( $sharecounts['Pinterest'] ) ? $counts['shares']['pin'] = $sharecounts['Pinterest'] : $counts['shares']['pin'] = 0;
|
117 |
+
isset( $sharecounts['https']['Pinterest'] ) ? $counts['shares']['pin_https'] = $sharecounts['https']['Pinterest'] : $counts['shares']['pin_https'] = 0;
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
+
$total = 0;
|
122 |
+
foreach ( $counts['shares'] as $totalcount ) {
|
123 |
+
$total += ( int ) $totalcount;
|
124 |
+
}
|
125 |
+
$totalArr = array('total' => $total);
|
126 |
+
$objMerged = ( object ) array_merge( ( array ) $sharecounts, ( array ) $totalArr );
|
127 |
+
mashdebug()->info( "sharedcount.com getAllCounts: " . $counts['total'] );
|
128 |
+
return $objMerged;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
*
|
133 |
+
* @global array $mashsb_options
|
134 |
+
* @param type $domain
|
135 |
+
* @return int
|
136 |
+
*/
|
137 |
+
// function update_sharedcount_domain( $domain = false ) {
|
138 |
+
// global $mashsb_options;
|
139 |
+
// if( !$domain ) {
|
140 |
+
// try {
|
141 |
+
// $domain_obj = $this->_curl( 'http://' . $mashsb_options["mashsharer_sharecount_domain"] . "/account?apikey=" . $this->apikey );
|
142 |
+
// $domain = $domain_obj["domain"];
|
143 |
+
// } catch ( Exception $e ) {
|
144 |
+
// mashdebug()->error( "error: " . $domain_obj );
|
145 |
+
// return 0;
|
146 |
+
// }
|
147 |
+
// }
|
148 |
+
// $mashsb_options["mashsharer_sharecount_domain"] = $domain;
|
149 |
+
// update_option( 'mashsb_settings', $mashsb_options );
|
150 |
+
// return 1;
|
151 |
+
// }
|
152 |
+
|
153 |
+
private function _curl( $url ) {
|
154 |
+
$curl = curl_init();
|
155 |
+
curl_setopt( $curl, CURLOPT_URL, $url );
|
156 |
+
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
157 |
+
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 5 );
|
158 |
+
curl_setopt( $curl, CURLOPT_TIMEOUT, 5 ); //timeout in seconds
|
159 |
+
$curl_results = curl_exec( $curl );
|
160 |
+
curl_close( $curl );
|
161 |
+
return json_decode( $curl_results, true );
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Get share count from sharedcount.com API
|
166 |
+
* @global array $mashsb_options
|
167 |
+
* @return mixed array | int
|
168 |
+
*/
|
169 |
+
function get_sharedcount() {
|
170 |
+
|
171 |
+
global $mashsb_options;
|
172 |
+
|
173 |
+
if( empty( $this->apikey ) ) {
|
174 |
+
return 0; //quit early if there's no API key.
|
175 |
+
}
|
176 |
+
|
177 |
+
try {
|
178 |
+
$counts = array();
|
179 |
+
$httpsShares = array();
|
180 |
+
|
181 |
+
if( isset( $mashsb_options['cumulate_http_https'] ) ) {
|
182 |
+
$counts = $this->_curl( 'https://api.sharedcount.com/v1.0/?url=' . $this->http_scheme_url . "&apikey=" . $this->apikey );
|
183 |
+
$httpsShares = $this->_curl( 'https://api.sharedcount.com/v1.0/?url=' . $this->https_scheme_url . "&apikey=" . $this->apikey );
|
184 |
+
} else {
|
185 |
+
$counts = $this->_curl( 'https://api.sharedcount.com/v1.0/?url=' . $this->url . "&apikey=" . $this->apikey );
|
186 |
+
}
|
187 |
+
|
188 |
+
if( isset( $counts["Error"] ) && isset( $counts['Domain'] ) && $counts["Type"] === "domain_apikey_mismatch" ) {
|
189 |
+
return 0;
|
190 |
+
} else if( isset( $counts["Error"] ) && isset( $counts['Type'] ) && $counts['Type'] === 'invalid_api_key' ) {
|
191 |
+
return 0;
|
192 |
+
}
|
193 |
+
|
194 |
+
$tweets = $this->getTwitterShares();
|
195 |
+
|
196 |
+
$counts = is_array( $counts ) ? array_merge( $counts, array('Twitter' => $tweets) ) : array('Twitter' => $tweets);
|
197 |
+
|
198 |
+
$counts['https'] = $httpsShares;
|
199 |
+
|
200 |
+
return $counts;
|
201 |
+
} catch ( Exception $e ) {
|
202 |
+
mashdebug()->error( "error: " . $e );
|
203 |
+
MASHSB()->logger->info( 'ERROR: Curl()' . $e );
|
204 |
return 0;
|
205 |
+
}
|
206 |
+
mashdebug()->error( "error2: " . $counts );
|
207 |
+
MASHSB()->logger->info( 'ERROR 2: Curl()' . $counts );
|
208 |
+
return 0;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Get twitter tweet count if social network add-on is installed
|
213 |
+
* @return int
|
214 |
+
*/
|
215 |
+
private function getTwitterShares() {
|
216 |
+
|
217 |
+
if( class_exists( 'mashnetTwitter' ) ) {
|
218 |
+
$twitter = new mashnetTwitter( $this->url );
|
219 |
+
|
220 |
+
$tweets = $twitter->getTwitterShares();
|
221 |
+
|
222 |
+
return empty( $tweets ) ? 0 : $tweets;
|
223 |
+
}
|
224 |
+
return 0;
|
225 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
|
227 |
}
|
228 |
|
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
|
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.3
|
10 |
* Text Domain: mashsb
|
11 |
* Domain Path: /languages
|
12 |
|
35 |
|
36 |
// Plugin version
|
37 |
if( !defined( 'MASHSB_VERSION' ) ) {
|
38 |
+
define( 'MASHSB_VERSION', '3.6.3' );
|
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.1
|
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.2 =
|
254 |
* New: Necessary change because of new facebook API
|
255 |
* New: Remove mashengine
|
@@ -307,10 +315,7 @@ https://www.mashshare.net/changelog/
|
|
307 |
|
308 |
== Upgrade Notice ==
|
309 |
|
310 |
-
= 3.6.
|
311 |
-
*
|
312 |
-
* New: Remove mashengine
|
313 |
-
* New: Remove GDPR option. Not needed any longer as all shares are collected via sharedcount.com
|
314 |
-
* New: Add admin notice notifying user of new facebook API.
|
315 |
|
316 |
|
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.1
|
12 |
+
Stable tag: 3.6.3
|
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.3 =
|
254 |
+
* Fix: Option Cumulate Http(s) Shares not working for sharedcount.com API endpoint
|
255 |
+
* Fix: Tweets can be requested via opensharecount.com
|
256 |
+
* Fix: Async cache refresh not fired
|
257 |
+
* New: Performance Improvements in collecting sharecount
|
258 |
+
* New: Switch default share method to refresh while loading
|
259 |
+
* New: If yoast twitter title and description is populated the mashshare generated twitter card will use this settings but still allows to define a custom tweet text.
|
260 |
+
|
261 |
= 3.6.2 =
|
262 |
* New: Necessary change because of new facebook API
|
263 |
* New: Remove mashengine
|
315 |
|
316 |
== Upgrade Notice ==
|
317 |
|
318 |
+
= 3.6.3 =
|
319 |
+
* Fix: Option Cumulate Http(s) Shares not working for sharedcount.com API endpoint
|
|
|
|
|
|
|
320 |
|
321 |
|