PluginProbe
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.2.9
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.2.9
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 / Codepoints.php
Codepoints.php
82 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Codepoints.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 * Codepoints Provider
19 * @link https://codepoints.net
20 */
21 class Codepoints extends ProviderAdapter implements ProviderInterface
22 {
23 /** inline {@inheritdoc} */
24 protected $endpoint = 'https://codepoints.net/api/v1/oembed?format=json';
25
26 /** inline {@inheritdoc} */
27 protected static $hosts = [
28 'codepoints.net'
29 ];
30
31 /** inline {@inheritdoc} */
32 protected $httpsSupport = true;
33
34 /** inline {@inheritdoc} */
35 public function validateUrl(Url $url)
36 {
37 return (bool) (preg_match('~codepoints\.net/U\+(?:[^/]+)$~i', (string) $url));
38 }
39
40 /** inline {@inheritdoc} */
41 public function normalizeUrl(Url $url)
42 {
43 $url->convertToHttps();
44 $url->removeQueryString();
45 $url->removeLastSlash();
46 return $url;
47 }
48
49 /** inline {@inheritdoc} */
50 public function modifyResponse(array $response = [])
51 {
52 // The oembed html response returns http:// but it is capable of handling https://
53 if (!empty($response['html'])) {
54 $response['html'] = str_ireplace('http://', 'https://', $response['html']);
55 }
56
57 return $response;
58 }
59
60 /** inline {@inheritdoc} */
61 public function getFakeResponse()
62 {
63 preg_match('~/U\+([^/]+)$~i', $this->url, $m);
64
65 $embedUrl = $this->url . '?embed';
66
67 $attr = [];
68 $attr[] = 'src="' . $embedUrl . '"';
69 $attr[] = 'style="width: 64px; height: 640px; border: 1px solid #444;"';
70
71 return [
72 'type' => 'rich',
73 'provider_name' => 'Codepoints.net',
74 'provider_url' => 'http://codepoints.net/',
75 'thumbnail_url' => 'http://codepoints.net/api/v1/glyph/' . $m['1'],
76 'title' => 'Unknown title',
77 'html' => '<iframe ' . implode(' ', $attr). '></iframe>',
78 ];
79 }
80
81 }
82