Version Description
- Fix: Fix a bug where only for http schemed urls the shares are returned. This happens only when no FB APP secret is used.
- Fix: Default table options are not stored on plugin update
- Tweak: Add more unit tests to check shares for http(s)
- Tweak: Show FB app secret admin notice only on MashShare admin pages
Download this release
Release Info
Developer | ReneHermi |
Plugin | Social Media Share Buttons | MashShare |
Version | 3.2.5 |
Comparing to | |
See all releases |
Code changes from version 3.2.4 to 3.2.5
- README.md +9 -0
- includes/MASHSB_SL_Plugin_Updater.php +2 -1
- includes/admin/admin-footer.php +0 -1
- includes/admin/admin-notices.php +4 -0
- includes/admin/dashboard.php +0 -1
- includes/admin/settings/register-settings.php +2 -3
- includes/admin/tracking.php +1 -1
- includes/admin/upgrades/upgrade-functions.php +19 -0
- includes/class-mashsb-html-elements.php +0 -7
- includes/class-mashsb-license-handler.php +0 -17
- includes/class-mashsb-shared-posts-widget.php +1 -1
- includes/header-meta-tags.php +658 -658
- includes/libraries/RolingCurlX.php +1 -1
- includes/logger.php +1 -1
- includes/mashengine.php +2 -2
- includes/sharecount-functions.php +8 -9
- includes/sharedcount.class.php +0 -163
- includes/template-functions.php +4 -24
- mashshare.php +2 -2
- readme.txt +8 -2
README.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1 |
# [Mashshare](https://www.mashshare.net)
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
### Welcome to the Mashshare GitHub Repository
|
4 |
|
5 |
Social sharing optimization is essential for every website that aims to be succesfull regarding traffic and social interaction.
|
1 |
# [Mashshare](https://www.mashshare.net)
|
2 |
|
3 |
+
|
4 |
+
![Plugin Version](https://img.shields.io/wordpress/plugin/v/mashsharer.svg?maxAge=2592000)
|
5 |
+
![Total Downloads](https://img.shields.io/wordpress/plugin/dt/mashsharer.svg?maxAge=2592000)
|
6 |
+
![Plugin Rating](https://img.shields.io/wordpress/plugin/r/mashsharer.svg?maxAge=2592000)
|
7 |
+
![WordPress Compatibility](https://img.shields.io/wordpress/v/mashsharer.svg?maxAge=2592000)
|
8 |
+
[![Build Status](https://img.shields.io/travis/mashshare/MashShare/master.svg?maxAge=3600)](https://travis-ci.org/mashshare/MashShare.svg?branch=master)
|
9 |
+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mashshare/MashShare/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mashshare/MashShare/?branch=master)
|
10 |
+
[![License](https://img.shields.io/badge/license-GPL--2.0%2B-red.svg)](https://github.com/mashshare/MashShare/blob/master/license.txt)
|
11 |
+
|
12 |
### Welcome to the Mashshare GitHub Repository
|
13 |
|
14 |
Social sharing optimization is essential for every website that aims to be succesfull regarding traffic and social interaction.
|
includes/MASHSB_SL_Plugin_Updater.php
CHANGED
@@ -14,6 +14,7 @@ class MASHSB_SL_Plugin_Updater {
|
|
14 |
private $api_data = array();
|
15 |
private $name = '';
|
16 |
private $slug = '';
|
|
|
17 |
|
18 |
/**
|
19 |
* Class constructor.
|
@@ -84,7 +85,7 @@ class MASHSB_SL_Plugin_Updater {
|
|
84 |
|
85 |
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
86 |
|
87 |
-
|
88 |
|
89 |
if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
90 |
|
14 |
private $api_data = array();
|
15 |
private $name = '';
|
16 |
private $slug = '';
|
17 |
+
private $version = '';
|
18 |
|
19 |
/**
|
20 |
* Class constructor.
|
85 |
|
86 |
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
87 |
|
88 |
+
//$this->did_check = true;
|
89 |
|
90 |
if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
91 |
|
includes/admin/admin-footer.php
CHANGED
@@ -16,7 +16,6 @@ if( !defined( 'ABSPATH' ) ) exit;
|
|
16 |
* Add rating links to the settings footer
|
17 |
*
|
18 |
* @since 1.0.0
|
19 |
-
* @param string $footer_text The existing footer text
|
20 |
* @return string
|
21 |
*/
|
22 |
function mashsb_admin_rate_us() {
|
16 |
* Add rating links to the settings footer
|
17 |
*
|
18 |
* @since 1.0.0
|
|
|
19 |
* @return string
|
20 |
*/
|
21 |
function mashsb_admin_rate_us() {
|
includes/admin/admin-notices.php
CHANGED
@@ -218,6 +218,10 @@ add_action( 'wp_ajax_mashsb_hide_notice', 'mashsb_hide_update_notice' );
|
|
218 |
*/
|
219 |
function mashsb_update_notice_101() {
|
220 |
|
|
|
|
|
|
|
|
|
221 |
$notice_id = '101'; //unique id of our notice
|
222 |
$message = sprintf(__( 'Admin notices are pain but read this one or you will miss how to fix your facebook share counts in MashShare: <p><strong style="font-weight:bold;">Go to <a href="%1s">Settings->Networks</a> and request your access token via facebook login - That\'s all. '
|
223 |
. '<a href="#" id="mashsb_notice_101_resp"> Whats also new? </a> </strong>'
|
218 |
*/
|
219 |
function mashsb_update_notice_101() {
|
220 |
|
221 |
+
if( !mashsb_is_admin_page() ) {
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
|
225 |
$notice_id = '101'; //unique id of our notice
|
226 |
$message = sprintf(__( 'Admin notices are pain but read this one or you will miss how to fix your facebook share counts in MashShare: <p><strong style="font-weight:bold;">Go to <a href="%1s">Settings->Networks</a> and request your access token via facebook login - That\'s all. '
|
227 |
. '<a href="#" id="mashsb_notice_101_resp"> Whats also new? </a> </strong>'
|
includes/admin/dashboard.php
CHANGED
@@ -15,7 +15,6 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
15 |
/**
|
16 |
* Add new columns in posts dashboard
|
17 |
*
|
18 |
-
* @param array $content
|
19 |
* @return string
|
20 |
*/
|
21 |
function mashsb_create_share_columns($col) {
|
15 |
/**
|
16 |
* Add new columns in posts dashboard
|
17 |
*
|
|
|
18 |
* @return string
|
19 |
*/
|
20 |
function mashsb_create_share_columns($col) {
|
includes/admin/settings/register-settings.php
CHANGED
@@ -790,7 +790,6 @@ add_filter( 'mashsb_settings_sanitize_text', 'mashsb_sanitize_text_field' );
|
|
790 |
* Retrieve settings tabs
|
791 |
*
|
792 |
* @since 1.8
|
793 |
-
* @param array $input The field value
|
794 |
* @return string $input Sanitizied value
|
795 |
*/
|
796 |
function mashsb_get_settings_tabs() {
|
@@ -826,9 +825,7 @@ function mashsb_get_settings_tabs() {
|
|
826 |
* Retrieve a list of possible expire cache times
|
827 |
*
|
828 |
* @since 2.0.0
|
829 |
-
* @change
|
830 |
*
|
831 |
-
* @param array $methods Array mit verfügbaren Arten
|
832 |
*/
|
833 |
|
834 |
function mashsb_get_expiretimes() {
|
@@ -1299,6 +1296,8 @@ function mashsb_color_callback( $args ) {
|
|
1299 |
if ( ! function_exists( 'mashsb_license_key_callback' ) ) {
|
1300 |
function mashsb_license_key_callback( $args ) {
|
1301 |
global $mashsb_options;
|
|
|
|
|
1302 |
|
1303 |
$messages = array();
|
1304 |
$license = get_option( $args['options']['is_valid_license_option'] );
|
790 |
* Retrieve settings tabs
|
791 |
*
|
792 |
* @since 1.8
|
|
|
793 |
* @return string $input Sanitizied value
|
794 |
*/
|
795 |
function mashsb_get_settings_tabs() {
|
825 |
* Retrieve a list of possible expire cache times
|
826 |
*
|
827 |
* @since 2.0.0
|
|
|
828 |
*
|
|
|
829 |
*/
|
830 |
|
831 |
function mashsb_get_expiretimes() {
|
1296 |
if ( ! function_exists( 'mashsb_license_key_callback' ) ) {
|
1297 |
function mashsb_license_key_callback( $args ) {
|
1298 |
global $mashsb_options;
|
1299 |
+
|
1300 |
+
$class = '';
|
1301 |
|
1302 |
$messages = array();
|
1303 |
$license = get_option( $args['options']['is_valid_license_option'] );
|
includes/admin/tracking.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* @package MASHSB
|
6 |
* @subpackage Admin
|
7 |
-
* @copyright Copyright (c) 2015,
|
8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
* @since 2.5.1
|
10 |
*/
|
4 |
*
|
5 |
* @package MASHSB
|
6 |
* @subpackage Admin
|
7 |
+
* @copyright Copyright (c) 2015, Rene Hermenau
|
8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
* @since 2.5.1
|
10 |
*/
|
includes/admin/upgrades/upgrade-functions.php
CHANGED
@@ -24,6 +24,9 @@ function mashsb_do_automatic_upgrades() {
|
|
24 |
$did_upgrade = false;
|
25 |
$mashsb_version = preg_replace( '/[^0-9.].*/', '', get_option( 'mashsb_version' ) );
|
26 |
|
|
|
|
|
|
|
27 |
if( version_compare( $mashsb_version, '3.2.4', '<' ) ) {
|
28 |
mashsb_upgrade_v1();
|
29 |
}
|
@@ -45,10 +48,26 @@ function mashsb_do_automatic_upgrades() {
|
|
45 |
}
|
46 |
add_action( 'admin_init', 'mashsb_do_automatic_upgrades' );
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* Enable the margin option
|
50 |
*/
|
51 |
function mashsb_upgrade_v1() {
|
|
|
52 |
// Try to load some settings.
|
53 |
$settings = get_option( 'mashsb_settings' );
|
54 |
// Enable the Margin Option.
|
24 |
$did_upgrade = false;
|
25 |
$mashsb_version = preg_replace( '/[^0-9.].*/', '', get_option( 'mashsb_version' ) );
|
26 |
|
27 |
+
if( version_compare( $mashsb_version, '3.2.5', '<' ) ) {
|
28 |
+
mashsb_upgrade_v1a();
|
29 |
+
}
|
30 |
if( version_compare( $mashsb_version, '3.2.4', '<' ) ) {
|
31 |
mashsb_upgrade_v1();
|
32 |
}
|
48 |
}
|
49 |
add_action( 'admin_init', 'mashsb_do_automatic_upgrades' );
|
50 |
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Store default settings
|
54 |
+
*/
|
55 |
+
function mashsb_upgrade_v1a() {
|
56 |
+
|
57 |
+
// Show Rating Div
|
58 |
+
add_option( 'mashsb_RatingDiv', 'no' );
|
59 |
+
// Show facebook access token notice
|
60 |
+
add_option( 'mashsb_update_notice_101', 'yes' );
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
/**
|
67 |
* Enable the margin option
|
68 |
*/
|
69 |
function mashsb_upgrade_v1() {
|
70 |
+
|
71 |
// Try to load some settings.
|
72 |
$settings = get_option( 'mashsb_settings' );
|
73 |
// Enable the Margin Option.
|
includes/class-mashsb-html-elements.php
CHANGED
@@ -123,10 +123,7 @@ class MASHSB_HTML_Elements {
|
|
123 |
*
|
124 |
* @since 1.5.2
|
125 |
*
|
126 |
-
* @param string $name Name attribute of the text field
|
127 |
* @param string $value The value to prepopulate the field with
|
128 |
-
* @param string $label
|
129 |
-
* @param string $desc
|
130 |
* @return string Text field
|
131 |
*/
|
132 |
public function text( $args = array() ) {
|
@@ -178,10 +175,6 @@ class MASHSB_HTML_Elements {
|
|
178 |
*
|
179 |
* @since 1.9
|
180 |
*
|
181 |
-
* @param string $name Name attribute of the textarea
|
182 |
-
* @param string $value The value to prepopulate the field with
|
183 |
-
* @param string $label
|
184 |
-
* @param string $desc
|
185 |
* @return string textarea
|
186 |
*/
|
187 |
public function textarea( $args = array() ) {
|
123 |
*
|
124 |
* @since 1.5.2
|
125 |
*
|
|
|
126 |
* @param string $value The value to prepopulate the field with
|
|
|
|
|
127 |
* @return string Text field
|
128 |
*/
|
129 |
public function text( $args = array() ) {
|
175 |
*
|
176 |
* @since 1.9
|
177 |
*
|
|
|
|
|
|
|
|
|
178 |
* @return string textarea
|
179 |
*/
|
180 |
public function textarea( $args = array() ) {
|
includes/class-mashsb-license-handler.php
CHANGED
@@ -13,19 +13,6 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
13 |
|
14 |
if ( ! class_exists( 'MASHSB_License' ) ) :
|
15 |
|
16 |
-
// uncomment for debugging
|
17 |
-
//add_action( 'http_api_debug', 'viper_http_api_debug', 10, 5 );
|
18 |
-
|
19 |
-
function mashsb_http_api_debug( $response, $type, $class, $args, $url ) {
|
20 |
-
// You can change this from error_log() to var_dump() but it can break AJAX requests
|
21 |
-
error_log( 'Request URL: ' . var_export( $url, true ) );
|
22 |
-
error_log( 'Request Args: ' . var_export( $args, true ) );
|
23 |
-
error_log( 'Request Response : ' . var_export( $response, true ) );
|
24 |
-
var_dump( 'Request URL: ' . var_export( $url, true ) );
|
25 |
-
var_dump( 'Request Args: ' . var_export( $args, true ) );
|
26 |
-
var_dump( 'Request Response : ' . var_export( $response, true ) );
|
27 |
-
}
|
28 |
-
|
29 |
/**
|
30 |
* MASHSB_License Class
|
31 |
*/
|
@@ -223,11 +210,7 @@ class MASHSB_License {
|
|
223 |
* @return void
|
224 |
*/
|
225 |
public function activate_license() {
|
226 |
-
|
227 |
|
228 |
-
if ( ! isset( $_POST["mashsb_settings"] ) ) {
|
229 |
-
//return;
|
230 |
-
}
|
231 |
|
232 |
if ( ! isset( $_REQUEST[ $this->item_shortname . '_license_key-nonce'] ) || ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce'], $this->item_shortname . '_license_key-nonce' ) ) {
|
233 |
|
13 |
|
14 |
if ( ! class_exists( 'MASHSB_License' ) ) :
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
/**
|
17 |
* MASHSB_License Class
|
18 |
*/
|
210 |
* @return void
|
211 |
*/
|
212 |
public function activate_license() {
|
|
|
213 |
|
|
|
|
|
|
|
214 |
|
215 |
if ( ! isset( $_REQUEST[ $this->item_shortname . '_license_key-nonce'] ) || ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce'], $this->item_shortname . '_license_key-nonce' ) ) {
|
216 |
|
includes/class-mashsb-shared-posts-widget.php
CHANGED
@@ -199,7 +199,7 @@ class mashsb_mostshared_posts_widget extends WP_Widget {
|
|
199 |
/**
|
200 |
* Cut characters of the excerpt
|
201 |
*
|
202 |
-
* @param type $
|
203 |
* @param type $int
|
204 |
* @return type
|
205 |
*/
|
199 |
/**
|
200 |
* Cut characters of the excerpt
|
201 |
*
|
202 |
+
* @param type $excerpt
|
203 |
* @param type $int
|
204 |
* @return type
|
205 |
*/
|
includes/header-meta-tags.php
CHANGED
@@ -1,658 +1,658 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Exit if accessed directly
|
4 |
-
if( !defined( 'ABSPATH' ) )
|
5 |
-
exit;
|
6 |
-
|
7 |
-
/*
|
8 |
-
* Create twitter card and open graph tags
|
9 |
-
*/
|
10 |
-
|
11 |
-
class MASHSB_HEADER_META_TAGS {
|
12 |
-
|
13 |
-
protected $postID = 0;
|
14 |
-
protected $imageURL;
|
15 |
-
protected $post_title;
|
16 |
-
protected $post_featured_image;
|
17 |
-
protected $post_description;
|
18 |
-
protected $og_title = '';
|
19 |
-
protected $og_description;
|
20 |
-
protected $og_image;
|
21 |
-
protected $fb_author_url;
|
22 |
-
protected $fb_app_id;
|
23 |
-
protected $twitter_title;
|
24 |
-
protected $twitter_description;
|
25 |
-
protected $twitter_image;
|
26 |
-
protected $twitter_site;
|
27 |
-
protected $twitter_creator;
|
28 |
-
protected $pinterest_description;
|
29 |
-
protected $pinterest_image;
|
30 |
-
// Yoast Data
|
31 |
-
protected $yoast_og_title;
|
32 |
-
protected $yoast_og_description;
|
33 |
-
protected $yoast_og_image;
|
34 |
-
protected $yoast_seo_title;
|
35 |
-
protected $yoast_seo_description;
|
36 |
-
protected $yoast_twitter_title;
|
37 |
-
protected $yoast_twitter_description;
|
38 |
-
protected $yoast_twitter_image;
|
39 |
-
protected $yoast_twitter_creator;
|
40 |
-
// yoast social settings
|
41 |
-
protected $yoast = array();
|
42 |
-
|
43 |
-
// open-graph add-on data - outdated - only for compatibility
|
44 |
-
//protected $addon_og_title;
|
45 |
-
//protected $addon_og_description;
|
46 |
-
//protected $addon_twitter_title;
|
47 |
-
|
48 |
-
public function __construct() {
|
49 |
-
global $post;
|
50 |
-
|
51 |
-
// Die when $post is not set
|
52 |
-
if( !get_the_ID() ) {
|
53 |
-
return;
|
54 |
-
}
|
55 |
-
// Create Open Graph tags only on singular pages and frontpage
|
56 |
-
if( !is_singular() ) {
|
57 |
-
return false;
|
58 |
-
}
|
59 |
-
|
60 |
-
$this->postID = get_the_ID();
|
61 |
-
$this->post_title = $this->get_title();
|
62 |
-
$this->post_featured_image = $this->get_featured_image();
|
63 |
-
$this->post_description = $this->sanitize_data( $this->get_excerpt_by_id( $this->postID ) );
|
64 |
-
$this->pinterest_image = $this->get_pinterest_image_url();
|
65 |
-
$this->pinterest_description = $this->get_pinterest_description();
|
66 |
-
|
67 |
-
$this->get_og_data();
|
68 |
-
// We do not want to support the old stuff so let's disable this. Hopefully no one demands it!
|
69 |
-
//$this->get_og_add_on_data();
|
70 |
-
$this->remove_jetpack_og();
|
71 |
-
$this->remove_simple_podcast_press_og();
|
72 |
-
$this->get_yoast_data();
|
73 |
-
$this->render_header_meta();
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Get relevant main open graph, twitter and pinterest data and use it for later functions
|
78 |
-
*
|
79 |
-
* @return void
|
80 |
-
*/
|
81 |
-
public function get_og_data() {
|
82 |
-
$this->og_title = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_og_title', true ) );
|
83 |
-
$this->og_description = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_og_description', true ) );
|
84 |
-
$this->og_image = $this->get_image_url();
|
85 |
-
$this->twitter_title = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_custom_tweet', true ) );
|
86 |
-
$this->twitter_creator = $this->get_twitter_creator();
|
87 |
-
$this->twitter_site = mashsb_get_twitter_username();
|
88 |
-
}
|
89 |
-
|
90 |
-
public function sanitize_data($string){
|
91 |
-
//return $string;
|
92 |
-
return htmlspecialchars(preg_replace( "/\r|\n/", " ", $string ));
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Get open graph add-on data
|
97 |
-
*
|
98 |
-
* @deprecated
|
99 |
-
* @return void
|
100 |
-
*/
|
101 |
-
/* public function get_og_add_on_data() {
|
102 |
-
$this->addon_og_title = htmlspecialchars( get_post_meta( $this->postID, '_og_title', true ) );
|
103 |
-
$this->addon_og_description = htmlspecialchars( get_post_meta( $this->postID, '_og_description', true ) );
|
104 |
-
$this->addon_twitter_title = htmlspecialchars( get_post_meta( $this->postID, 'mashog_tw_title', true ) );
|
105 |
-
} */
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Get Yoast open graph and social data
|
109 |
-
*
|
110 |
-
* @global array $wpseo_og WP SEO (Yoast open graph) settings
|
111 |
-
* @return void
|
112 |
-
*/
|
113 |
-
public function get_yoast_data() {
|
114 |
-
if( !defined( 'WPSEO_VERSION' ) ) {
|
115 |
-
return;
|
116 |
-
}
|
117 |
-
|
118 |
-
global $wpseo_og;
|
119 |
-
if( has_action( 'wpseo_head', array($wpseo_og, 'opengraph') ) ) {
|
120 |
-
// Yoast open graph tags
|
121 |
-
$this->yoast_og_title = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-title', true );
|
122 |
-
$this->yoast_og_description = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-description', true );
|
123 |
-
$this->yoast_og_image = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-image', true );
|
124 |
-
|
125 |
-
// Yoast twitter card data
|
126 |
-
$this->yoast_twitter_title = get_post_meta( $this->postID, '_yoast_wpseo_twitter-title', true );
|
127 |
-
$this->yoast_twitter_description = get_post_meta( $this->postID, '_yoast_wpseo_twitter-description', true );
|
128 |
-
$this->yoast_twitter_image = get_post_meta( $this->postID, '_yoast_wpseo_twitter-image', true );
|
129 |
-
|
130 |
-
// Yoast SEO title and description
|
131 |
-
$this->yoast_seo_title = get_post_meta( $this->postID, '_yoast_wpseo_title', true );
|
132 |
-
$this->yoast_seo_description = get_post_meta( $this->postID, '_yoast_wpseo_metadesc', true );
|
133 |
-
|
134 |
-
// Remove Yoast open graph and twitter cards data from head of site
|
135 |
-
if( $this->is_open_graph() ) {
|
136 |
-
remove_action( 'wpseo_head', array($wpseo_og, 'opengraph'), 30 );
|
137 |
-
}
|
138 |
-
|
139 |
-
if( $this->is_twitter_card() ) {
|
140 |
-
remove_action( 'wpseo_head', array('WPSEO_Twitter', 'get_instance'), 40 );
|
141 |
-
}
|
142 |
-
|
143 |
-
// Get Yoast social settings
|
144 |
-
$this->yoast = get_option( 'wpseo_social' );
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Remove Jetpack Open Graph tags
|
150 |
-
*
|
151 |
-
* @return void
|
152 |
-
*/
|
153 |
-
public function remove_jetpack_og() {
|
154 |
-
if( class_exists( 'JetPack' ) && $this->is_open_graph() ) {
|
155 |
-
add_filter( 'jetpack_enable_opengraph', '__return_false', 99 );
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Get the title
|
161 |
-
*
|
162 |
-
* @return string
|
163 |
-
*/
|
164 |
-
public function get_title() {
|
165 |
-
return mashsb_get_document_title();
|
166 |
-
//return $this->replace_quote_characters( htmlspecialchars_decode( mashsb_get_document_title() ) );
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Get the og title
|
171 |
-
*
|
172 |
-
* @return string
|
173 |
-
*/
|
174 |
-
public function get_og_title() {
|
175 |
-
|
176 |
-
if( !empty( $this->og_title ) ) {
|
177 |
-
return $this->og_title;
|
178 |
-
}
|
179 |
-
if( defined( 'WPSEO_VERSION' ) ) {
|
180 |
-
if( !empty( $this->yoast_og_title ) ) {
|
181 |
-
return $this->yoast_og_title;
|
182 |
-
}
|
183 |
-
if( !empty( $this->yoast_seo_title ) ) {
|
184 |
-
return $this->yoast_seo_title;
|
185 |
-
}
|
186 |
-
}
|
187 |
-
// Default return value
|
188 |
-
return $this->post_title;
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Get the og description
|
193 |
-
*
|
194 |
-
* @return string
|
195 |
-
*/
|
196 |
-
public function get_og_description() {
|
197 |
-
|
198 |
-
if( !empty( $this->og_description ) ) {
|
199 |
-
return $this->og_description;
|
200 |
-
}
|
201 |
-
|
202 |
-
if( defined( 'WPSEO_VERSION' ) ) {
|
203 |
-
if( !empty( $this->yoast_og_description ) ) {
|
204 |
-
return $this->yoast_og_description;
|
205 |
-
}
|
206 |
-
}
|
207 |
-
// Default return value
|
208 |
-
return $this->post_description;
|
209 |
-
}
|
210 |
-
|
211 |
-
/**
|
212 |
-
* Get the excerpt
|
213 |
-
*
|
214 |
-
* @param int $post_id
|
215 |
-
* @since 2.5.9
|
216 |
-
* @return string
|
217 |
-
*/
|
218 |
-
function get_excerpt_by_id( $post_id ) {
|
219 |
-
// Check if the post has an excerpt
|
220 |
-
if( has_excerpt() ) {
|
221 |
-
$excerpt_length = apply_filters( 'excerpt_length', 35 );
|
222 |
-
return trim( get_the_excerpt() );
|
223 |
-
}
|
224 |
-
|
225 |
-
$the_post = get_post( $post_id ); //Gets post ID
|
226 |
-
$the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt
|
227 |
-
$excerpt_length = 35; //Sets excerpt length by words
|
228 |
-
$the_excerpt = strip_tags( strip_shortcodes( $the_excerpt ) ); //Strips tags and images
|
229 |
-
$words = explode( ' ', $the_excerpt, $excerpt_length + 1 );
|
230 |
-
if( count( $words ) > $excerpt_length ) {
|
231 |
-
array_pop( $words );
|
232 |
-
$the_excerpt = implode( ' ', $words );
|
233 |
-
}
|
234 |
-
|
235 |
-
return trim( wp_strip_all_tags( $the_excerpt ) );
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Get the og image
|
240 |
-
*
|
241 |
-
* @return string
|
242 |
-
*/
|
243 |
-
public function get_og_image() {
|
244 |
-
if( !empty( $this->og_image ) ) {
|
245 |
-
return $this->og_image;
|
246 |
-
}
|
247 |
-
|
248 |
-
if( defined( 'WPSEO_VERSION' ) ) {
|
249 |
-
if( !empty( $this->yoast_og_image ) ) {
|
250 |
-
return $this->yoast_og_image;
|
251 |
-
}
|
252 |
-
}
|
253 |
-
return $this->post_featured_image;
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Get image size
|
258 |
-
*
|
259 |
-
* @param string image id
|
260 |
-
* @return mixed array|bool array[0] = width, array[1] = height | false no result
|
261 |
-
*/
|
262 |
-
public function get_og_image_size() {
|
263 |
-
$og_image = $this->get_og_image();
|
264 |
-
if( empty( $og_image ) ) {
|
265 |
-
return;
|
266 |
-
}
|
267 |
-
|
268 |
-
$upload_dir = wp_upload_dir();
|
269 |
-
$img_src = str_replace( $upload_dir['baseurl'], $upload_dir['basedir'], $this->get_og_image() );
|
270 |
-
$imagesize = getimagesize( $img_src );
|
271 |
-
if(!empty($imagesize)){
|
272 |
-
return $imagesize;
|
273 |
-
}
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Get the twitter image
|
278 |
-
*
|
279 |
-
* @return string
|
280 |
-
*/
|
281 |
-
public function get_twitter_image() {
|
282 |
-
if( !empty( $this->twitter_image ) ) {
|
283 |
-
return $this->twitter_image;
|
284 |
-
}
|
285 |
-
|
286 |
-
if( defined( 'WPSEO_VERSION' ) ) {
|
287 |
-
if( !empty( $this->yoast_twitter_image ) ) {
|
288 |
-
return $this->yoast_twitter_image;
|
289 |
-
}
|
290 |
-
}
|
291 |
-
return $this->post_featured_image;
|
292 |
-
}
|
293 |
-
|
294 |
-
/**
|
295 |
-
* Get the feature image
|
296 |
-
*
|
297 |
-
* @return mixed string | boolean false on failure or no featured image available
|
298 |
-
*/
|
299 |
-
public function get_featured_image() {
|
300 |
-
// Return post thumbnail
|
301 |
-
// rawurlencode() Must be tested for images with non lating characters
|
302 |
-
//return rawurlencode( wp_get_attachment_url( get_post_thumbnail_id( $this->postID ) ) );
|
303 |
-
return wp_get_attachment_url( get_post_thumbnail_id( $this->postID ) );
|
304 |
-
}
|
305 |
-
|
306 |
-
/**
|
307 |
-
* Get custom open graph image url from mashsb og settings
|
308 |
-
*
|
309 |
-
* @return string
|
310 |
-
*/
|
311 |
-
public function get_image_url() {
|
312 |
-
$og_image = get_post_meta( $this->postID, 'mashsb_og_image', true );
|
313 |
-
if( $og_image ) {
|
314 |
-
//return rawurlencode( wp_get_attachment_url( $og_image ) );
|
315 |
-
return wp_get_attachment_url( $og_image );
|
316 |
-
}
|
317 |
-
}
|
318 |
-
|
319 |
-
/**
|
320 |
-
* Get Pinterst image url from mashsb meta box settings
|
321 |
-
*
|
322 |
-
* @return string
|
323 |
-
*/
|
324 |
-
public function get_pinterest_image_url() {
|
325 |
-
$image = get_post_meta( $this->postID, 'mashsb_pinterest_image', true );
|
326 |
-
if( $image ) {
|
327 |
-
//return rawurlencode( wp_get_attachment_url( $og_image ) );
|
328 |
-
return wp_get_attachment_url( $image );
|
329 |
-
}
|
330 |
-
|
331 |
-
$og_image = get_post_meta( $this->postID, 'mashsb_og_image', true );
|
332 |
-
if( $og_image ) {
|
333 |
-
//return rawurlencode( wp_get_attachment_url( $og_image ) );
|
334 |
-
return wp_get_attachment_url( $og_image );
|
335 |
-
}
|
336 |
-
|
337 |
-
return $this->post_featured_image;
|
338 |
-
}
|
339 |
-
|
340 |
-
/**
|
341 |
-
* Get pinterest description
|
342 |
-
*
|
343 |
-
* @return string
|
344 |
-
*/
|
345 |
-
public function get_pinterest_description() {
|
346 |
-
$desc = get_post_meta( $this->postID, 'mashsb_pinterest_description', true );
|
347 |
-
if( !empty( $desc ) ) {
|
348 |
-
return $desc;
|
349 |
-
}
|
350 |
-
|
351 |
-
if( !empty( $this->og_description ) ) {
|
352 |
-
return $this->og_description;
|
353 |
-
}
|
354 |
-
|
355 |
-
// Default return value
|
356 |
-
return $this->post_description;
|
357 |
-
}
|
358 |
-
|
359 |
-
/**
|
360 |
-
* Get the facebook author url
|
361 |
-
*
|
362 |
-
* @return string
|
363 |
-
*/
|
364 |
-
public function get_fb_author_url() {
|
365 |
-
// MASHSB facebook author url
|
366 |
-
if( get_the_author_meta( 'mashsb_fb_author', $this->get_post_author( $this->postID ) ) ) {
|
367 |
-
return get_the_author_meta( 'mashsb_fb_author', $this->get_post_author( $this->postID ) );
|
368 |
-
}
|
369 |
-
// Yoast facebook author url
|
370 |
-
if( get_the_author_meta( 'facebook', $this->get_post_author( $this->postID ) ) && defined( 'WPSEO_VERSION' ) ) {
|
371 |
-
return get_the_author_meta( 'facebook', $this->get_post_author( $this->postID ) );
|
372 |
-
}
|
373 |
-
}
|
374 |
-
|
375 |
-
/**
|
376 |
-
* Get the twitter creator tag site:creator
|
377 |
-
*
|
378 |
-
* @return string
|
379 |
-
*/
|
380 |
-
public function get_twitter_creator() {
|
381 |
-
// MASHSB facebook author url
|
382 |
-
$twitter_handle = get_the_author_meta( 'mashsb_twitter_handle', $this->get_post_author( $this->postID ) );
|
383 |
-
if( $twitter_handle ) {
|
384 |
-
return $twitter_handle;
|
385 |
-
}
|
386 |
-
// Yoast facebook author url
|
387 |
-
$yoast_twitter_handle = get_the_author_meta( 'twitter', $this->get_post_author( $this->postID ) );
|
388 |
-
if( $yoast_twitter_handle ) {
|
389 |
-
return $yoast_twitter_handle;
|
390 |
-
}
|
391 |
-
}
|
392 |
-
|
393 |
-
/**
|
394 |
-
* Get facebook publisher url
|
395 |
-
*
|
396 |
-
* @global array $mashsb_options
|
397 |
-
* @return string
|
398 |
-
*/
|
399 |
-
public function get_fb_publisher_url() {
|
400 |
-
global $mashsb_options;
|
401 |
-
if( !empty( $mashsb_options['fb_publisher_url'] ) ) {
|
402 |
-
return $mashsb_options['fb_publisher_url'];
|
403 |
-
}
|
404 |
-
if( !empty( $this->yoast['facebook_site'] ) ) {
|
405 |
-
return $this->yoast['facebook_site'];
|
406 |
-
}
|
407 |
-
}
|
408 |
-
|
409 |
-
/**
|
410 |
-
* Get facebook app id
|
411 |
-
*
|
412 |
-
* @global array $mashsb_options
|
413 |
-
* @return string
|
414 |
-
*/
|
415 |
-
public function get_fb_app_id() {
|
416 |
-
global $mashsb_options;
|
417 |
-
if( !empty( $mashsb_options['fb_app_id'] ) ) {
|
418 |
-
return $mashsb_options['fb_app_id'];
|
419 |
-
}
|
420 |
-
if( !empty( $this->yoast ) && !empty( $this->yoast['fbadminapp'] ) ) {
|
421 |
-
return $this->yoast['fbadminapp'];
|
422 |
-
}
|
423 |
-
return false;
|
424 |
-
}
|
425 |
-
|
426 |
-
/**
|
427 |
-
* Get the post author
|
428 |
-
*
|
429 |
-
* @param int $post_id
|
430 |
-
* @return string
|
431 |
-
*/
|
432 |
-
public function get_post_author( $post_id = 0 ) {
|
433 |
-
$post = get_post( $post_id );
|
434 |
-
return $post->post_author;
|
435 |
-
}
|
436 |
-
|
437 |
-
/**
|
438 |
-
* Get twitter title
|
439 |
-
*
|
440 |
-
* @return string
|
441 |
-
*/
|
442 |
-
public function get_twitter_title() {
|
443 |
-
if( !empty( $this->twitter_title ) ) {
|
444 |
-
return $this->twitter_title;
|
445 |
-
}
|
446 |
-
|
447 |
-
if( defined( 'WPSEO_VERSION' ) ) {
|
448 |
-
if( !empty( $this->yoast_twitter_title ) ) {
|
449 |
-
return $this->yoast_twitter_title;
|
450 |
-
}
|
451 |
-
if( !empty( $this->yoast_seo_title ) ) {
|
452 |
-
return $this->yoast_seo_title;
|
453 |
-
}
|
454 |
-
}
|
455 |
-
// Default return value
|
456 |
-
return $this->post_title;
|
457 |
-
}
|
458 |
-
|
459 |
-
/**
|
460 |
-
* Get twitter description
|
461 |
-
*
|
462 |
-
* @return string
|
463 |
-
*/
|
464 |
-
public function get_twitter_description() {
|
465 |
-
if( defined( 'WPSEO_VERSION' ) ) {
|
466 |
-
if( !empty( $this->yoast_twitter_description ) ) {
|
467 |
-
return $this->yoast_twitter_description;
|
468 |
-
}
|
469 |
-
}
|
470 |
-
// Default return value
|
471 |
-
return $this->post_description;
|
472 |
-
}
|
473 |
-
|
474 |
-
/**
|
475 |
-
* Remove Simple Podcast Press open graph tags
|
476 |
-
*
|
477 |
-
* @global array $ob_wp_simplepodcastpress
|
478 |
-
*/
|
479 |
-
public function remove_simple_podcast_press_og() {
|
480 |
-
if(!$this->is_open_graph()){
|
481 |
-
return;
|
482 |
-
}
|
483 |
-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
484 |
-
if( is_plugin_active( 'simple-podcast-press/simple-podcast-press.php' ) ) {
|
485 |
-
global $ob_wp_simplepodcastpress;
|
486 |
-
remove_action( 'wp_head', array($ob_wp_simplepodcastpress, 'spp_open_graph'), 1 );
|
487 |
-
}
|
488 |
-
}
|
489 |
-
|
490 |
-
/**
|
491 |
-
* Return special quote characters
|
492 |
-
*
|
493 |
-
* @param string $
|
494 |
-
* @todo write a test
|
495 |
-
* @return string
|
496 |
-
*/
|
497 |
-
public function replace_quote_characters( $string ) {
|
498 |
-
$string = str_replace( '"', '\'', $string );
|
499 |
-
$string = str_replace( '‘', '\'', $string );
|
500 |
-
$string = str_replace( '’', '\'', $string );
|
501 |
-
$string = str_replace( '“', '\'', $string );
|
502 |
-
$string = str_replace( '”', '\'', $string );
|
503 |
-
return $string;
|
504 |
-
}
|
505 |
-
|
506 |
-
/**
|
507 |
-
* Check if twitter card is enabled
|
508 |
-
*
|
509 |
-
* @global array $mashsb_options
|
510 |
-
* @return boolean
|
511 |
-
*/
|
512 |
-
public function is_twitter_card() {
|
513 |
-
global $mashsb_options;
|
514 |
-
if( isset( $mashsb_options['twitter_card'] ) ) {
|
515 |
-
return true;
|
516 |
-
}
|
517 |
-
}
|
518 |
-
|
519 |
-
/**
|
520 |
-
* Check if mashshare open graph meta tags are enabled
|
521 |
-
*
|
522 |
-
* @global array $mashsb_options
|
523 |
-
* @return boolean
|
524 |
-
*/
|
525 |
-
public function is_open_graph() {
|
526 |
-
global $mashsb_options;
|
527 |
-
if( isset( $mashsb_options['open_graph'] ) ) {
|
528 |
-
return true;
|
529 |
-
}
|
530 |
-
}
|
531 |
-
|
532 |
-
/**
|
533 |
-
* Render Open Graph Meta Output
|
534 |
-
*
|
535 |
-
* @return string HTML
|
536 |
-
*/
|
537 |
-
public function render_open_graph_meta() {
|
538 |
-
|
539 |
-
if( !$this->is_open_graph() ) {
|
540 |
-
$html = '';
|
541 |
-
return $html;
|
542 |
-
}
|
543 |
-
|
544 |
-
$opengraph = PHP_EOL . '<!-- Open Graph Meta Tags generated by MashShare ' . MASHSB_VERSION . ' - https://mashshare.net -->';
|
545 |
-
$opengraph .= PHP_EOL . '<meta property="og:type" content="article" /> ';
|
546 |
-
if( $this->get_og_title() ) {
|
547 |
-
$opengraph .= PHP_EOL . '<meta property="og:title" content="' . $this->get_og_title() . '" />';
|
548 |
-
}
|
549 |
-
if( $this->get_og_description() ) {
|
550 |
-
$opengraph .= PHP_EOL . '<meta property="og:description" content="' . $this->get_og_description() . '" />';
|
551 |
-
}
|
552 |
-
if( $this->get_og_image() ) {
|
553 |
-
$opengraph .= PHP_EOL . '<meta property="og:image" content="' . $this->get_og_image() . '" />';
|
554 |
-
}
|
555 |
-
$opengraph .= PHP_EOL . '<meta property="og:url" content="' . get_permalink() . '" />';
|
556 |
-
$opengraph .= PHP_EOL . '<meta property="og:site_name" content="' . get_bloginfo( 'name' ) . '" />';
|
557 |
-
if( $this->get_fb_author_url() ) {
|
558 |
-
$opengraph .= PHP_EOL . '<meta property="article:author" content="' . $this->get_fb_author_url() . '" />';
|
559 |
-
}
|
560 |
-
if( $this->get_fb_publisher_url() ) {
|
561 |
-
$opengraph .= PHP_EOL . '<meta property="article:publisher" content="' . $this->get_fb_publisher_url() . '" />';
|
562 |
-
}
|
563 |
-
if( $this->get_fb_app_id() ) {
|
564 |
-
$opengraph .= PHP_EOL . '<meta property="fb:app_id" content="' . $this->get_fb_app_id() . '" />';
|
565 |
-
}
|
566 |
-
$opengraph .= PHP_EOL . '<meta property="article:published_time" content="' . get_post_time( 'c' ) . '" />';
|
567 |
-
$opengraph .= PHP_EOL . '<meta property="article:modified_time" content="' . get_post_modified_time( 'c' ) . '" />';
|
568 |
-
$opengraph .= PHP_EOL . '<meta property="og:updated_time" content="' . get_post_modified_time( 'c' ) . '" />';
|
569 |
-
$opengraph .= PHP_EOL . '<!-- Open Graph Meta Tags generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->';
|
570 |
-
|
571 |
-
return $opengraph;
|
572 |
-
}
|
573 |
-
|
574 |
-
/**
|
575 |
-
* Render Twitter Card Meta Output
|
576 |
-
*
|
577 |
-
* @return string HTML
|
578 |
-
*/
|
579 |
-
public function render_twitter_card_meta() {
|
580 |
-
|
581 |
-
if( !$this->is_twitter_card() ) {
|
582 |
-
$html = '';
|
583 |
-
return $html;
|
584 |
-
}
|
585 |
-
|
586 |
-
$twittercard = PHP_EOL . '<!-- Twitter Card generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->';
|
587 |
-
|
588 |
-
$imagesize = $this->get_og_image_size();
|
589 |
-
if( is_array( $imagesize ) && isset($imagesize[0]) && isset($imagesize[1]) ) {
|
590 |
-
$twittercard .= PHP_EOL . '<meta property="og:image:width" content="' . $imagesize[0] . '" />';
|
591 |
-
$twittercard .= PHP_EOL . '<meta property="og:image:height" content="' . $imagesize[1] . '" />';
|
592 |
-
}
|
593 |
-
// Large Summary Twitter Card
|
594 |
-
if( $this->get_twitter_image() ) {
|
595 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:card" content="summary_large_image">';
|
596 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:title" content="' . $this->get_twitter_title() . '">';
|
597 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:description" content="' . $this->get_twitter_description() . '">';
|
598 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:image" content="' . $this->get_twitter_image() . '">';
|
599 |
-
if( !empty( $this->twitter_site ) ) {
|
600 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:site" content="@' . $this->twitter_site . '">';
|
601 |
-
}
|
602 |
-
if( !empty( $this->twitter_creator ) ) {
|
603 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:creator" content="@' . str_replace( '@', '', $this->twitter_creator ) . '">';
|
604 |
-
}
|
605 |
-
|
606 |
-
// Small Summary Twitter Cards
|
607 |
-
} else {
|
608 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:card" content="summary">';
|
609 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:title" content="' . $this->get_twitter_title() . '">';
|
610 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:description" content="' . $this->get_twitter_description() . '">';
|
611 |
-
if( !empty( $this->twitter_site ) ) {
|
612 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:site" content="@' . $this->twitter_site . '">';
|
613 |
-
}
|
614 |
-
if( !empty( $this->twitter_creator ) ) {
|
615 |
-
$twittercard .= PHP_EOL . '<meta name="twitter:creator" content="@' . str_replace( '@', '', $this->twitter_creator ) . '">';
|
616 |
-
}
|
617 |
-
}
|
618 |
-
$twittercard .= PHP_EOL . '<!-- Twitter Card generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->' . PHP_EOL . PHP_EOL;
|
619 |
-
return $twittercard;
|
620 |
-
}
|
621 |
-
|
622 |
-
/**
|
623 |
-
* Render Meta Output
|
624 |
-
*
|
625 |
-
* @return string HTML
|
626 |
-
*/
|
627 |
-
public function render_header_meta() {
|
628 |
-
//echo apply_filters( 'mashsb_meta_tags', $html );
|
629 |
-
echo apply_filters( 'mashsb_opengraph_meta', $this->render_open_graph_meta() );
|
630 |
-
echo apply_filters( 'mashsb_twittercard_meta', $this->render_twitter_card_meta() );
|
631 |
-
}
|
632 |
-
|
633 |
-
}
|
634 |
-
|
635 |
-
// end class
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Init - Execute only once
|
639 |
-
*
|
640 |
-
* @global MASHSB_HEADER_META_TAGS $mashsb_meta_tags
|
641 |
-
* @return object
|
642 |
-
*/
|
643 |
-
function mashsb_meta_tags_init() {
|
644 |
-
global $mashsb_meta_tags;
|
645 |
-
|
646 |
-
if( !is_null( $mashsb_meta_tags ) ) {
|
647 |
-
return $mashsb_meta_tags;
|
648 |
-
}
|
649 |
-
|
650 |
-
$mashsb_meta_tags = new MASHSB_HEADER_META_TAGS();
|
651 |
-
return $mashsb_meta_tags;
|
652 |
-
}
|
653 |
-
|
654 |
-
add_action( 'wp_head', 'mashsb_meta_tags_init', 1 );
|
655 |
-
|
656 |
-
// Remove Social Warfare tags open graph tags (Soory Social Warfare guys - You do a great job)
|
657 |
-
add_filter( 'sw_meta_tags', '__return_false', 99 );
|
658 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if( !defined( 'ABSPATH' ) )
|
5 |
+
exit;
|
6 |
+
|
7 |
+
/*
|
8 |
+
* Create twitter card and open graph tags
|
9 |
+
*/
|
10 |
+
|
11 |
+
class MASHSB_HEADER_META_TAGS {
|
12 |
+
|
13 |
+
protected $postID = 0;
|
14 |
+
protected $imageURL;
|
15 |
+
protected $post_title;
|
16 |
+
protected $post_featured_image;
|
17 |
+
protected $post_description;
|
18 |
+
protected $og_title = '';
|
19 |
+
protected $og_description;
|
20 |
+
protected $og_image;
|
21 |
+
protected $fb_author_url;
|
22 |
+
protected $fb_app_id;
|
23 |
+
protected $twitter_title;
|
24 |
+
protected $twitter_description;
|
25 |
+
protected $twitter_image;
|
26 |
+
protected $twitter_site;
|
27 |
+
protected $twitter_creator;
|
28 |
+
protected $pinterest_description;
|
29 |
+
protected $pinterest_image;
|
30 |
+
// Yoast Data
|
31 |
+
protected $yoast_og_title;
|
32 |
+
protected $yoast_og_description;
|
33 |
+
protected $yoast_og_image;
|
34 |
+
protected $yoast_seo_title;
|
35 |
+
protected $yoast_seo_description;
|
36 |
+
protected $yoast_twitter_title;
|
37 |
+
protected $yoast_twitter_description;
|
38 |
+
protected $yoast_twitter_image;
|
39 |
+
protected $yoast_twitter_creator;
|
40 |
+
// yoast social settings
|
41 |
+
protected $yoast = array();
|
42 |
+
|
43 |
+
// open-graph add-on data - outdated - only for compatibility
|
44 |
+
//protected $addon_og_title;
|
45 |
+
//protected $addon_og_description;
|
46 |
+
//protected $addon_twitter_title;
|
47 |
+
|
48 |
+
public function __construct() {
|
49 |
+
global $post;
|
50 |
+
|
51 |
+
// Die when $post is not set
|
52 |
+
if( !get_the_ID() ) {
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
// Create Open Graph tags only on singular pages and frontpage
|
56 |
+
if( !is_singular() ) {
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
$this->postID = get_the_ID();
|
61 |
+
$this->post_title = $this->get_title();
|
62 |
+
$this->post_featured_image = $this->get_featured_image();
|
63 |
+
$this->post_description = $this->sanitize_data( $this->get_excerpt_by_id( $this->postID ) );
|
64 |
+
$this->pinterest_image = $this->get_pinterest_image_url();
|
65 |
+
$this->pinterest_description = $this->get_pinterest_description();
|
66 |
+
|
67 |
+
$this->get_og_data();
|
68 |
+
// We do not want to support the old stuff so let's disable this. Hopefully no one demands it!
|
69 |
+
//$this->get_og_add_on_data();
|
70 |
+
$this->remove_jetpack_og();
|
71 |
+
$this->remove_simple_podcast_press_og();
|
72 |
+
$this->get_yoast_data();
|
73 |
+
$this->render_header_meta();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Get relevant main open graph, twitter and pinterest data and use it for later functions
|
78 |
+
*
|
79 |
+
* @return void
|
80 |
+
*/
|
81 |
+
public function get_og_data() {
|
82 |
+
$this->og_title = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_og_title', true ) );
|
83 |
+
$this->og_description = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_og_description', true ) );
|
84 |
+
$this->og_image = $this->get_image_url();
|
85 |
+
$this->twitter_title = $this->sanitize_data( get_post_meta( $this->postID, 'mashsb_custom_tweet', true ) );
|
86 |
+
$this->twitter_creator = $this->get_twitter_creator();
|
87 |
+
$this->twitter_site = mashsb_get_twitter_username();
|
88 |
+
}
|
89 |
+
|
90 |
+
public function sanitize_data($string){
|
91 |
+
//return $string;
|
92 |
+
return htmlspecialchars(preg_replace( "/\r|\n/", " ", $string ));
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Get open graph add-on data
|
97 |
+
*
|
98 |
+
* @deprecated
|
99 |
+
* @return void
|
100 |
+
*/
|
101 |
+
/* public function get_og_add_on_data() {
|
102 |
+
$this->addon_og_title = htmlspecialchars( get_post_meta( $this->postID, '_og_title', true ) );
|
103 |
+
$this->addon_og_description = htmlspecialchars( get_post_meta( $this->postID, '_og_description', true ) );
|
104 |
+
$this->addon_twitter_title = htmlspecialchars( get_post_meta( $this->postID, 'mashog_tw_title', true ) );
|
105 |
+
} */
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get Yoast open graph and social data
|
109 |
+
*
|
110 |
+
* @global array $wpseo_og WP SEO (Yoast open graph) settings
|
111 |
+
* @return void
|
112 |
+
*/
|
113 |
+
public function get_yoast_data() {
|
114 |
+
if( !defined( 'WPSEO_VERSION' ) ) {
|
115 |
+
return;
|
116 |
+
}
|
117 |
+
|
118 |
+
global $wpseo_og;
|
119 |
+
if( has_action( 'wpseo_head', array($wpseo_og, 'opengraph') ) ) {
|
120 |
+
// Yoast open graph tags
|
121 |
+
$this->yoast_og_title = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-title', true );
|
122 |
+
$this->yoast_og_description = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-description', true );
|
123 |
+
$this->yoast_og_image = get_post_meta( $this->postID, '_yoast_wpseo_opengraph-image', true );
|
124 |
+
|
125 |
+
// Yoast twitter card data
|
126 |
+
$this->yoast_twitter_title = get_post_meta( $this->postID, '_yoast_wpseo_twitter-title', true );
|
127 |
+
$this->yoast_twitter_description = get_post_meta( $this->postID, '_yoast_wpseo_twitter-description', true );
|
128 |
+
$this->yoast_twitter_image = get_post_meta( $this->postID, '_yoast_wpseo_twitter-image', true );
|
129 |
+
|
130 |
+
// Yoast SEO title and description
|
131 |
+
$this->yoast_seo_title = get_post_meta( $this->postID, '_yoast_wpseo_title', true );
|
132 |
+
$this->yoast_seo_description = get_post_meta( $this->postID, '_yoast_wpseo_metadesc', true );
|
133 |
+
|
134 |
+
// Remove Yoast open graph and twitter cards data from head of site
|
135 |
+
if( $this->is_open_graph() ) {
|
136 |
+
remove_action( 'wpseo_head', array($wpseo_og, 'opengraph'), 30 );
|
137 |
+
}
|
138 |
+
|
139 |
+
if( $this->is_twitter_card() ) {
|
140 |
+
remove_action( 'wpseo_head', array('WPSEO_Twitter', 'get_instance'), 40 );
|
141 |
+
}
|
142 |
+
|
143 |
+
// Get Yoast social settings
|
144 |
+
$this->yoast = get_option( 'wpseo_social' );
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Remove Jetpack Open Graph tags
|
150 |
+
*
|
151 |
+
* @return void
|
152 |
+
*/
|
153 |
+
public function remove_jetpack_og() {
|
154 |
+
if( class_exists( 'JetPack' ) && $this->is_open_graph() ) {
|
155 |
+
add_filter( 'jetpack_enable_opengraph', '__return_false', 99 );
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Get the title
|
161 |
+
*
|
162 |
+
* @return string
|
163 |
+
*/
|
164 |
+
public function get_title() {
|
165 |
+
return mashsb_get_document_title();
|
166 |
+
//return $this->replace_quote_characters( htmlspecialchars_decode( mashsb_get_document_title() ) );
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Get the og title
|
171 |
+
*
|
172 |
+
* @return string
|
173 |
+
*/
|
174 |
+
public function get_og_title() {
|
175 |
+
|
176 |
+
if( !empty( $this->og_title ) ) {
|
177 |
+
return $this->og_title;
|
178 |
+
}
|
179 |
+
if( defined( 'WPSEO_VERSION' ) ) {
|
180 |
+
if( !empty( $this->yoast_og_title ) ) {
|
181 |
+
return $this->yoast_og_title;
|
182 |
+
}
|
183 |
+
if( !empty( $this->yoast_seo_title ) ) {
|
184 |
+
return $this->yoast_seo_title;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
// Default return value
|
188 |
+
return $this->post_title;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Get the og description
|
193 |
+
*
|
194 |
+
* @return string
|
195 |
+
*/
|
196 |
+
public function get_og_description() {
|
197 |
+
|
198 |
+
if( !empty( $this->og_description ) ) {
|
199 |
+
return $this->og_description;
|
200 |
+
}
|
201 |
+
|
202 |
+
if( defined( 'WPSEO_VERSION' ) ) {
|
203 |
+
if( !empty( $this->yoast_og_description ) ) {
|
204 |
+
return $this->yoast_og_description;
|
205 |
+
}
|
206 |
+
}
|
207 |
+
// Default return value
|
208 |
+
return $this->post_description;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Get the excerpt
|
213 |
+
*
|
214 |
+
* @param int $post_id
|
215 |
+
* @since 2.5.9
|
216 |
+
* @return string
|
217 |
+
*/
|
218 |
+
function get_excerpt_by_id( $post_id ) {
|
219 |
+
// Check if the post has an excerpt
|
220 |
+
if( has_excerpt() ) {
|
221 |
+
$excerpt_length = apply_filters( 'excerpt_length', 35 );
|
222 |
+
return trim( get_the_excerpt() );
|
223 |
+
}
|
224 |
+
|
225 |
+
$the_post = get_post( $post_id ); //Gets post ID
|
226 |
+
$the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt
|
227 |
+
$excerpt_length = 35; //Sets excerpt length by words
|
228 |
+
$the_excerpt = strip_tags( strip_shortcodes( $the_excerpt ) ); //Strips tags and images
|
229 |
+
$words = explode( ' ', $the_excerpt, $excerpt_length + 1 );
|
230 |
+
if( count( $words ) > $excerpt_length ) {
|
231 |
+
array_pop( $words );
|
232 |
+
$the_excerpt = implode( ' ', $words );
|
233 |
+
}
|
234 |
+
|
235 |
+
return trim( wp_strip_all_tags( $the_excerpt ) );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Get the og image
|
240 |
+
*
|
241 |
+
* @return string
|
242 |
+
*/
|
243 |
+
public function get_og_image() {
|
244 |
+
if( !empty( $this->og_image ) ) {
|
245 |
+
return $this->og_image;
|
246 |
+
}
|
247 |
+
|
248 |
+
if( defined( 'WPSEO_VERSION' ) ) {
|
249 |
+
if( !empty( $this->yoast_og_image ) ) {
|
250 |
+
return $this->yoast_og_image;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
return $this->post_featured_image;
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Get image size
|
258 |
+
*
|
259 |
+
* @param string image id
|
260 |
+
* @return mixed array|bool array[0] = width, array[1] = height | false no result
|
261 |
+
*/
|
262 |
+
public function get_og_image_size() {
|
263 |
+
$og_image = $this->get_og_image();
|
264 |
+
if( empty( $og_image ) ) {
|
265 |
+
return;
|
266 |
+
}
|
267 |
+
|
268 |
+
$upload_dir = wp_upload_dir();
|
269 |
+
$img_src = str_replace( $upload_dir['baseurl'], $upload_dir['basedir'], $this->get_og_image() );
|
270 |
+
$imagesize = getimagesize( $img_src );
|
271 |
+
if(!empty($imagesize)){
|
272 |
+
return $imagesize;
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Get the twitter image
|
278 |
+
*
|
279 |
+
* @return string
|
280 |
+
*/
|
281 |
+
public function get_twitter_image() {
|
282 |
+
if( !empty( $this->twitter_image ) ) {
|
283 |
+
return $this->twitter_image;
|
284 |
+
}
|
285 |
+
|
286 |
+
if( defined( 'WPSEO_VERSION' ) ) {
|
287 |
+
if( !empty( $this->yoast_twitter_image ) ) {
|
288 |
+
return $this->yoast_twitter_image;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
return $this->post_featured_image;
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* Get the feature image
|
296 |
+
*
|
297 |
+
* @return mixed string | boolean false on failure or no featured image available
|
298 |
+
*/
|
299 |
+
public function get_featured_image() {
|
300 |
+
// Return post thumbnail
|
301 |
+
// rawurlencode() Must be tested for images with non lating characters
|
302 |
+
//return rawurlencode( wp_get_attachment_url( get_post_thumbnail_id( $this->postID ) ) );
|
303 |
+
return wp_get_attachment_url( get_post_thumbnail_id( $this->postID ) );
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Get custom open graph image url from mashsb og settings
|
308 |
+
*
|
309 |
+
* @return string
|
310 |
+
*/
|
311 |
+
public function get_image_url() {
|
312 |
+
$og_image = get_post_meta( $this->postID, 'mashsb_og_image', true );
|
313 |
+
if( $og_image ) {
|
314 |
+
//return rawurlencode( wp_get_attachment_url( $og_image ) );
|
315 |
+
return wp_get_attachment_url( $og_image );
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Get Pinterst image url from mashsb meta box settings
|
321 |
+
*
|
322 |
+
* @return string
|
323 |
+
*/
|
324 |
+
public function get_pinterest_image_url() {
|
325 |
+
$image = get_post_meta( $this->postID, 'mashsb_pinterest_image', true );
|
326 |
+
if( $image ) {
|
327 |
+
//return rawurlencode( wp_get_attachment_url( $og_image ) );
|
328 |
+
return wp_get_attachment_url( $image );
|
329 |
+
}
|
330 |
+
|
331 |
+
$og_image = get_post_meta( $this->postID, 'mashsb_og_image', true );
|
332 |
+
if( $og_image ) {
|
333 |
+
//return rawurlencode( wp_get_attachment_url( $og_image ) );
|
334 |
+
return wp_get_attachment_url( $og_image );
|
335 |
+
}
|
336 |
+
|
337 |
+
return $this->post_featured_image;
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Get pinterest description
|
342 |
+
*
|
343 |
+
* @return string
|
344 |
+
*/
|
345 |
+
public function get_pinterest_description() {
|
346 |
+
$desc = get_post_meta( $this->postID, 'mashsb_pinterest_description', true );
|
347 |
+
if( !empty( $desc ) ) {
|
348 |
+
return $desc;
|
349 |
+
}
|
350 |
+
|
351 |
+
if( !empty( $this->og_description ) ) {
|
352 |
+
return $this->og_description;
|
353 |
+
}
|
354 |
+
|
355 |
+
// Default return value
|
356 |
+
return $this->post_description;
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Get the facebook author url
|
361 |
+
*
|
362 |
+
* @return string
|
363 |
+
*/
|
364 |
+
public function get_fb_author_url() {
|
365 |
+
// MASHSB facebook author url
|
366 |
+
if( get_the_author_meta( 'mashsb_fb_author', $this->get_post_author( $this->postID ) ) ) {
|
367 |
+
return get_the_author_meta( 'mashsb_fb_author', $this->get_post_author( $this->postID ) );
|
368 |
+
}
|
369 |
+
// Yoast facebook author url
|
370 |
+
if( get_the_author_meta( 'facebook', $this->get_post_author( $this->postID ) ) && defined( 'WPSEO_VERSION' ) ) {
|
371 |
+
return get_the_author_meta( 'facebook', $this->get_post_author( $this->postID ) );
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Get the twitter creator tag site:creator
|
377 |
+
*
|
378 |
+
* @return string
|
379 |
+
*/
|
380 |
+
public function get_twitter_creator() {
|
381 |
+
// MASHSB facebook author url
|
382 |
+
$twitter_handle = get_the_author_meta( 'mashsb_twitter_handle', $this->get_post_author( $this->postID ) );
|
383 |
+
if( $twitter_handle ) {
|
384 |
+
return $twitter_handle;
|
385 |
+
}
|
386 |
+
// Yoast facebook author url
|
387 |
+
$yoast_twitter_handle = get_the_author_meta( 'twitter', $this->get_post_author( $this->postID ) );
|
388 |
+
if( $yoast_twitter_handle ) {
|
389 |
+
return $yoast_twitter_handle;
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Get facebook publisher url
|
395 |
+
*
|
396 |
+
* @global array $mashsb_options
|
397 |
+
* @return string
|
398 |
+
*/
|
399 |
+
public function get_fb_publisher_url() {
|
400 |
+
global $mashsb_options;
|
401 |
+
if( !empty( $mashsb_options['fb_publisher_url'] ) ) {
|
402 |
+
return $mashsb_options['fb_publisher_url'];
|
403 |
+
}
|
404 |
+
if( !empty( $this->yoast['facebook_site'] ) ) {
|
405 |
+
return $this->yoast['facebook_site'];
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Get facebook app id
|
411 |
+
*
|
412 |
+
* @global array $mashsb_options
|
413 |
+
* @return string
|
414 |
+
*/
|
415 |
+
public function get_fb_app_id() {
|
416 |
+
global $mashsb_options;
|
417 |
+
if( !empty( $mashsb_options['fb_app_id'] ) ) {
|
418 |
+
return $mashsb_options['fb_app_id'];
|
419 |
+
}
|
420 |
+
if( !empty( $this->yoast ) && !empty( $this->yoast['fbadminapp'] ) ) {
|
421 |
+
return $this->yoast['fbadminapp'];
|
422 |
+
}
|
423 |
+
return false;
|
424 |
+
}
|
425 |
+
|
426 |
+
/**
|
427 |
+
* Get the post author
|
428 |
+
*
|
429 |
+
* @param int $post_id
|
430 |
+
* @return string
|
431 |
+
*/
|
432 |
+
public function get_post_author( $post_id = 0 ) {
|
433 |
+
$post = get_post( $post_id );
|
434 |
+
return $post->post_author;
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Get twitter title
|
439 |
+
*
|
440 |
+
* @return string
|
441 |
+
*/
|
442 |
+
public function get_twitter_title() {
|
443 |
+
if( !empty( $this->twitter_title ) ) {
|
444 |
+
return $this->twitter_title;
|
445 |
+
}
|
446 |
+
|
447 |
+
if( defined( 'WPSEO_VERSION' ) ) {
|
448 |
+
if( !empty( $this->yoast_twitter_title ) ) {
|
449 |
+
return $this->yoast_twitter_title;
|
450 |
+
}
|
451 |
+
if( !empty( $this->yoast_seo_title ) ) {
|
452 |
+
return $this->yoast_seo_title;
|
453 |
+
}
|
454 |
+
}
|
455 |
+
// Default return value
|
456 |
+
return $this->post_title;
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* Get twitter description
|
461 |
+
*
|
462 |
+
* @return string
|
463 |
+
*/
|
464 |
+
public function get_twitter_description() {
|
465 |
+
if( defined( 'WPSEO_VERSION' ) ) {
|
466 |
+
if( !empty( $this->yoast_twitter_description ) ) {
|
467 |
+
return $this->yoast_twitter_description;
|
468 |
+
}
|
469 |
+
}
|
470 |
+
// Default return value
|
471 |
+
return $this->post_description;
|
472 |
+
}
|
473 |
+
|
474 |
+
/**
|
475 |
+
* Remove Simple Podcast Press open graph tags
|
476 |
+
*
|
477 |
+
* @global array $ob_wp_simplepodcastpress
|
478 |
+
*/
|
479 |
+
public function remove_simple_podcast_press_og() {
|
480 |
+
if(!$this->is_open_graph()){
|
481 |
+
return;
|
482 |
+
}
|
483 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
484 |
+
if( is_plugin_active( 'simple-podcast-press/simple-podcast-press.php' ) ) {
|
485 |
+
global $ob_wp_simplepodcastpress;
|
486 |
+
remove_action( 'wp_head', array($ob_wp_simplepodcastpress, 'spp_open_graph'), 1 );
|
487 |
+
}
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Return special quote characters
|
492 |
+
*
|
493 |
+
* @param string $string
|
494 |
+
* @todo write a test
|
495 |
+
* @return string
|
496 |
+
*/
|
497 |
+
public function replace_quote_characters( $string ) {
|
498 |
+
$string = str_replace( '"', '\'', $string );
|
499 |
+
$string = str_replace( '‘', '\'', $string );
|
500 |
+
$string = str_replace( '’', '\'', $string );
|
501 |
+
$string = str_replace( '“', '\'', $string );
|
502 |
+
$string = str_replace( '”', '\'', $string );
|
503 |
+
return $string;
|
504 |
+
}
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Check if twitter card is enabled
|
508 |
+
*
|
509 |
+
* @global array $mashsb_options
|
510 |
+
* @return boolean
|
511 |
+
*/
|
512 |
+
public function is_twitter_card() {
|
513 |
+
global $mashsb_options;
|
514 |
+
if( isset( $mashsb_options['twitter_card'] ) ) {
|
515 |
+
return true;
|
516 |
+
}
|
517 |
+
}
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Check if mashshare open graph meta tags are enabled
|
521 |
+
*
|
522 |
+
* @global array $mashsb_options
|
523 |
+
* @return boolean
|
524 |
+
*/
|
525 |
+
public function is_open_graph() {
|
526 |
+
global $mashsb_options;
|
527 |
+
if( isset( $mashsb_options['open_graph'] ) ) {
|
528 |
+
return true;
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* Render Open Graph Meta Output
|
534 |
+
*
|
535 |
+
* @return string HTML
|
536 |
+
*/
|
537 |
+
public function render_open_graph_meta() {
|
538 |
+
|
539 |
+
if( !$this->is_open_graph() ) {
|
540 |
+
$html = '';
|
541 |
+
return $html;
|
542 |
+
}
|
543 |
+
|
544 |
+
$opengraph = PHP_EOL . '<!-- Open Graph Meta Tags generated by MashShare ' . MASHSB_VERSION . ' - https://mashshare.net -->';
|
545 |
+
$opengraph .= PHP_EOL . '<meta property="og:type" content="article" /> ';
|
546 |
+
if( $this->get_og_title() ) {
|
547 |
+
$opengraph .= PHP_EOL . '<meta property="og:title" content="' . $this->get_og_title() . '" />';
|
548 |
+
}
|
549 |
+
if( $this->get_og_description() ) {
|
550 |
+
$opengraph .= PHP_EOL . '<meta property="og:description" content="' . $this->get_og_description() . '" />';
|
551 |
+
}
|
552 |
+
if( $this->get_og_image() ) {
|
553 |
+
$opengraph .= PHP_EOL . '<meta property="og:image" content="' . $this->get_og_image() . '" />';
|
554 |
+
}
|
555 |
+
$opengraph .= PHP_EOL . '<meta property="og:url" content="' . get_permalink() . '" />';
|
556 |
+
$opengraph .= PHP_EOL . '<meta property="og:site_name" content="' . get_bloginfo( 'name' ) . '" />';
|
557 |
+
if( $this->get_fb_author_url() ) {
|
558 |
+
$opengraph .= PHP_EOL . '<meta property="article:author" content="' . $this->get_fb_author_url() . '" />';
|
559 |
+
}
|
560 |
+
if( $this->get_fb_publisher_url() ) {
|
561 |
+
$opengraph .= PHP_EOL . '<meta property="article:publisher" content="' . $this->get_fb_publisher_url() . '" />';
|
562 |
+
}
|
563 |
+
if( $this->get_fb_app_id() ) {
|
564 |
+
$opengraph .= PHP_EOL . '<meta property="fb:app_id" content="' . $this->get_fb_app_id() . '" />';
|
565 |
+
}
|
566 |
+
$opengraph .= PHP_EOL . '<meta property="article:published_time" content="' . get_post_time( 'c' ) . '" />';
|
567 |
+
$opengraph .= PHP_EOL . '<meta property="article:modified_time" content="' . get_post_modified_time( 'c' ) . '" />';
|
568 |
+
$opengraph .= PHP_EOL . '<meta property="og:updated_time" content="' . get_post_modified_time( 'c' ) . '" />';
|
569 |
+
$opengraph .= PHP_EOL . '<!-- Open Graph Meta Tags generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->';
|
570 |
+
|
571 |
+
return $opengraph;
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Render Twitter Card Meta Output
|
576 |
+
*
|
577 |
+
* @return string HTML
|
578 |
+
*/
|
579 |
+
public function render_twitter_card_meta() {
|
580 |
+
|
581 |
+
if( !$this->is_twitter_card() ) {
|
582 |
+
$html = '';
|
583 |
+
return $html;
|
584 |
+
}
|
585 |
+
|
586 |
+
$twittercard = PHP_EOL . '<!-- Twitter Card generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->';
|
587 |
+
|
588 |
+
$imagesize = $this->get_og_image_size();
|
589 |
+
if( is_array( $imagesize ) && isset($imagesize[0]) && isset($imagesize[1]) ) {
|
590 |
+
$twittercard .= PHP_EOL . '<meta property="og:image:width" content="' . $imagesize[0] . '" />';
|
591 |
+
$twittercard .= PHP_EOL . '<meta property="og:image:height" content="' . $imagesize[1] . '" />';
|
592 |
+
}
|
593 |
+
// Large Summary Twitter Card
|
594 |
+
if( $this->get_twitter_image() ) {
|
595 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:card" content="summary_large_image">';
|
596 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:title" content="' . $this->get_twitter_title() . '">';
|
597 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:description" content="' . $this->get_twitter_description() . '">';
|
598 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:image" content="' . $this->get_twitter_image() . '">';
|
599 |
+
if( !empty( $this->twitter_site ) ) {
|
600 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:site" content="@' . $this->twitter_site . '">';
|
601 |
+
}
|
602 |
+
if( !empty( $this->twitter_creator ) ) {
|
603 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:creator" content="@' . str_replace( '@', '', $this->twitter_creator ) . '">';
|
604 |
+
}
|
605 |
+
|
606 |
+
// Small Summary Twitter Cards
|
607 |
+
} else {
|
608 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:card" content="summary">';
|
609 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:title" content="' . $this->get_twitter_title() . '">';
|
610 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:description" content="' . $this->get_twitter_description() . '">';
|
611 |
+
if( !empty( $this->twitter_site ) ) {
|
612 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:site" content="@' . $this->twitter_site . '">';
|
613 |
+
}
|
614 |
+
if( !empty( $this->twitter_creator ) ) {
|
615 |
+
$twittercard .= PHP_EOL . '<meta name="twitter:creator" content="@' . str_replace( '@', '', $this->twitter_creator ) . '">';
|
616 |
+
}
|
617 |
+
}
|
618 |
+
$twittercard .= PHP_EOL . '<!-- Twitter Card generated by MashShare ' . MASHSB_VERSION . ' - https://www.mashshare.net -->' . PHP_EOL . PHP_EOL;
|
619 |
+
return $twittercard;
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Render Meta Output
|
624 |
+
*
|
625 |
+
* @return string HTML
|
626 |
+
*/
|
627 |
+
public function render_header_meta() {
|
628 |
+
//echo apply_filters( 'mashsb_meta_tags', $html );
|
629 |
+
echo apply_filters( 'mashsb_opengraph_meta', $this->render_open_graph_meta() );
|
630 |
+
echo apply_filters( 'mashsb_twittercard_meta', $this->render_twitter_card_meta() );
|
631 |
+
}
|
632 |
+
|
633 |
+
}
|
634 |
+
|
635 |
+
// end class
|
636 |
+
|
637 |
+
/**
|
638 |
+
* Init - Execute only once
|
639 |
+
*
|
640 |
+
* @global MASHSB_HEADER_META_TAGS $mashsb_meta_tags
|
641 |
+
* @return object
|
642 |
+
*/
|
643 |
+
function mashsb_meta_tags_init() {
|
644 |
+
global $mashsb_meta_tags;
|
645 |
+
|
646 |
+
if( !is_null( $mashsb_meta_tags ) ) {
|
647 |
+
return $mashsb_meta_tags;
|
648 |
+
}
|
649 |
+
|
650 |
+
$mashsb_meta_tags = new MASHSB_HEADER_META_TAGS();
|
651 |
+
return $mashsb_meta_tags;
|
652 |
+
}
|
653 |
+
|
654 |
+
add_action( 'wp_head', 'mashsb_meta_tags_init', 1 );
|
655 |
+
|
656 |
+
// Remove Social Warfare tags open graph tags (Soory Social Warfare guys - You do a great job)
|
657 |
+
add_filter( 'sw_meta_tags', '__return_false', 99 );
|
658 |
+
|
includes/libraries/RolingCurlX.php
CHANGED
@@ -55,7 +55,7 @@ Class RollingCurlX {
|
|
55 |
array $post_data = NULL,
|
56 |
//callable $callback = NULL, //individual callback rhe
|
57 |
//$callback = NULL, //individual callback
|
58 |
-
|
59 |
$user_data = NULL,
|
60 |
array $options = NULL, //individual cURL options
|
61 |
array $headers = NULL //individual cURL request headers
|
55 |
array $post_data = NULL,
|
56 |
//callable $callback = NULL, //individual callback rhe
|
57 |
//$callback = NULL, //individual callback
|
58 |
+
array $callback = NULL,
|
59 |
$user_data = NULL,
|
60 |
array $options = NULL, //individual cURL options
|
61 |
array $headers = NULL //individual cURL request headers
|
includes/logger.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
*
|
10 |
**/
|
11 |
class mashsbLogger {
|
12 |
-
var $file, $path, $level, $stream;
|
13 |
const INFO = 4;
|
14 |
const DEBUG = 3;
|
15 |
const WARN = 2;
|
9 |
*
|
10 |
**/
|
11 |
class mashsbLogger {
|
12 |
+
var $file, $path, $level, $stream, $folder;
|
13 |
const INFO = 4;
|
14 |
const DEBUG = 3;
|
15 |
const WARN = 2;
|
includes/mashengine.php
CHANGED
@@ -90,7 +90,7 @@ class mashengine {
|
|
90 |
$RollingCurlX->addRequest( "https://graph.facebook.com/v2.7/?id=" . $this->https_scheme_url, $post_data, array($this, 'getCount'), array('facebook_total'), $headers );
|
91 |
$RollingCurlX->addRequest( "https://graph.facebook.com/v2.7/?id=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('facebook_total'), $headers );
|
92 |
}else{
|
93 |
-
$RollingCurlX->addRequest( "https://graph.facebook.com/v2.7/?id=" . $this->
|
94 |
}
|
95 |
}
|
96 |
break;
|
@@ -291,7 +291,7 @@ class mashengine {
|
|
291 |
$this->data->shares->$service[0] = $count;
|
292 |
* */
|
293 |
$this->data->total += $count;
|
294 |
-
|
295 |
MASHSB()->logger->info( 'MashEngine - URL: ' . $url . ' ' . $service[0] . ': ' . $count );
|
296 |
mashdebug()->info( 'MashEngine - URL: ' . $url . ' ' . $service[0] . ': ' . $count );
|
297 |
}
|
90 |
$RollingCurlX->addRequest( "https://graph.facebook.com/v2.7/?id=" . $this->https_scheme_url, $post_data, array($this, 'getCount'), array('facebook_total'), $headers );
|
91 |
$RollingCurlX->addRequest( "https://graph.facebook.com/v2.7/?id=" . $this->http_scheme_url, $post_data, array($this, 'getCount'), array('facebook_total'), $headers );
|
92 |
}else{
|
93 |
+
$RollingCurlX->addRequest( "https://graph.facebook.com/v2.7/?id=" . $this->url . '&access_token=' . sanitize_text_field( $mashsb_options['fb_access_token'] ), $post_data, array($this, 'getCount'), array('facebook_total'), $headers );
|
94 |
}
|
95 |
}
|
96 |
break;
|
291 |
$this->data->shares->$service[0] = $count;
|
292 |
* */
|
293 |
$this->data->total += $count;
|
294 |
+
//$this->data->$service[0] = $count;
|
295 |
MASHSB()->logger->info( 'MashEngine - URL: ' . $url . ' ' . $service[0] . ': ' . $count );
|
296 |
mashdebug()->info( 'MashEngine - URL: ' . $url . ' ' . $service[0] . ': ' . $count );
|
297 |
}
|
includes/sharecount-functions.php
CHANGED
@@ -23,6 +23,13 @@ if( !defined( 'ABSPATH' ) ) {
|
|
23 |
function mashsb_is_cache_refresh() {
|
24 |
global $post, $mashsb_options;
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
// if it's a crawl deactivate cache
|
27 |
if( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'] ) ) {
|
28 |
return false;
|
@@ -43,12 +50,6 @@ function mashsb_is_cache_refresh() {
|
|
43 |
return false;
|
44 |
}
|
45 |
|
46 |
-
// Debug mode or cache activated
|
47 |
-
if( MASHSB_DEBUG || isset( $mashsb_options['disable_cache'] ) ) {
|
48 |
-
MASHSB()->logger->info( 'mashsb_is_cache_refresh: MASHSB_DEBUG - refresh Cache' );
|
49 |
-
return true;
|
50 |
-
}
|
51 |
-
|
52 |
// New cache on singular pages
|
53 |
//
|
54 |
// Refreshing cache on blog posts like categories will lead
|
@@ -100,7 +101,7 @@ function mashsb_is_cache_refresh() {
|
|
100 |
* @return string numerical
|
101 |
*/
|
102 |
function mashsb_ajax_refresh_cache() {
|
103 |
-
if( mashsb_is_cache_refresh ) {
|
104 |
wp_die( '1' );
|
105 |
} else {
|
106 |
wp_die( '0' );
|
@@ -113,7 +114,6 @@ add_action( 'wp_ajax_nopriv_mashsb_refresh_cache', 'mashsb_ajax_refresh_cache' )
|
|
113 |
/**
|
114 |
* Get expiration time for new Asyn Cache Method
|
115 |
*
|
116 |
-
* @param int $post_age
|
117 |
* @since 3.0.0
|
118 |
* @return int
|
119 |
*/
|
@@ -138,7 +138,6 @@ function mashsb_get_expiration_method_async() {
|
|
138 |
/**
|
139 |
* Get expiration time for old method "Refresh On Loading"
|
140 |
*
|
141 |
-
* @param int $post_age
|
142 |
* @since 3.0.0
|
143 |
* @return int
|
144 |
*/
|
23 |
function mashsb_is_cache_refresh() {
|
24 |
global $post, $mashsb_options;
|
25 |
|
26 |
+
|
27 |
+
// Debug mode or cache activated
|
28 |
+
if( MASHSB_DEBUG || isset( $mashsb_options['disable_cache'] ) ) {
|
29 |
+
MASHSB()->logger->info( 'mashsb_is_cache_refresh: MASHSB_DEBUG - refresh Cache' );
|
30 |
+
return true;
|
31 |
+
}
|
32 |
+
|
33 |
// if it's a crawl deactivate cache
|
34 |
if( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'] ) ) {
|
35 |
return false;
|
50 |
return false;
|
51 |
}
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
// New cache on singular pages
|
54 |
//
|
55 |
// Refreshing cache on blog posts like categories will lead
|
101 |
* @return string numerical
|
102 |
*/
|
103 |
function mashsb_ajax_refresh_cache() {
|
104 |
+
if( mashsb_is_cache_refresh() ) {
|
105 |
wp_die( '1' );
|
106 |
} else {
|
107 |
wp_die( '0' );
|
114 |
/**
|
115 |
* Get expiration time for new Asyn Cache Method
|
116 |
*
|
|
|
117 |
* @since 3.0.0
|
118 |
* @return int
|
119 |
*/
|
138 |
/**
|
139 |
* Get expiration time for old method "Refresh On Loading"
|
140 |
*
|
|
|
141 |
* @since 3.0.0
|
142 |
* @return int
|
143 |
*/
|
includes/sharedcount.class.php
DELETED
@@ -1,163 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Sharecount functions
|
4 |
-
* Get the share count from the service sharedcount.com
|
5 |
-
*
|
6 |
-
* @package MASHSB
|
7 |
-
* @subpackage Functions/sharedcount
|
8 |
-
* @copyright Copyright (c) 2014, René Hermenau
|
9 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
10 |
-
* @since 2.0.9
|
11 |
-
*/
|
12 |
-
|
13 |
-
class mashsbSharedcount {
|
14 |
-
private $url,$timeout;
|
15 |
-
|
16 |
-
function __construct($url,$timeout=10, $apikey = '') {
|
17 |
-
global $mashsb_options;
|
18 |
-
$this->url = rawurlencode($url);
|
19 |
-
$this->timeout= $timeout;
|
20 |
-
$this->apikey = trim($apikey);
|
21 |
-
}
|
22 |
-
|
23 |
-
function getFBTWCounts(){
|
24 |
-
global $mashsb_options;
|
25 |
-
|
26 |
-
isset($mashsb_options['facebook_count_mode']) ? $fb_mode = $mashsb_options['facebook_count_mode'] : $fb_mode = '';
|
27 |
-
|
28 |
-
$sharecounts = $this->get_sharedcount();
|
29 |
-
|
30 |
-
if(!$sharecounts){
|
31 |
-
$this->sharecount = new stdClass;
|
32 |
-
$this->sharecount->total = 0;
|
33 |
-
return $this->sharecount;
|
34 |
-
}
|
35 |
-
$counts = array('shares'=>array(),'total'=>0);
|
36 |
-
switch ($fb_mode){
|
37 |
-
case $fb_mode === 'likes':
|
38 |
-
$counts['shares']['fb'] = $sharecounts['Facebook']['like_count'];
|
39 |
-
break;
|
40 |
-
case $fb_mode === 'total':
|
41 |
-
$counts['shares']['fb'] = $sharecounts['Facebook']['total_count'];
|
42 |
-
break;
|
43 |
-
default:
|
44 |
-
$counts['shares']['fb'] = $sharecounts['Facebook']['share_count'];
|
45 |
-
}
|
46 |
-
$counts['shares']['tw'] = $sharecounts['Twitter'];
|
47 |
-
|
48 |
-
foreach ($counts['shares'] as $mashsbcounts => $sharecount) $counts['total'] += (int)$sharecount;
|
49 |
-
mashdebug()->error("sharedcount.com getFBTWCounts: " . $counts['total']);
|
50 |
-
|
51 |
-
$totalArr = array ('total' => $counts['total']);
|
52 |
-
$objMerged = (object)array_merge((array)$sharecounts, (array)$totalArr);
|
53 |
-
return $objMerged;
|
54 |
-
|
55 |
-
}
|
56 |
-
/* Only used when mashshare-networks is enabled */
|
57 |
-
function getAllCounts(){
|
58 |
-
global $mashsb_options;
|
59 |
-
|
60 |
-
isset($mashsb_options['facebook_count_mode']) ? $fb_mode = $mashsb_options['facebook_count_mode'] : $fb_mode = '';
|
61 |
-
|
62 |
-
$sharecounts = $this->get_sharedcount();
|
63 |
-
if(!$sharecounts){
|
64 |
-
$this->sharecount = new stdClass;
|
65 |
-
$this->sharecount->total = 0;
|
66 |
-
return $this->sharecount;
|
67 |
-
}
|
68 |
-
|
69 |
-
$counts = array('shares'=>array(),'total'=>0);
|
70 |
-
$counts = array('shares'=>array(),'total'=>0);
|
71 |
-
switch ($fb_mode){
|
72 |
-
case $fb_mode === 'likes':
|
73 |
-
$counts['shares']['fb'] = $sharecounts['Facebook']['like_count'];
|
74 |
-
break;
|
75 |
-
case $fb_mode === 'total':
|
76 |
-
$counts['shares']['fb'] = $sharecounts['Facebook']['total_count'];
|
77 |
-
break;
|
78 |
-
default:
|
79 |
-
$counts['shares']['fb'] = $sharecounts['Facebook']['share_count'];
|
80 |
-
}
|
81 |
-
isset($sharecounts['Twitter']) ? $counts['shares']['tw'] = $sharecounts['Twitter'] : $sharecounts['Twitter'] = 0;
|
82 |
-
isset($sharecounts['GooglePlusOne']) ? $counts['shares']['gp'] = $sharecounts['GooglePlusOne'] : $counts['shares']['gp'] = 0 ;
|
83 |
-
isset($sharecounts['LinkedIn']) ? $counts['shares']['li'] = $sharecounts['LinkedIn'] : $counts['shares']['li'] = 0;
|
84 |
-
isset($sharecounts['StumbleUpon']) ? $counts['shares']['st'] = $sharecounts['StumbleUpon'] : $counts['shares']['st'] = 0 ;
|
85 |
-
isset($sharecounts['Pinterest']) ? $counts['shares']['pin'] = $sharecounts['Pinterest'] : $counts['shares']['pin'] = 0;
|
86 |
-
|
87 |
-
$total = 0;
|
88 |
-
foreach ($counts['shares'] as $totalcount) $total += (int)$totalcount;
|
89 |
-
$totalArr = array ('total' => $total);
|
90 |
-
$objMerged = (object)array_merge((array)$sharecounts, (array)$totalArr);
|
91 |
-
mashdebug()->info("sharedcount.com getAllCounts: " . $counts['total']);
|
92 |
-
return $objMerged;
|
93 |
-
}
|
94 |
-
|
95 |
-
function update_sharedcount_domain($domain = false){
|
96 |
-
global $mashsb_options;
|
97 |
-
if(!$domain){
|
98 |
-
try{
|
99 |
-
$domain_obj = $this->_curl('http://'. $mashsb_options["mashsharer_sharecount_domain"] . "/account?apikey=" . $this->apikey);
|
100 |
-
$domain = $domain_obj["domain"];
|
101 |
-
}
|
102 |
-
catch (Exception $e){
|
103 |
-
mashdebug()->error("error: " . $domain_obj);
|
104 |
-
return 0;
|
105 |
-
}
|
106 |
-
}
|
107 |
-
$mashsb_options["mashsharer_sharecount_domain"] = $domain;
|
108 |
-
update_option( 'mashsb_settings', $mashsb_options);
|
109 |
-
return 1;
|
110 |
-
}
|
111 |
-
|
112 |
-
private function _curl($url){
|
113 |
-
$curl = curl_init();
|
114 |
-
curl_setopt($curl, CURLOPT_URL, $url);
|
115 |
-
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
116 |
-
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT ,5);
|
117 |
-
curl_setopt($curl, CURLOPT_TIMEOUT, 5); //timeout in seconds
|
118 |
-
$curl_results = curl_exec ($curl);
|
119 |
-
curl_close ($curl);
|
120 |
-
return json_decode($curl_results, true);
|
121 |
-
}
|
122 |
-
|
123 |
-
function get_sharedcount() {
|
124 |
-
mashdebug()->info("Share URL: " . $this->url);
|
125 |
-
global $mashsb_options;
|
126 |
-
if( empty($this->apikey) ){
|
127 |
-
return 0; //quit early if there's no API key.
|
128 |
-
}
|
129 |
-
//$apikey = trim($mashsb_options['mashsharer_apikey']);
|
130 |
-
$domain = isset($mashsb_options['mashsharer_sharecount_domain']) ? trim($mashsb_options['mashsharer_sharecount_domain']) : '';
|
131 |
-
if(!isset($domain) || empty($domain)){
|
132 |
-
$domain = "free.sharedcount.com";
|
133 |
-
$this->update_sharedcount_domain($domain);
|
134 |
-
}
|
135 |
-
|
136 |
-
try {
|
137 |
-
$counts = $this->_curl('http://'.$domain . "/?url=" . $this->url . "&apikey=" . $this->apikey);
|
138 |
-
//mashdebug()->error('check ' . $domain . $this->apikey . $this->url);
|
139 |
-
if(isset($counts["Error"]) && isset($counts['Domain']) && $counts["Type"] === "domain_apikey_mismatch"){
|
140 |
-
$this->update_sharedcount_domain($counts['Domain']);
|
141 |
-
return 0;
|
142 |
-
}
|
143 |
-
else if(isset($counts["Error"]) && isset($counts['Type']) && $counts['Type'] === 'invalid_api_key' ){
|
144 |
-
$this->update_sharedcount_domain();
|
145 |
-
return 0;
|
146 |
-
}
|
147 |
-
|
148 |
-
mashdebug()->error("Facebook total count: " . $counts['Facebook']['total_count']);
|
149 |
-
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'] . " TW: " . $counts['Twitter'] . " G+:" . $counts['GooglePlusOne'] . " Linkedin:" . $counts['LinkedIn'] . " Stumble: " . $counts['StumbleUpon'] . " Pinterest: " . $counts['Pinterest']);
|
150 |
-
|
151 |
-
return $counts;
|
152 |
-
} catch (Exception $e){
|
153 |
-
mashdebug()->error("error: " . $counts);
|
154 |
-
MASHSB()->logger->info('ERROR: Curl()' . $counts);
|
155 |
-
return 0;
|
156 |
-
}
|
157 |
-
mashdebug()->error("error2: " . $counts);
|
158 |
-
MASHSB()->logger->info('ERROR 2: Curl()' . $counts);
|
159 |
-
return 0;
|
160 |
-
}
|
161 |
-
|
162 |
-
}
|
163 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/template-functions.php
CHANGED
@@ -55,7 +55,7 @@ function mashsbGetShareObj( $url ) {
|
|
55 |
require_once(MASHSB_PLUGIN_DIR . 'includes/mashengine.php');
|
56 |
}
|
57 |
|
58 |
-
mashdebug()->info( 'mashsbGetShareObj() url: ' . $url );
|
59 |
$mashsbSharesObj = new mashengine( $url );
|
60 |
return $mashsbSharesObj;
|
61 |
|
@@ -153,41 +153,21 @@ function getSharedcount( $url ) {
|
|
153 |
return apply_filters( 'filter_get_sharedcount', 0 );
|
154 |
}
|
155 |
|
156 |
-
// if it's a crawl bot only serve non calculated numbers to save load
|
157 |
-
/*if( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'] ) ) {
|
158 |
-
return apply_filters( 'filter_get_sharedcount', 100 );
|
159 |
-
}*/
|
160 |
-
|
161 |
/*
|
162 |
* Return share count on non singular pages when url is defined
|
163 |
Possible: Category, blog list pages, non singular() pages. This store the shares in transients with mashsbGetNonPostShares();
|
164 |
*/
|
165 |
|
166 |
-
|
167 |
-
// // global sharecount
|
168 |
-
// $shares = mashsbGetNonPostShares( mashsb_get_main_url() ) + getFakecount();
|
169 |
-
// $mashsb_sharecount = array($url => $shares);
|
170 |
-
// echo "url2: " . $mashsb_sharecount[$url];
|
171 |
-
// return apply_filters( 'filter_get_sharedcount', $shares );
|
172 |
-
// }
|
173 |
if( !empty( $url ) && is_null( $post ) ) {
|
174 |
-
|
175 |
}
|
176 |
|
177 |
-
/*
|
178 |
-
* Important: This runs on non singular pages
|
179 |
-
* and prevents php from crashing and looping
|
180 |
-
* because of timeouts and no results query
|
181 |
-
*/
|
182 |
-
/*if( !is_null( $post ) ) {
|
183 |
-
return apply_filters( 'filter_get_sharedcount', get_post_meta( $post->ID, 'mashsb_shares', true ) + getFakecount() );
|
184 |
-
}*/
|
185 |
-
|
186 |
/*
|
187 |
* Refresh Cache
|
188 |
*/
|
189 |
if( mashsb_force_cache_refresh() && is_singular() ) {
|
190 |
-
|
191 |
// free some memory
|
192 |
unset ( $mashsb_sharecount[$url] );
|
193 |
|
55 |
require_once(MASHSB_PLUGIN_DIR . 'includes/mashengine.php');
|
56 |
}
|
57 |
|
58 |
+
//mashdebug()->info( 'mashsbGetShareObj() url: ' . $url );
|
59 |
$mashsbSharesObj = new mashengine( $url );
|
60 |
return $mashsbSharesObj;
|
61 |
|
153 |
return apply_filters( 'filter_get_sharedcount', 0 );
|
154 |
}
|
155 |
|
|
|
|
|
|
|
|
|
|
|
156 |
/*
|
157 |
* Return share count on non singular pages when url is defined
|
158 |
Possible: Category, blog list pages, non singular() pages. This store the shares in transients with mashsbGetNonPostShares();
|
159 |
*/
|
160 |
|
161 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
if( !empty( $url ) && is_null( $post ) ) {
|
163 |
+
return apply_filters( 'filter_get_sharedcount', mashsbGetNonPostShares( $url ) );
|
164 |
}
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
/*
|
167 |
* Refresh Cache
|
168 |
*/
|
169 |
if( mashsb_force_cache_refresh() && is_singular() ) {
|
170 |
+
|
171 |
// free some memory
|
172 |
unset ( $mashsb_sharecount[$url] );
|
173 |
|
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.2.
|
10 |
* Text Domain: mashsb
|
11 |
* Domain Path: /languages
|
12 |
* Credits: Thanks go to Pippin Williamson and the edd team. When we started with Mashshare we decided to use the EDD code base and
|
@@ -37,7 +37,7 @@ if( !defined( 'ABSPATH' ) )
|
|
37 |
|
38 |
// Plugin version
|
39 |
if( !defined( 'MASHSB_VERSION' ) ) {
|
40 |
-
define( 'MASHSB_VERSION', '3.2.
|
41 |
}
|
42 |
|
43 |
// 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.2.5
|
10 |
* Text Domain: mashsb
|
11 |
* Domain Path: /languages
|
12 |
* Credits: Thanks go to Pippin Williamson and the edd team. When we started with Mashshare we decided to use the EDD code base and
|
37 |
|
38 |
// Plugin version
|
39 |
if( !defined( 'MASHSB_VERSION' ) ) {
|
40 |
+
define( 'MASHSB_VERSION', '3.2.5' );
|
41 |
}
|
42 |
|
43 |
// 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
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 4.7
|
12 |
-
Stable tag: 3.2.
|
13 |
|
14 |
Social Media Share Buttons for Twitter, Facebook and other social networks. Highly customizable Social Media ecosystem
|
15 |
|
@@ -319,7 +319,13 @@ Read here more FAQ: [https://www.mashshare.net/faq/](https://www.mashshare.net/f
|
|
319 |
|
320 |
== Changelog ==
|
321 |
|
322 |
-
3.2.
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
* Fix: Remove box-shadow: none; declaration and fix the shadow button style
|
324 |
* Fix: Review button link in admin notice not working
|
325 |
* Fix: Button margin upgrade function not working
|
9 |
Tags: Share buttons, Social Sharing, social media, Facebook, Twitter, Subscribe, Traffic posts, pages, widget, social share buttons, analytics, email
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 4.7
|
12 |
+
Stable tag: 3.2.5
|
13 |
|
14 |
Social Media Share Buttons for Twitter, Facebook and other social networks. Highly customizable Social Media ecosystem
|
15 |
|
319 |
|
320 |
== Changelog ==
|
321 |
|
322 |
+
= 3.2.5 =
|
323 |
+
* Fix: Fix a bug where only for http schemed urls the shares are returned. This happens only when no FB APP secret is used.
|
324 |
+
* Fix: Default table options are not stored on plugin update
|
325 |
+
* Tweak: Add more unit tests to check shares for http(s)
|
326 |
+
* Tweak: Show FB app secret admin notice only on MashShare admin pages
|
327 |
+
|
328 |
+
= 3.2.4 =
|
329 |
* Fix: Remove box-shadow: none; declaration and fix the shadow button style
|
330 |
* Fix: Review button link in admin notice not working
|
331 |
* Fix: Button margin upgrade function not working
|