PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.4.8
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.4.8
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / EmbedPress / Providers / Wistia.php
embedpress / EmbedPress / Providers Last commit date
TemplateLayouts 9 months ago AirTable.php 1 year ago Boomplay.php 1 year ago Calendly.php 2 years ago Canva.php 1 year ago FITE.php 1 year ago GettyImages.php 9 months ago Giphy.php 2 years ago GitHub.php 3 years ago GoogleCalendar.php 8 months ago GoogleDocs.php 2 years ago GoogleDrive.php 2 years ago GoogleMaps.php 2 years ago GooglePhotos.php 7 months ago Gumroad.php 2 years ago InstagramFeed.php 6 months ago LinkedIn.php 2 years ago Meetup.php 6 months ago NRKRadio.php 2 years ago OneDrive.php 11 months ago OpenSea.php 9 months ago SelfHosted.php 2 years ago Spreaker.php 1 year ago TikTok.php 2 years ago Twitch.php 2 years ago Wistia.php 6 months ago Wrapper.php 3 years ago X.php 2 years ago Youtube.php 9 months ago index.html 7 years ago
Wistia.php
333 lines
1 <?php
2
3 namespace EmbedPress\Providers;
4
5 use Embera\Provider\ProviderAdapter;
6 use Embera\Provider\ProviderInterface;
7 use Embera\Url;
8
9 (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
10
11 /**
12 * Wistia provider for EmbedPress.
13 *
14 * @package EmbedPress
15 * @subpackage EmbedPress/Providers
16 * @author EmbedPress
17 * @license GPLv3 or later
18 * @since 1.0.0
19 */
20 class Wistia extends ProviderAdapter implements ProviderInterface
21 {
22 protected static $hosts = [
23 '*.wistia.com',
24 'wistia.com'
25 ];
26
27 /** inline {@inheritdoc} */
28 protected $allowedParams = [
29 'maxwidth',
30 'maxheight',
31 'wstarttime',
32 'wautoplay',
33 'scheme',
34 'captions',
35 'playbutton',
36 'smallplaybutton',
37 'playbar',
38 'resumable',
39 'wistiafocus',
40 'volumecontrol',
41 'volume',
42 'rewind',
43 'wfullscreen',
44 ];
45
46
47 /** inline {@inheritdoc} */
48 protected $httpsSupport = true;
49
50 public function getAllowedParams()
51 {
52 return $this->allowedParams;
53 }
54
55 /** inline {@inheritdoc} */
56 protected $responsiveSupport = true;
57
58 public function __construct($url, array $config = [])
59 {
60 parent::__construct($url, $config);
61 add_filter('embedpress_render_dynamic_content', [$this, 'fakeDynamicResponse'], 10, 2);
62 }
63
64 /**
65 * Validates if the URL belongs to Wistia.
66 *
67 * @param Url $url
68 * @return bool
69 */
70 public function validateUrl(Url $url)
71 {
72 $urlString = (string) $url;
73
74
75 return (bool) (
76 preg_match('~(?:\w+\.)?wistia\.com/embed/(iframe|playlists)/([^/]+)~i', $urlString) ||
77 preg_match('~(?:\w+\.)?wistia\.com/medias/([^/]+)~i', $urlString)
78 );
79 }
80
81 public function getVideoIDFromURL($url)
82 {
83 // https://fast.wistia.com/embed/medias/xf1edjzn92.jsonp
84 // https://ostraining-1.wistia.com/medias/xf1edjzn92
85 preg_match('#\/medias\\\?\/([a-z0-9]+)\.?#i', $url, $matches);
86
87 $id = false;
88 if (isset($matches[1])) {
89 $id = $matches[1];
90 }
91
92 return $id;
93 }
94
95 public function enhance_wistia()
96 {
97
98 $options = $this->getParams();
99
100 $embedOptions = new \stdClass;
101 $embedOptions->videoFoam = false;
102
103 // Fullscreen
104 $embedOptions->fullscreenButton =
105 isset($options['wfullscreen']) && (bool) $options['wfullscreen'];
106
107 // Playbar
108 $embedOptions->playbar =
109 isset($options['playbar']) && (bool) $options['playbar'];
110
111 // Small play button
112 $embedOptions->smallPlayButton =
113 isset($options['smallplaybutton']) && (bool) $options['smallplaybutton'];
114
115 // Autoplay
116 $embedOptions->autoPlay =
117 isset($options['wautoplay']) && (bool) $options['wautoplay'];
118
119 // Start time
120 if (!empty($options['wstarttime'])) {
121 $embedOptions->time = (int) $options['wstarttime'];
122 }
123
124 // Player color
125 if (!empty($options['scheme'])) {
126 $embedOptions->playerColor = $options['scheme'];
127 }
128
129 // Plugins
130 $pluginsBaseURL = plugins_url(
131 'assets/js/wistia/min',
132 dirname(__DIR__) . '/embedpress-Wistia.php'
133 );
134
135 $pluginList = [];
136
137 // Resumable
138 $isResumableEnabled = !empty($options['resumable']);
139 if ($isResumableEnabled) {
140 $pluginList['resumable'] = [
141 'src' => $pluginsBaseURL . '/resumable.min.js',
142 'async' => false
143 ];
144 }
145
146 // Autoplay + resumable fix
147 if ($embedOptions->autoPlay && $isResumableEnabled) {
148 $pluginList['fixautoplayresumable'] = [
149 'src' => $pluginsBaseURL . '/fixautoplayresumable.min.js'
150 ];
151 }
152
153 // Focus
154 if (isset($options['wistiafocus'])) {
155 $pluginList['dimthelights'] = [
156 'src' => $pluginsBaseURL . '/dimthelights.min.js',
157 'autoDim' => (bool) $options['wistiafocus']
158 ];
159 $embedOptions->focus = (bool) $options['wistiafocus'];
160 }
161
162 // Rewind
163 if (!empty($options['rewind'])) {
164 $embedOptions->rewindTime = 10;
165
166 $pluginList['rewind'] = [
167 'src' => $pluginsBaseURL . '/rewind.min.js'
168 ];
169 }
170
171 $embedOptions->plugin = $pluginList;
172 $embedOptions = json_encode($embedOptions);
173
174 // Video ID
175 $videoId = $this->getVideoIDFromURL($options['url']);
176 $shortVideoId = substr($videoId, 0, 3);
177
178 $class = [
179 'wistia_embed',
180 'wistia_async_' . $videoId
181 ];
182
183 $width = $options['width'] ?? 640;
184 $height = $options['height'] ?? 360;
185
186 $attribs = [
187 sprintf('id="wistia_%s"', $videoId),
188 sprintf('class="%s"', implode(' ', $class)),
189 sprintf('style="width:%spx; height:%spx;"', $width, $height)
190 ];
191
192 $html = "<div class=\"embedpress-wrapper ose-wistia ose-uid-{$videoId} responsive we\">";
193 $html .= '<script src="https://fast.wistia.com/assets/external/E-v1.js" async></script>';
194 $html .= "<script>window._wq = window._wq || []; _wq.push({\"{$shortVideoId}\": {$embedOptions}});</script>";
195 $html .= '<div ' . implode(' ', $attribs) . '></div>';
196 $html .= '</div>';
197
198 return $html;
199 }
200
201 public function fakeDynamicResponse($embed, $options = [])
202 {
203
204
205 $embedOptions = new \stdClass;
206 $embedOptions->videoFoam = false;
207
208 // Fullscreen
209 $embedOptions->fullscreenButton =
210 isset($options['wfullscreen']) && (bool) $options['wfullscreen'];
211
212 // Playbar
213 $embedOptions->playbar =
214 isset($options['playbar']) && (bool) $options['playbar'];
215
216 // Small play button
217 $embedOptions->smallPlayButton =
218 isset($options['smallplaybutton']) && (bool) $options['smallplaybutton'];
219
220 // Autoplay
221 $embedOptions->autoPlay =
222 isset($options['wautoplay']) && (bool) $options['wautoplay'];
223
224 // Start time
225 if (!empty($options['wstarttime'])) {
226 $embedOptions->time = (int) $options['wstarttime'];
227 }
228
229 // Player color
230 if (!empty($options['scheme'])) {
231 $embedOptions->playerColor = $options['scheme'];
232 }
233
234 // Plugins
235 $pluginsBaseURL = plugins_url(
236 'assets/js/wistia/min',
237 dirname(__DIR__) . '/embedpress-Wistia.php'
238 );
239
240 $pluginList = [];
241
242 // Resumable
243 $isResumableEnabled = !empty($options['resumable']);
244 if ($isResumableEnabled) {
245 $pluginList['resumable'] = [
246 'src' => $pluginsBaseURL . '/resumable.min.js',
247 'async' => false
248 ];
249 }
250
251 // Autoplay + resumable fix
252 if ($embedOptions->autoPlay && $isResumableEnabled) {
253 $pluginList['fixautoplayresumable'] = [
254 'src' => $pluginsBaseURL . '/fixautoplayresumable.min.js'
255 ];
256 }
257
258 // Focus
259 if (isset($options['wistiafocus'])) {
260 $pluginList['dimthelights'] = [
261 'src' => $pluginsBaseURL . '/dimthelights.min.js',
262 'autoDim' => (bool) $options['wistiafocus']
263 ];
264 $embedOptions->focus = (bool) $options['wistiafocus'];
265 }
266
267 // Rewind
268 if (!empty($options['rewind'])) {
269 $embedOptions->rewindTime = 10;
270
271 $pluginList['rewind'] = [
272 'src' => $pluginsBaseURL . '/rewind.min.js'
273 ];
274 }
275
276 $embedOptions->plugin = $pluginList;
277 $embedOptions = json_encode($embedOptions);
278
279 // Video ID
280 $videoId = $this->getVideoIDFromURL($options['url']);
281 $shortVideoId = substr($videoId, 0, 3);
282
283 $class = [
284 'wistia_embed',
285 'wistia_async_' . $videoId
286 ];
287
288 $attribs = [
289 sprintf('id="wistia_%s"', $videoId),
290 sprintf('class="%s"', implode(' ', $class)),
291 sprintf('style="width:%spx; height:%spx;"', $options['width'], $options['height'])
292 ];
293
294
295 $html = "<div class=\"embedpress-wrapper ose-wistia ose-uid-{$videoId} responsive we\">";
296 $html .= '<script src="https://fast.wistia.com/assets/external/E-v1.js" async></script>';
297 $html .= "<script>window._wq = window._wq || []; _wq.push({\"{$shortVideoId}\": {$embedOptions}});</script>";
298 $html .= '<div ' . implode(' ', $attribs) . '></div>';
299 $html .= '</div>';
300
301 return $html;
302 }
303
304
305 /**
306 * Generates a fake oEmbed response.
307 *
308 * @return array
309 */
310 public function fakeResponse()
311 {
312
313 return [
314 'type' => 'rich',
315 'provider_name' => 'Wistia',
316 'provider_url' => 'https://wistia.com',
317 'title' => 'Wistia',
318 'html' => $this->enhance_wistia(),
319 ];
320 }
321
322 /**
323 * Fallback for modifyResponse, returns fakeResponse.
324 *
325 * @param array $response
326 * @return array
327 */
328 public function modifyResponse(array $response = [])
329 {
330 return $this->fakeResponse();
331 }
332 }
333