Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Fix: Convert Quote characters in open graph title to html entities.
* Fix: Pinterest button not working on AMP pages
* Fix: Hackernews and  Flipboard button not working on AMP pages
  • Loading branch information
rene-hermenau committed Oct 19, 2016
1 parent fad1f5b commit ac7d44e
Show file tree
Hide file tree
Showing 16 changed files with 749 additions and 107 deletions.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
Binary file added assets/css/fonts/old/mashsb-font.eot
Binary file not shown.
78 changes: 78 additions & 0 deletions assets/css/fonts/old/mashsb-font.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/css/fonts/old/mashsb-font.ttf
Binary file not shown.
Binary file added assets/css/fonts/old/mashsb-font.woff
Binary file not shown.
Binary file added assets/css/fonts/old/mashsb-font.woff2
Binary file not shown.
9 changes: 9 additions & 0 deletions assets/css/mashsb-amp.css
Expand Up @@ -110,6 +110,8 @@ color:#ffffff;
.mashicon-frype .icon:before { content: '\e81c'; } /* '' */
.mashicon-skype .icon:before { content: '\e81d'; } /* '' */
.mashicon-telegram .icon:before { content: '\e81f'; } /* '' */
.mashicon-hackernews .icon:before { content: '\e820'; } /* '' */
.mashicon-flipboard .icon:before { content: '\e821'; } /* '' */

.mashicon-share:before { content: '\e81E'; } /* '' */

Expand Down Expand Up @@ -238,6 +240,13 @@ background: #00afef;
background: #1d94d3;
}

.mashicon-hackernews{
background: #ff6600;
}
.mashicon-flipboard{
background: #b31f17;
}

.mashicon-buffer .text, mashicon-buffer .icon{
color: #ffffff;
}
Expand Down
421 changes: 420 additions & 1 deletion assets/css/mashsb.min.css

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions includes/amp.php
@@ -0,0 +1,135 @@
<?php

/**
* Scripts
*
* @package MASHSB
* @subpackage AMP Functions
* @copyright Copyright (c) 2016, René Hermenau
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*/
// Exit if accessed directly
if( !defined( 'ABSPATH' ) )
exit;

add_action( 'amp_post_template_css', 'mashsb_amp_load_css', 10 );

/**
* Check if current page is AMP page
*
* @return boolean
*/
function mashsb_is_amp_page(){
// Defined in https://wordpress.org/plugins/amp/ is_amp_endpoint()

if ( function_exists('is_amp_endpoint') && is_amp_endpoint()){
return true;
}
return false;
}

/**
* Load AMP (Accelerated Mobile Pages) CSS
*
* @return string css
*/
function mashsb_amp_load_css() {
global $mashsb_options;

$share_color = !empty( $mashsb_options['share_color'] ) ? '.mashsb-count {color:' . $mashsb_options['share_color'] . '}' : '';
$custom_css = isset( $mashsb_options['custom_css'] ) ? $mashsb_options['custom_css'] : '';
$amp_css = isset( $mashsb_options['amp_css'] ) ? $mashsb_options['amp_css'] : '';

$css = "@font-face {
font-family: 'mashsb-font';
src: url('" . MASHSB_PLUGIN_URL . "assets/css/fonts/mashsb-font.eot?62884501');
src: url('" . MASHSB_PLUGIN_URL . "assets/css/fonts/mashsb-font.eot?62884501#iefix') format('embedded-opentype'),
url('" . MASHSB_PLUGIN_URL . "assets/css/fonts/mashsb-font.woff?62884501') format('woff'),
url('" . MASHSB_PLUGIN_URL . "assets/css/fonts/mashsb-font.ttf?62884501') format('truetype'),
url('" . MASHSB_PLUGIN_URL . "assets/css/fonts/mashsb-font.svg?62884501#mashsb-font') format('svg');
font-weight: normal;
font-style: normal;
}";

// Get default css file
$css .= file_get_contents( MASHSB_PLUGIN_DIR . '/assets/css/mashsb-amp.css' );


// add custom css
$css .= $custom_css;

// add AMP custom css
$css .= $amp_css;

// STYLES
$css .= $share_color;

if( !empty( $mashsb_options['border_radius'] ) && $mashsb_options['border_radius'] != 'default' ) {
$css .= '
[class^="mashicon-"], .onoffswitch-label, .onoffswitch2-label {
border-radius: ' . $mashsb_options['border_radius'] . 'px;
}';
}
if( !empty( $mashsb_options['mash_style'] ) && $mashsb_options['mash_style'] == 'gradiant' ) {
$css .= '
.mashsb-buttons a {
background-image: -webkit-linear-gradient(bottom,rgba(0, 0, 0, 0.17) 0%,rgba(255, 255, 255, 0.17) 100%);
background-image: -moz-linear-gradient(bottom,rgba(0, 0, 0, 0.17) 0%,rgba(255, 255, 255, 0.17) 100%);
background-image: linear-gradient(bottom,rgba(0,0,0,.17) 0%,rgba(255,255,255,.17) 100%);}';
}
// Get css for small buttons
$css .= '[class^="mashicon-"] .text, [class*=" mashicon-"] .text{
text-indent: -9999px;
line-height: 0px;
display: block;
}
[class^="mashicon-"] .text:after, [class*=" mashicon-"] .text:after {
content: "";
text-indent: 0;
font-size:13px;
display: block;
}
[class^="mashicon-"], [class*=" mashicon-"] {
width:25%;
text-align: center;
}
[class^="mashicon-"] .icon:before, [class*=" mashicon-"] .icon:before {
float:none;
margin-right: 0;
}
.mashsb-buttons a{
margin-right: 3px;
margin-bottom:3px;
min-width: 0px;
width: 41px;
}
.onoffswitch,
.onoffswitch-inner:before,
.onoffswitch-inner:after
.onoffswitch2,
.onoffswitch2-inner:before,
.onoffswitch2-inner:after {
margin-right: 0px;
width: 41px;
line-height: 41px;
}';
// hide plus and subscribe button
// on AMP we disable js
$css .= '.onoffswitch2, .onoffswitch{display:none}';

// Hide subscribe button when it's not a link
$css .= isset( $mashsb_options['subscribe_behavior'] ) && $mashsb_options['subscribe_behavior'] === 'content' ? '.mashicon-subscribe{display:none;}' : '';

// Make sure the share buttons are not moving under the share count when decreasing width
$css .= '.mashsb-buttons{display:table;}';

// Float the second shares box
$css .= '.secondary-shares{float:left;}';

// Hide the view count
$css .= '.mashpv{display:none;}';

echo $css;
}
204 changes: 101 additions & 103 deletions includes/scripts.php
Expand Up @@ -17,7 +17,7 @@
add_action( 'wp_enqueue_scripts', 'mashsb_load_scripts', 10 );
add_action( 'wp_enqueue_scripts', 'mashsb_register_styles', 10 );
add_action( 'wp_enqueue_scripts', 'mashsb_load_inline_styles', 10 );
add_action( 'amp_post_template_css', 'mashsb_amp_load_css', 10 );
//add_action( 'amp_post_template_css', 'mashsb_amp_load_css', 10 );

/**
* Load Scripts
Expand Down Expand Up @@ -252,108 +252,106 @@ function mashsb_load_inline_styles() {
*
* @return string css
*/
function mashsb_amp_load_css() {
global $mashsb_options;

$share_color = !empty( $mashsb_options['share_color'] ) ? '.mashsb-count {color:' . $mashsb_options['share_color'] . '}' : '';
$custom_css = isset( $mashsb_options['custom_css'] ) ? $mashsb_options['custom_css'] : '';
$amp_css = isset( $mashsb_options['amp_css'] ) ? $mashsb_options['amp_css'] : '';

$css = "@font-face {
font-family: 'mashsb-font';
src: url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.eot?29924580');
src: url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.eot?29924580#iefix') format('embedded-opentype'),
url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.woff2?29924580') format('woff2'),
url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.woff?29924580') format('woff'),
url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.ttf?29924580') format('truetype'),
url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.svg?29924580#mashsb-font') format('svg');
font-weight: normal;
font-style: normal;
}";

// Get default css file
$css .= file_get_contents( MASHSB_PLUGIN_DIR . '/assets/css/mashsb-amp.css' );


// add custom css
$css .= $custom_css;

// add AMP custom css
$css .= $amp_css;

// STYLES
$css .= $share_color;

if( !empty( $mashsb_options['border_radius'] ) && $mashsb_options['border_radius'] != 'default' ) {
$css .= '
[class^="mashicon-"], .onoffswitch-label, .onoffswitch2-label {
border-radius: ' . $mashsb_options['border_radius'] . 'px;
}';
}
if( !empty( $mashsb_options['mash_style'] ) && $mashsb_options['mash_style'] == 'gradiant' ) {
$css .= '
.mashsb-buttons a {
background-image: -webkit-linear-gradient(bottom,rgba(0, 0, 0, 0.17) 0%,rgba(255, 255, 255, 0.17) 100%);
background-image: -moz-linear-gradient(bottom,rgba(0, 0, 0, 0.17) 0%,rgba(255, 255, 255, 0.17) 100%);
background-image: linear-gradient(bottom,rgba(0,0,0,.17) 0%,rgba(255,255,255,.17) 100%);}';
}
// Get css for small buttons
$css .= '[class^="mashicon-"] .text, [class*=" mashicon-"] .text{
text-indent: -9999px;
line-height: 0px;
display: block;
}
[class^="mashicon-"] .text:after, [class*=" mashicon-"] .text:after {
content: "";
text-indent: 0;
font-size:13px;
display: block;
}
[class^="mashicon-"], [class*=" mashicon-"] {
width:25%;
text-align: center;
}
[class^="mashicon-"] .icon:before, [class*=" mashicon-"] .icon:before {
float:none;
margin-right: 0;
}
.mashsb-buttons a{
margin-right: 3px;
margin-bottom:3px;
min-width: 0px;
width: 41px;
}
.onoffswitch,
.onoffswitch-inner:before,
.onoffswitch-inner:after
.onoffswitch2,
.onoffswitch2-inner:before,
.onoffswitch2-inner:after {
margin-right: 0px;
width: 41px;
line-height: 41px;
}';
// hide plus and subscribe button
// on AMP we disable js
$css .= '.onoffswitch2, .onoffswitch{display:none}';

// Hide subscribe button when it's not a link
$css .= isset( $mashsb_options['subscribe_behavior'] ) && $mashsb_options['subscribe_behavior'] === 'content' ? '.mashicon-subscribe{display:none;}' : '';

// Make sure the share buttons are not moving under the share count when decreasing width
$css .= '.mashsb-buttons{display:table;}';

// Float the second shares box
$css .= '.secondary-shares{float:left;}';

// Hide the view count
$css .= '.mashpv{display:none;}';

echo $css;
}

;
//function mashsb_amp_load_css() {
// global $mashsb_options;
//
// $share_color = !empty( $mashsb_options['share_color'] ) ? '.mashsb-count {color:' . $mashsb_options['share_color'] . '}' : '';
// $custom_css = isset( $mashsb_options['custom_css'] ) ? $mashsb_options['custom_css'] : '';
// $amp_css = isset( $mashsb_options['amp_css'] ) ? $mashsb_options['amp_css'] : '';
//
// $css = "@font-face {
// font-family: 'mashsb-font';
// src: url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.eot?29924580');
// src: url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.eot?29924580#iefix') format('embedded-opentype'),
// url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.woff2?29924580') format('woff2'),
// url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.woff?29924580') format('woff'),
// url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.ttf?29924580') format('truetype'),
// url('" . MASHSB_PLUGIN_URL . "/assets/css/fonts/mashsb-font.svg?29924580#mashsb-font') format('svg');
// font-weight: normal;
// font-style: normal;
//}";
//
// // Get default css file
// $css .= file_get_contents( MASHSB_PLUGIN_DIR . '/assets/css/mashsb-amp.css' );
//
//
// // add custom css
// $css .= $custom_css;
//
// // add AMP custom css
// $css .= $amp_css;
//
// // STYLES
// $css .= $share_color;
//
// if( !empty( $mashsb_options['border_radius'] ) && $mashsb_options['border_radius'] != 'default' ) {
// $css .= '
// [class^="mashicon-"], .onoffswitch-label, .onoffswitch2-label {
// border-radius: ' . $mashsb_options['border_radius'] . 'px;
// }';
// }
// if( !empty( $mashsb_options['mash_style'] ) && $mashsb_options['mash_style'] == 'gradiant' ) {
// $css .= '
// .mashsb-buttons a {
// background-image: -webkit-linear-gradient(bottom,rgba(0, 0, 0, 0.17) 0%,rgba(255, 255, 255, 0.17) 100%);
// background-image: -moz-linear-gradient(bottom,rgba(0, 0, 0, 0.17) 0%,rgba(255, 255, 255, 0.17) 100%);
// background-image: linear-gradient(bottom,rgba(0,0,0,.17) 0%,rgba(255,255,255,.17) 100%);}';
// }
// // Get css for small buttons
// $css .= '[class^="mashicon-"] .text, [class*=" mashicon-"] .text{
// text-indent: -9999px;
// line-height: 0px;
// display: block;
// }
// [class^="mashicon-"] .text:after, [class*=" mashicon-"] .text:after {
// content: "";
// text-indent: 0;
// font-size:13px;
// display: block;
// }
// [class^="mashicon-"], [class*=" mashicon-"] {
// width:25%;
// text-align: center;
// }
// [class^="mashicon-"] .icon:before, [class*=" mashicon-"] .icon:before {
// float:none;
// margin-right: 0;
// }
// .mashsb-buttons a{
// margin-right: 3px;
// margin-bottom:3px;
// min-width: 0px;
// width: 41px;
// }
//
// .onoffswitch,
// .onoffswitch-inner:before,
// .onoffswitch-inner:after
// .onoffswitch2,
// .onoffswitch2-inner:before,
// .onoffswitch2-inner:after {
// margin-right: 0px;
// width: 41px;
// line-height: 41px;
// }';
// // hide plus and subscribe button
// // on AMP we disable js
// $css .= '.onoffswitch2, .onoffswitch{display:none}';
//
// // Hide subscribe button when it's not a link
// $css .= isset( $mashsb_options['subscribe_behavior'] ) && $mashsb_options['subscribe_behavior'] === 'content' ? '.mashicon-subscribe{display:none;}' : '';
//
// // Make sure the share buttons are not moving under the share count when decreasing width
// $css .= '.mashsb-buttons{display:table;}';
//
// // Float the second shares box
// $css .= '.secondary-shares{float:left;}';
//
// // Hide the view count
// $css .= '.mashpv{display:none;}';
//
// echo $css;
//}

/*
* Check if debug mode is enabled
Expand Down
4 changes: 2 additions & 2 deletions includes/template-functions.php
Expand Up @@ -477,8 +477,8 @@ function mashsb_getNetworks( $is_shortcode = false, $services = 0 ) {

$enablednetworks[$key]['id'] == 'whatsapp' ? $display = 'style="display:none;"' : $display = ''; // Whatsapp button is made visible via js when opened on mobile devices

// Lets use the data attribute to prevent that pininit.js is overwriting our pinterest button PR https://secure.helpscout.net/conversation/257066283/954/?folderId=924740
if ('pinterest' === $enablednetworks[$key]['id'] ) {
// Lets use the data attribute to prevent that pininit.js is overwriting our pinterest button - PR: https://secure.helpscout.net/conversation/257066283/954/?folderId=924740
if ('pinterest' === $enablednetworks[$key]['id'] && !mashsb_is_amp_page() ) {
$output .= '<a ' . $display . ' class="mashicon-' . $enablednetworks[$key]['id'] . $class_size . $class_margin . $class_center . $class_style . '" href="#" data-mashsb-url="'. arrNetworks( $enablednetworks[$key]['id'], $is_shortcode ) . '" target="_blank" rel="nofollow"><span class="icon"></span><span class="text">' . $name . '</span></a>';
} else {
$output .= '<a ' . $display . ' class="mashicon-' . $enablednetworks[$key]['id'] . $class_size . $class_margin . $class_center . $class_style . '" href="' . arrNetworks( $enablednetworks[$key]['id'], $is_shortcode ) . '" target="_blank" rel="nofollow"><span class="icon"></span><span class="text">' . $name . '</span></a>';
Expand Down
1 change: 1 addition & 0 deletions mashshare.php
Expand Up @@ -200,6 +200,7 @@ private function includes() {
require_once MASHSB_PLUGIN_DIR . 'includes/libraries/class-bitly-shorturl.php';
require_once MASHSB_PLUGIN_DIR . 'includes/admin/tracking.php'; // Ensure cron is loading even on frontpage
require_once MASHSB_PLUGIN_DIR . 'includes/debug/debug.php';
require_once MASHSB_PLUGIN_DIR . 'includes/amp.php';

if( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
require_once MASHSB_PLUGIN_DIR . 'includes/install.php';
Expand Down

0 comments on commit ac7d44e

Please sign in to comment.