PluginProbe
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 3.8.5
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v3.8.5
4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 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 All 189 releases
embedpress / vendor / wpdevelopers / embera / src / Embera / Provider / SmashNotes.php
SmashNotes.php
92 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * SmashNotes.php
4 *
5 * @package Embera
6 * @author Michael Pratt <yo@michael-pratt.com>
7 * @link http://www.michael-pratt.com/
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13 namespace Embera\Provider;
14
15 use Embera\Url;
16
17 /**
18 * SmashNotes Provider
19 * @link https://smashnotes.com
20 */
21 class SmashNotes extends ProviderAdapter implements ProviderInterface
22 {
23 /** inline {@inheritdoc} */
24 protected $endpoint = 'https://smashnotes.com/services/oembed?format=json';
25
26 /** inline {@inheritdoc} */
27 protected static $hosts = [
28 'smashnotes.com'
29 ];
30
31 /** inline {@inheritdoc} */
32 protected $allowedParams = [ 'maxwidth', 'maxheight' ];
33
34 /** inline {@inheritdoc} */
35 protected $httpsSupport = true;
36
37 /** inline {@inheritdoc} */
38 protected $responsiveSupport = false;
39
40 /** inline {@inheritdoc} */
41 public function validateUrl(Url $url)
42 {
43 return (bool) (
44 preg_match('~smashnotes\.com/p/([^/]+)~i', (string) $url) ||
45 preg_match('~smashnotes\.com/p/([^/]+)/e/([^/]+)~i', (string) $url)
46 );
47 }
48
49 /** inline {@inheritdoc} */
50 public function normalizeUrl(Url $url)
51 {
52 $url->convertToHttps();
53 $url->removeQueryString();
54 $url->removeLastSlash();
55
56 return $url;
57 }
58
59 /** inline {@inheritdoc} */
60 public function modifyResponse(array $response = [])
61 {
62 if (!empty($response['html'])) {
63 $response['html'] = preg_replace('~title=\'(.+)\'~i', 'title=""', $response['html']);
64 }
65
66 return $response;
67 }
68
69 /** inline {@inheritdoc} */
70 public function getFakeResponse()
71 {
72 $embedUrl = $this->url . '/embed/';
73
74 $attr = [];
75 $attr[] = 'src="' . $embedUrl . '"';
76 $attr[] = 'width="{width}"';
77 $attr[] = 'height="{height}"';
78 $attr[] = 'frameborder="0"';
79 $attr[] = 'scrolling="no"';
80 $attr[] = 'title=""';
81
82 return [
83 'type' => 'rich',
84 'provider_name' => 'SmashNotes',
85 'provider_url' => 'https://smashnotes.com',
86 'title' => 'Unknown title',
87 'html' => '<iframe ' . implode(' ', $attr). '></iframe>',
88 ];
89 }
90
91 }
92