EmbedPress – Embed Google Docs, YouTube, Maps, Vimeo, Wistia Videos & Upload PDF, PPT in Gutenberg & Elementor - Version 2.1.4

Version Description

Download this release

Release Info

Developer andergmartins
Plugin Icon wp plugin EmbedPress – Embed Google Docs, YouTube, Maps, Vimeo, Wistia Videos & Upload PDF, PPT in Gutenberg & Elementor
Version 2.1.4
Comparing to
See all releases

Code changes from version 2.1.3 to 2.1.4

EmbedPress/Providers/Twitch.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  namespace EmbedPress\Providers;
3
 
4
- use \Embera\Adapters\Service as EmberaService;
5
 
6
  (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
7
 
@@ -25,7 +25,7 @@ class Twitch extends EmberaService
25
  *
26
  * @var string
27
  */
28
- private $urlRegexPattern = '/http[s]?:\/\/(?:www\.|clips\.)twitch\.tv\/([0-9a-zA-Z\-\_]+)\/?(chat\/?$)?/';
29
 
30
  /**
31
  * Method that verifies if the embed URL belongs to Twitch.
@@ -39,6 +39,30 @@ class Twitch extends EmberaService
39
  return preg_match($this->urlRegexPattern, $this->url);
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  /**
43
  * This method fakes an Oembed response.
44
  *
@@ -48,23 +72,44 @@ class Twitch extends EmberaService
48
  */
49
  public function fakeResponse()
50
  {
51
- $url = $this->getUrl();
 
 
 
52
 
53
  if (preg_match("{$this->urlRegexPattern}i", $url, $matches)) {
54
  $channelName = $matches[1];
55
- $renderChatInsteadOfStream = (count($matches) > 2 && strtolower($matches[2]) === "chat");
56
- $isClip = stristr($url, 'clips.twitch.tv');
57
-
58
- if ($isClip !== False) {
59
- $providerUrl = 'https://clips.twitch.tv';
60
- $html = '<iframe src="https://clips.twitch.tv/embed?clip=' . $channelName . '&autoplay=false" height="{height}" width="{width}" scrolling="no" frameborder="0" allowfullscreen="true"></iframe>';
61
- } else {
62
- $providerUrl = 'https://www.twitch.tv';
63
- $html = '<iframe src="https://www.twitch.tv/' . $channelName . '/' . ($renderChatInsteadOfStream ? 'chat' : 'embed') . '" height="{height}" width="{width}" scrolling="no" frameborder="0" allowfullscreen="true"></iframe>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
 
 
66
  $response = array(
67
- 'type' => ($renderChatInsteadOfStream ? 'rich' : 'video'),
68
  'provider_name' => 'Twitch',
69
  'provider_url' => $providerUrl,
70
  'url' => $url,
1
  <?php
2
  namespace EmbedPress\Providers;
3
 
4
+ use Embera\Adapters\Service as EmberaService;
5
 
6
  (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
7
 
25
  *
26
  * @var string
27
  */
28
+ private $urlRegexPattern = '/http[s]?:\/\/(?:www\.|clips\.)twitch\.tv\/([0-9a-zA-Z\-\_]+)\/?(chat\/?$|[0-9a-z\-\_]*)?/';
29
 
30
  /**
31
  * Method that verifies if the embed URL belongs to Twitch.
39
  return preg_match($this->urlRegexPattern, $this->url);
40
  }
41
 
42
+ /**
43
+ * Return the type of the embed based on the URL.
44
+ *
45
+ * @param $url
46
+ *
47
+ * @return string
48
+ */
49
+ protected function getType($url)
50
+ {
51
+ if ( stristr($url, 'clips.twitch.tv') ) {
52
+ return 'clip';
53
+ }
54
+
55
+ if ( stristr($url, '/videos/') ) {
56
+ return 'video';
57
+ }
58
+
59
+ if ( preg_match('#/chat$#', $url) ) {
60
+ return 'chat';
61
+ }
62
+
63
+ return 'channel';
64
+ }
65
+
66
  /**
67
  * This method fakes an Oembed response.
68
  *
72
  */
73
  public function fakeResponse()
74
  {
75
+ $url = $this->getUrl();
76
+ $providerUrl = 'https://twitch.tv';
77
+ $html = '';
78
+ $src = '';
79
 
80
  if (preg_match("{$this->urlRegexPattern}i", $url, $matches)) {
81
  $channelName = $matches[1];
82
+
83
+ $type = $this->getType($url);
84
+
85
+ // Clip, channel, chat, collection, or video?
86
+ switch ($type) {
87
+ case 'clip':
88
+ $src = 'https://clips.twitch.tv/embed?clip=' . $channelName . '&autoplay=false';
89
+ $attrs = 'scrolling="no" frameborder="0" allowfullscreen="true"';
90
+ break;
91
+
92
+ case 'video':
93
+ $channelName = $matches[2];
94
+ $src = 'https://player.twitch.tv/?video=' . $channelName;
95
+ $attrs = 'scrolling="no" frameborder="0" allowfullscreen="true"';
96
+ break;
97
+
98
+ case 'channel':
99
+ $src = 'https://player.twitch.tv/?channel=' . $channelName;
100
+ $attrs = 'scrolling="no" frameborder="0" allowfullscreen="true"';
101
+ break;
102
+
103
+ case 'chat':
104
+ $src = 'http://www.twitch.tv/embed/' . $channelName . '/chat';
105
+ $attrs = 'scrolling="yes" frameborder="0" allowfullscreen="true" id="' . $channelName . '"';
106
+ break;
107
  }
108
 
109
+ $html = '<iframe src="' . $src . '" height="{height}" width="{width}" ' . $attrs . '></iframe>';
110
+
111
  $response = array(
112
+ 'type' => $type,
113
  'provider_name' => 'Twitch',
114
  'provider_url' => $providerUrl,
115
  'url' => $url,
assets/js/preview.js CHANGED
@@ -563,8 +563,6 @@
563
  var contentWrapper = $($content).clone();
564
  contentWrapper.html('');
565
 
566
- var dom = editorInstance.dom;
567
-
568
  $wrapper.removeClass('embedpress_placeholder');
569
 
570
  $wrapper.append(contentWrapper);
@@ -579,7 +577,8 @@
579
  iframe.class = "wpview-sandbox";
580
  iframe.style.width = '100%';
581
 
582
- dom.add(contentWrapper, iframe);
 
583
  var iframeWindow = iframe.contentWindow;
584
  // Content failed to load.
585
  if (!iframeWindow) {
@@ -1273,7 +1272,7 @@
1273
  }
1274
  }
1275
  });
1276
-
1277
  var embedWidth = (((embedItem && embedItem.width()) || $embedInnerWrapper.data('width')) || $embedInnerWrapper.width()) || "";
1278
  var embedHeight = (((embedItem && embedItem.height()) || $embedInnerWrapper.data('height')) || $embedInnerWrapper.height()) || "";
1279
 
563
  var contentWrapper = $($content).clone();
564
  contentWrapper.html('');
565
 
 
 
566
  $wrapper.removeClass('embedpress_placeholder');
567
 
568
  $wrapper.append(contentWrapper);
577
  iframe.class = "wpview-sandbox";
578
  iframe.style.width = '100%';
579
 
580
+ contentWrapper.append(iframe);
581
+
582
  var iframeWindow = iframe.contentWindow;
583
  // Content failed to load.
584
  if (!iframeWindow) {
1272
  }
1273
  }
1274
  });
1275
+
1276
  var embedWidth = (((embedItem && embedItem.width()) || $embedInnerWrapper.data('width')) || $embedInnerWrapper.width()) || "";
1277
  var embedHeight = (((embedItem && embedItem.height()) || $embedInnerWrapper.data('height')) || $embedInnerWrapper.height()) || "";
1278
 
embedpress.php CHANGED
@@ -5,7 +5,7 @@
5
  * 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!
6
  * Author: EmbedPress
7
  * Author URI: http://embedpress.com
8
- * Version: 2.1.3
9
  * Text Domain: embedpress
10
  * Domain Path: /languages
11
  *
5
  * 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!
6
  * Author: EmbedPress
7
  * Author URI: http://embedpress.com
8
+ * Version: 2.1.4
9
  * Text Domain: embedpress
10
  * Domain Path: /languages
11
  *
readme.txt CHANGED
@@ -5,7 +5,7 @@ Author URI: https://embedpress.com
5
  Tags: YouTube, Google, Facebook, Wistia, Vimeo
6
  Requires at least: 4.6
7
  Tested up to: 4.9.4
8
- Stable tag: 2.1.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -184,6 +184,13 @@ Not at all. You can set up everything your team needs without any coding knowled
184
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
185
  and this project adheres to [Semantic Versioning](http://semver.org/).
186
 
 
 
 
 
 
 
 
187
  = [2.1.3] - 2018-06-12 =
188
 
189
  *Fixed:*
5
  Tags: YouTube, Google, Facebook, Wistia, Vimeo
6
  Requires at least: 4.6
7
  Tested up to: 4.9.4
8
+ Stable tag: 2.1.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
184
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
185
  and this project adheres to [Semantic Versioning](http://semver.org/).
186
 
187
+ = [2.1.4] - 2018-06-27 =
188
+
189
+ *Fixed:*
190
+
191
+ * Fixed embed preview after recent TinyMCE updates;
192
+ * Fixed Twitch embeds after their new URL structure;
193
+
194
  = [2.1.3] - 2018-06-12 =
195
 
196
  *Fixed:*