Version Description
Download this release
Release Info
| Developer | pressshack |
| Plugin | |
| Version | 2.0.1 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0.0 to 2.0.1
- EmbedPress/AMP/Adapter/Reddit.php +97 -0
- EmbedPress/AMP/Adapter/Twitter.php +90 -0
- EmbedPress/AMP/EmbedHandler.php +57 -0
- EmbedPress/Core.php +3 -0
- EmbedPress/Shortcode.php +9 -0
- assets/css/embedpress.css +4 -0
- embedpress.php +1 -1
- includes.php +1 -1
- readme.txt +9 -2
EmbedPress/AMP/Adapter/Reddit.php
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
namespace EmbedPress\AMP\Adapter;
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Entity that represents the embed provider for AMP.
|
| 9 |
+
*
|
| 10 |
+
* @package EmbedPress
|
| 11 |
+
* @author PressShack <help@pressshack.com>
|
| 12 |
+
* @copyright Copyright (C) 2017 PressShack. All rights reserved.
|
| 13 |
+
* @license GPLv2 or later
|
| 14 |
+
* @since 1.4.0
|
| 15 |
+
* @abstract
|
| 16 |
+
*/
|
| 17 |
+
class Reddit
|
| 18 |
+
{
|
| 19 |
+
/**
|
| 20 |
+
* @var object
|
| 21 |
+
*/
|
| 22 |
+
private $ampEmbedHandler;
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @var object
|
| 26 |
+
*/
|
| 27 |
+
private $urlData;
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
private $parsedContent;
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* @var array
|
| 37 |
+
*/
|
| 38 |
+
private $attributes;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* The constructor.
|
| 42 |
+
*
|
| 43 |
+
* @param object $urlData
|
| 44 |
+
*/
|
| 45 |
+
public function __construct($parsedContent, $urlData, $attributes)
|
| 46 |
+
{
|
| 47 |
+
add_action( 'amp_post_template_head', [$this, 'addScripts']);
|
| 48 |
+
|
| 49 |
+
$this->parsedContent = $parsedContent;
|
| 50 |
+
$this->urlData = $urlData;
|
| 51 |
+
$this->attributes = $attributes;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Convert the HTML for AMP compatible tag.
|
| 56 |
+
*
|
| 57 |
+
* @return string
|
| 58 |
+
*/
|
| 59 |
+
public function process()
|
| 60 |
+
{
|
| 61 |
+
// Check we have the required class
|
| 62 |
+
if (! class_exists('AMP_HTML_Utils')) {
|
| 63 |
+
return $this->parsedContent;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
$defaults = [
|
| 67 |
+
'data-width' => 100,
|
| 68 |
+
'data-height' => 100,
|
| 69 |
+
];
|
| 70 |
+
$attributes = wp_parse_args($this->attributes, $defaults);
|
| 71 |
+
|
| 72 |
+
$parsedContent = \AMP_HTML_Utils::build_tag(
|
| 73 |
+
'amp-reddit',
|
| 74 |
+
array(
|
| 75 |
+
'data-src' => $this->urlData->originalContent,
|
| 76 |
+
'layout' => 'responsive',
|
| 77 |
+
'data-embedtype' => "post",
|
| 78 |
+
'width' => $attributes['data-width'],
|
| 79 |
+
'height' => $attributes['data-height'],
|
| 80 |
+
)
|
| 81 |
+
);
|
| 82 |
+
|
| 83 |
+
return $parsedContent;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Add scripts to the output.
|
| 88 |
+
*/
|
| 89 |
+
public function addScripts()
|
| 90 |
+
{
|
| 91 |
+
if ( ! defined( 'PPEMB_REDDIT_AMP_SCRIPT_LOADED' ) ) {
|
| 92 |
+
echo '<script async custom-element="amp-reddit" src="https://cdn.ampproject.org/v0/amp-reddit-0.1.js"></script>';
|
| 93 |
+
|
| 94 |
+
define( 'PPEMB_REDDIT_AMP_SCRIPT_LOADED', 1 );
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
}
|
EmbedPress/AMP/Adapter/Twitter.php
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
namespace EmbedPress\AMP\Adapter;
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Entity that represents the embed provider for AMP.
|
| 9 |
+
*
|
| 10 |
+
* @package EmbedPress
|
| 11 |
+
* @author PressShack <help@pressshack.com>
|
| 12 |
+
* @copyright Copyright (C) 2017 PressShack. All rights reserved.
|
| 13 |
+
* @license GPLv2 or later
|
| 14 |
+
* @since 1.4.0
|
| 15 |
+
* @abstract
|
| 16 |
+
*/
|
| 17 |
+
class Twitter
|
| 18 |
+
{
|
| 19 |
+
/**
|
| 20 |
+
* @var object
|
| 21 |
+
*/
|
| 22 |
+
private $ampEmbedHandler;
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @var object
|
| 26 |
+
*/
|
| 27 |
+
private $urlData;
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
private $parsedContent;
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* @var array
|
| 37 |
+
*/
|
| 38 |
+
private $attributes;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* The constructor.
|
| 42 |
+
*
|
| 43 |
+
* @param object $urlData
|
| 44 |
+
*/
|
| 45 |
+
public function __construct($parsedContent, $urlData, $attributes)
|
| 46 |
+
{
|
| 47 |
+
if (class_exists('AMP_Twitter_Embed_Handler')) {
|
| 48 |
+
$this->ampEmbedHandler = new \AMP_Twitter_Embed_Handler;
|
| 49 |
+
|
| 50 |
+
add_action( 'amp_post_template_head', [$this, 'addScripts']);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
$this->parsedContent = $parsedContent;
|
| 54 |
+
$this->urlData = $urlData;
|
| 55 |
+
$this->attributes = $attributes;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Convert the HTML for AMP compatible tag.
|
| 60 |
+
*
|
| 61 |
+
* @return string
|
| 62 |
+
*/
|
| 63 |
+
public function process()
|
| 64 |
+
{
|
| 65 |
+
// Check we have the adapter set
|
| 66 |
+
if (! isset($this->ampEmbedHandler)) {
|
| 67 |
+
return $this->parsedContent;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
$attr = [
|
| 71 |
+
'tweet' => $this->urlData->url,
|
| 72 |
+
];
|
| 73 |
+
|
| 74 |
+
$parsedContent = $this->ampEmbedHandler->shortcode($attr);
|
| 75 |
+
|
| 76 |
+
return $parsedContent;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Add scripts to the output.
|
| 81 |
+
*/
|
| 82 |
+
public function addScripts()
|
| 83 |
+
{
|
| 84 |
+
if ( ! defined( 'PPEMB_TWITTER_AMP_SCRIPT_LOADED' ) ) {
|
| 85 |
+
echo '<script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>';
|
| 86 |
+
|
| 87 |
+
define( 'PPEMB_TWITTER_AMP_SCRIPT_LOADED', 1 );
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
}
|
EmbedPress/AMP/EmbedHandler.php
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
namespace EmbedPress\AMP;
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Entity that represents the embed modifier for AMP.
|
| 9 |
+
*
|
| 10 |
+
* @package EmbedPress
|
| 11 |
+
* @author PressShack <help@pressshack.com>
|
| 12 |
+
* @copyright Copyright (C) 2017 PressShack. All rights reserved.
|
| 13 |
+
* @license GPLv2 or later
|
| 14 |
+
* @since 1.4.0
|
| 15 |
+
* @abstract
|
| 16 |
+
*/
|
| 17 |
+
abstract class EmbedHandler
|
| 18 |
+
{
|
| 19 |
+
/**
|
| 20 |
+
* Process embeds to check if need to adapt for AMP pages. This is compatible
|
| 21 |
+
* witht the AMP plugin from Automattic.
|
| 22 |
+
*
|
| 23 |
+
* @param string $parsedContent
|
| 24 |
+
* @param object $urlData
|
| 25 |
+
* @param array $attributes
|
| 26 |
+
*
|
| 27 |
+
* @return object
|
| 28 |
+
*/
|
| 29 |
+
static function processParsedContent($parsedContent, $urlData, $attributes)
|
| 30 |
+
{
|
| 31 |
+
// Check if we don't have the AMP plugin installed to bypass
|
| 32 |
+
if (! class_exists('AMP_Base_Embed_Handler')) {
|
| 33 |
+
return $parsedContent;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
// Start processing
|
| 37 |
+
|
| 38 |
+
$handlerMap = [
|
| 39 |
+
'twitter' => '\\EmbedPress\\AMP\\Adapter\\Twitter',
|
| 40 |
+
'reddit' => '\\EmbedPress\\AMP\\Adapter\\Reddit',
|
| 41 |
+
];
|
| 42 |
+
|
| 43 |
+
$providerName = strtolower($urlData->provider_name);
|
| 44 |
+
|
| 45 |
+
// Check if we have a mapped handler
|
| 46 |
+
if (isset($urlData->provider_name) && array_key_exists($providerName, $handlerMap)) {
|
| 47 |
+
|
| 48 |
+
$className = $handlerMap[$providerName];
|
| 49 |
+
$handler = new $className($parsedContent, $urlData, $attributes);
|
| 50 |
+
|
| 51 |
+
// Modify the HTML according to the AMP embed handler
|
| 52 |
+
$parsedContent = $handler->process();
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
return $parsedContent;
|
| 56 |
+
}
|
| 57 |
+
}
|
EmbedPress/Core.php
CHANGED
|
@@ -162,6 +162,9 @@ class Core
|
|
| 162 |
unset($enqueueScriptsHookName, $plgHandlerPublicInstance);
|
| 163 |
}
|
| 164 |
|
|
|
|
|
|
|
|
|
|
| 165 |
$this->loaderInstance->run();
|
| 166 |
}
|
| 167 |
|
| 162 |
unset($enqueueScriptsHookName, $plgHandlerPublicInstance);
|
| 163 |
}
|
| 164 |
|
| 165 |
+
// Add support for embeds on AMP pages
|
| 166 |
+
add_filter('pp_embed_parsed_content', ['\EmbedPress\AMP\EmbedHandler', 'processParsedContent'], 10, 3);
|
| 167 |
+
|
| 168 |
$this->loaderInstance->run();
|
| 169 |
}
|
| 170 |
|
EmbedPress/Shortcode.php
CHANGED
|
@@ -110,6 +110,8 @@ class Shortcode
|
|
| 110 |
|
| 111 |
// Identify what service provider the shortcode's link belongs to
|
| 112 |
$serviceProvider = self::$oEmbedInstance->get_provider($content);
|
|
|
|
|
|
|
| 113 |
// Check if OEmbed was unable to detect the url service provider.
|
| 114 |
if (empty($serviceProvider)) {
|
| 115 |
// Attempt to do the same using Embera.
|
|
@@ -134,6 +136,11 @@ class Shortcode
|
|
| 134 |
// Sanitize the data
|
| 135 |
$urlData = self::sanitizeUrlData($urlData);
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
$eventResults = apply_filters('embedpress:onBeforeEmbed', $urlData);
|
| 138 |
if (empty($eventResults)) {
|
| 139 |
// EmbedPress seems unable to embed the url.
|
|
@@ -311,6 +318,8 @@ class Shortcode
|
|
| 311 |
$parsedContent = preg_replace('/\n/', '', $parsedContent);
|
| 312 |
}
|
| 313 |
|
|
|
|
|
|
|
| 314 |
if (!empty($parsedContent)) {
|
| 315 |
$embed = (object)array_merge((array)$urlData, array(
|
| 316 |
'attributes' => (object)$attributes,
|
| 110 |
|
| 111 |
// Identify what service provider the shortcode's link belongs to
|
| 112 |
$serviceProvider = self::$oEmbedInstance->get_provider($content);
|
| 113 |
+
|
| 114 |
+
|
| 115 |
// Check if OEmbed was unable to detect the url service provider.
|
| 116 |
if (empty($serviceProvider)) {
|
| 117 |
// Attempt to do the same using Embera.
|
| 136 |
// Sanitize the data
|
| 137 |
$urlData = self::sanitizeUrlData($urlData);
|
| 138 |
|
| 139 |
+
// Stores the original content
|
| 140 |
+
if (is_object($urlData)) {
|
| 141 |
+
$urlData->originalContent = $content;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
$eventResults = apply_filters('embedpress:onBeforeEmbed', $urlData);
|
| 145 |
if (empty($eventResults)) {
|
| 146 |
// EmbedPress seems unable to embed the url.
|
| 318 |
$parsedContent = preg_replace('/\n/', '', $parsedContent);
|
| 319 |
}
|
| 320 |
|
| 321 |
+
$parsedContent = apply_filters('pp_embed_parsed_content', $parsedContent, $urlData, $attributes);
|
| 322 |
+
|
| 323 |
if (!empty($parsedContent)) {
|
| 324 |
$embed = (object)array_merge((array)$urlData, array(
|
| 325 |
'attributes' => (object)$attributes,
|
assets/css/embedpress.css
CHANGED
|
@@ -106,3 +106,7 @@
|
|
| 106 |
position: absolute;
|
| 107 |
bottom: 0;
|
| 108 |
}
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
position: absolute;
|
| 107 |
bottom: 0;
|
| 108 |
}
|
| 109 |
+
|
| 110 |
+
.ose-mixcloud.responsive iframe {
|
| 111 |
+
width: 100%;
|
| 112 |
+
}
|
embedpress.php
CHANGED
|
@@ -12,7 +12,7 @@
|
|
| 12 |
* @embedpress
|
| 13 |
* Plugin Name: PublishPress Embeds
|
| 14 |
* Plugin URI: https://pressshack.com/embedpress/
|
| 15 |
-
* Version: 2.0.
|
| 16 |
* Description: WordPress supports around 35 embed sources, but PublishPress Embeds adds over 40 more, including Facebook, Google Maps, Google Docs, UStream! Just use the URL!
|
| 17 |
* Author: PressShack
|
| 18 |
* Author URI: http://pressshack.com
|
| 12 |
* @embedpress
|
| 13 |
* Plugin Name: PublishPress Embeds
|
| 14 |
* Plugin URI: https://pressshack.com/embedpress/
|
| 15 |
+
* Version: 2.0.1
|
| 16 |
* Description: WordPress supports around 35 embed sources, but PublishPress Embeds adds over 40 more, including Facebook, Google Maps, Google Docs, UStream! Just use the URL!
|
| 17 |
* Author: PressShack
|
| 18 |
* Author URI: http://pressshack.com
|
includes.php
CHANGED
|
@@ -22,7 +22,7 @@ if (!defined('EMBEDPRESS_PLG_NAME')) {
|
|
| 22 |
}
|
| 23 |
|
| 24 |
if (!defined('EMBEDPRESS_PLG_VERSION')) {
|
| 25 |
-
define('EMBEDPRESS_PLG_VERSION', "2.0.
|
| 26 |
}
|
| 27 |
|
| 28 |
if (!defined('EMBEDPRESS_ROOT')) {
|
| 22 |
}
|
| 23 |
|
| 24 |
if (!defined('EMBEDPRESS_PLG_VERSION')) {
|
| 25 |
+
define('EMBEDPRESS_PLG_VERSION', "2.0.1");
|
| 26 |
}
|
| 27 |
|
| 28 |
if (!defined('EMBEDPRESS_ROOT')) {
|
readme.txt
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
=== PublishPress Embeds – Embed Google Docs, Vimeo and Wistia videos, Giphy and Imgur photos, and more ===
|
| 2 |
-
Contributors: PressShack
|
| 3 |
Tags: YouTube, Google, Facebook, Wistia, Vimeo
|
| 4 |
Requires at least: 4.5
|
| 5 |
Tested up to: 4.8
|
| 6 |
-
Stable tag: 2.0.
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 9 |
|
|
@@ -182,6 +182,13 @@ Not at all. You can set up everything your team needs without any coding knowled
|
|
| 182 |
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
| 183 |
and this project adheres to [Semantic Versioning](http://semver.org/).
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
= [2.0.0] - 2017-08-02 =
|
| 186 |
|
| 187 |
* Changed:
|
| 1 |
=== PublishPress Embeds – Embed Google Docs, Vimeo and Wistia videos, Giphy and Imgur photos, and more ===
|
| 2 |
+
Contributors: PressShack, andergmartins
|
| 3 |
Tags: YouTube, Google, Facebook, Wistia, Vimeo
|
| 4 |
Requires at least: 4.5
|
| 5 |
Tested up to: 4.8
|
| 6 |
+
Stable tag: 2.0.1
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 9 |
|
| 182 |
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
| 183 |
and this project adheres to [Semantic Versioning](http://semver.org/).
|
| 184 |
|
| 185 |
+
= [2.0.1] - 2017-10-16 =
|
| 186 |
+
|
| 187 |
+
* Fixed:
|
| 188 |
+
* Fixed responsive support for Mixcloud embeds;
|
| 189 |
+
* Fixed scripts related to AMP avoiding to load them more than once;
|
| 190 |
+
* Fixed custom attributes for Reddit on AMP pages;
|
| 191 |
+
|
| 192 |
= [2.0.0] - 2017-08-02 =
|
| 193 |
|
| 194 |
* Changed:
|
