1 <?php |
1 <?php |
2 /** |
2 /** |
3 * API for fetching the HTML to embed remote content based on a provided URL. |
3 * API for fetching the HTML to embed remote content based on a provided URL |
4 * Used internally by the {@link WP_Embed} class, but is designed to be generic. |
4 * |
|
5 * Used internally by the WP_Embed class, but is designed to be generic. |
5 * |
6 * |
6 * @link https://codex.wordpress.org/oEmbed oEmbed Codex Article |
7 * @link https://codex.wordpress.org/oEmbed oEmbed Codex Article |
7 * @link http://oembed.com/ oEmbed Homepage |
8 * @link http://oembed.com/ oEmbed Homepage |
8 * |
9 * |
9 * @package WordPress |
10 * @package WordPress |
10 * @subpackage oEmbed |
11 * @subpackage oEmbed |
11 */ |
12 */ |
12 |
13 |
13 /** |
14 /** |
14 * oEmbed class. |
15 * Core class used to implement oEmbed functionality. |
15 * |
16 * |
16 * @package WordPress |
|
17 * @subpackage oEmbed |
|
18 * @since 2.9.0 |
17 * @since 2.9.0 |
19 */ |
18 */ |
20 class WP_oEmbed { |
19 class WP_oEmbed { |
|
20 |
|
21 /** |
|
22 * A list of oEmbed providers. |
|
23 * |
|
24 * @since 2.9.0 |
|
25 * @var array |
|
26 */ |
21 public $providers = array(); |
27 public $providers = array(); |
|
28 |
|
29 /** |
|
30 * A list of an early oEmbed providers. |
|
31 * |
|
32 * @since 4.0.0 |
|
33 * @static |
|
34 * @var array |
|
35 */ |
22 public static $early_providers = array(); |
36 public static $early_providers = array(); |
23 |
37 |
24 private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_body' ); |
38 /** |
25 |
39 * A list of private/protected methods, used for backward compatibility. |
26 /** |
40 * |
27 * Constructor |
41 * @since 4.2.0 |
|
42 * @var array |
|
43 */ |
|
44 private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_xml_body' ); |
|
45 |
|
46 /** |
|
47 * Constructor. |
28 * |
48 * |
29 * @since 2.9.0 |
49 * @since 2.9.0 |
30 */ |
50 */ |
31 public function __construct() { |
51 public function __construct() { |
|
52 $host = urlencode( home_url() ); |
32 $providers = array( |
53 $providers = array( |
33 '#http://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), |
54 '#https?://((m|www)\.)?youtube\.com/watch.*#i' => array( 'https://www.youtube.com/oembed', true ), |
34 '#https://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), |
55 '#https?://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'https://www.youtube.com/oembed', true ), |
35 '#http://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed', true ), |
56 '#https?://youtu\.be/.*#i' => array( 'https://www.youtube.com/oembed', true ), |
36 '#https://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), |
57 '#https?://(.+\.)?vimeo\.com/.*#i' => array( 'https://vimeo.com/api/oembed.{format}', true ), |
37 '#http://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed', true ), |
58 '#https?://(www\.)?dailymotion\.com/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ), |
38 '#https://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), |
59 '#https?://dai\.ly/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ), |
39 'http://blip.tv/*' => array( 'http://blip.tv/oembed/', false ), |
60 '#https?://(www\.)?flickr\.com/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ), |
40 '#https?://(.+\.)?vimeo\.com/.*#i' => array( 'http://vimeo.com/api/oembed.{format}', true ), |
61 '#https?://flic\.kr/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ), |
41 '#https?://(www\.)?dailymotion\.com/.*#i' => array( 'http://www.dailymotion.com/services/oembed', true ), |
62 '#https?://(.+\.)?smugmug\.com/.*#i' => array( 'https://api.smugmug.com/services/oembed/', true ), |
42 'http://dai.ly/*' => array( 'http://www.dailymotion.com/services/oembed', false ), |
63 '#https?://(www\.)?hulu\.com/watch/.*#i' => array( 'http://www.hulu.com/api/oembed.{format}', true ), |
43 '#https?://(www\.)?flickr\.com/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ), |
64 'http://i*.photobucket.com/albums/*' => array( 'http://api.photobucket.com/oembed', false ), |
44 '#https?://flic\.kr/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ), |
65 'http://gi*.photobucket.com/groups/*' => array( 'http://api.photobucket.com/oembed', false ), |
45 '#https?://(.+\.)?smugmug\.com/.*#i' => array( 'http://api.smugmug.com/services/oembed/', true ), |
66 '#https?://(www\.)?scribd\.com/doc/.*#i' => array( 'https://www.scribd.com/services/oembed', true ), |
46 '#https?://(www\.)?hulu\.com/watch/.*#i' => array( 'http://www.hulu.com/api/oembed.{format}', true ), |
67 '#https?://wordpress\.tv/.*#i' => array( 'https://wordpress.tv/oembed/', true ), |
47 'http://i*.photobucket.com/albums/*' => array( 'http://photobucket.com/oembed', false ), |
68 '#https?://(.+\.)?polldaddy\.com/.*#i' => array( 'https://polldaddy.com/oembed/', true ), |
48 'http://gi*.photobucket.com/groups/*' => array( 'http://photobucket.com/oembed', false ), |
69 '#https?://poll\.fm/.*#i' => array( 'https://polldaddy.com/oembed/', true ), |
49 '#https?://(www\.)?scribd\.com/doc/.*#i' => array( 'http://www.scribd.com/services/oembed', true ), |
70 '#https?://(www\.)?funnyordie\.com/videos/.*#i' => array( 'http://www.funnyordie.com/oembed', true ), |
50 '#https?://wordpress.tv/.*#i' => array( 'http://wordpress.tv/oembed/', true ), |
71 '#https?://(www\.)?twitter\.com/\w{1,15}/status(es)?/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
51 '#https?://(.+\.)?polldaddy\.com/.*#i' => array( 'https://polldaddy.com/oembed/', true ), |
72 '#https?://(www\.)?twitter\.com/\w{1,15}$#i' => array( 'https://publish.twitter.com/oembed', true ), |
52 '#https?://poll\.fm/.*#i' => array( 'https://polldaddy.com/oembed/', true ), |
73 '#https?://(www\.)?twitter\.com/\w{1,15}/likes$#i' => array( 'https://publish.twitter.com/oembed', true ), |
53 '#https?://(www\.)?funnyordie\.com/videos/.*#i' => array( 'http://www.funnyordie.com/oembed', true ), |
74 '#https?://(www\.)?twitter\.com/\w{1,15}/lists/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
54 '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i' => array( 'https://api.twitter.com/1/statuses/oembed.{format}', true ), |
75 '#https?://(www\.)?twitter\.com/\w{1,15}/timelines/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
55 '#https?://vine.co/v/.*#i' => array( 'https://vine.co/oembed.{format}', true ), |
76 '#https?://(www\.)?twitter\.com/i/moments/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
56 '#https?://(www\.)?soundcloud\.com/.*#i' => array( 'http://soundcloud.com/oembed', true ), |
77 '#https?://(www\.)?soundcloud\.com/.*#i' => array( 'https://soundcloud.com/oembed', true ), |
57 '#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ), |
78 '#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ), |
58 '#https?://instagr(\.am|am\.com)/p/.*#i' => array( 'https://api.instagram.com/oembed', true ), |
79 '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' => array( 'https://api.instagram.com/oembed', true ), |
59 '#https?://(www\.)?rdio\.com/.*#i' => array( 'http://www.rdio.com/api/oembed/', true ), |
80 '#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ), |
60 '#https?://rd\.io/x/.*#i' => array( 'http://www.rdio.com/api/oembed/', true ), |
81 '#https?://(.+\.)?imgur\.com/.*#i' => array( 'https://api.imgur.com/oembed', true ), |
61 '#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ), |
82 '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array( 'https://api.meetup.com/oembed', true ), |
62 '#https?://(.+\.)?imgur\.com/.*#i' => array( 'http://api.imgur.com/oembed', true ), |
83 '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'https://issuu.com/oembed_wp', true ), |
63 '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array( 'http://api.meetup.com/oembed', true ), |
84 '#https?://(www\.)?collegehumor\.com/video/.*#i' => array( 'https://www.collegehumor.com/oembed.{format}', true ), |
64 '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'http://issuu.com/oembed_wp', true ), |
85 '#https?://(www\.)?mixcloud\.com/.*#i' => array( 'https://www.mixcloud.com/oembed', true ), |
65 '#https?://(www\.)?collegehumor\.com/video/.*#i' => array( 'http://www.collegehumor.com/oembed.{format}', true ), |
86 '#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => array( 'https://www.ted.com/services/v1/oembed.{format}', true ), |
66 '#https?://(www\.)?mixcloud\.com/.*#i' => array( 'http://www.mixcloud.com/oembed', true ), |
87 '#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array( 'https://animoto.com/oembeds/create', true ), |
67 '#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => array( 'http://www.ted.com/talks/oembed.{format}', true ), |
88 '#https?://(.+)\.tumblr\.com/post/.*#i' => array( 'https://www.tumblr.com/oembed/1.0', true ), |
68 '#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array( 'http://animoto.com/oembeds/create', true ), |
89 '#https?://(www\.)?kickstarter\.com/projects/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), |
69 '#https?://(.+)\.tumblr\.com/post/.*#i' => array( 'https://www.tumblr.com/oembed/1.0', true ), |
90 '#https?://kck\.st/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), |
70 '#https?://(www\.)?kickstarter\.com/projects/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), |
91 '#https?://cloudup\.com/.*#i' => array( 'https://cloudup.com/oembed', true ), |
71 '#https?://kck\.st/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), |
92 '#https?://(www\.)?reverbnation\.com/.*#i' => array( 'https://www.reverbnation.com/oembed', true ), |
|
93 '#https?://videopress\.com/v/.*#' => array( 'https://public-api.wordpress.com/oembed/?for=' . $host, true ), |
|
94 '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array( 'https://www.reddit.com/oembed', true ), |
|
95 '#https?://(www\.)?speakerdeck\.com/.*#i' => array( 'https://speakerdeck.com/oembed.{format}', true ), |
|
96 '#https?://www\.facebook\.com/.*/posts/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
97 '#https?://www\.facebook\.com/.*/activity/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
98 '#https?://www\.facebook\.com/.*/photos/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
99 '#https?://www\.facebook\.com/photo(s/|\.php).*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
100 '#https?://www\.facebook\.com/permalink\.php.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
101 '#https?://www\.facebook\.com/media/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
102 '#https?://www\.facebook\.com/questions/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
103 '#https?://www\.facebook\.com/notes/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
104 '#https?://www\.facebook\.com/.*/videos/.*#i' => array( 'https://www.facebook.com/plugins/video/oembed.json/', true ), |
|
105 '#https?://www\.facebook\.com/video\.php.*#i' => array( 'https://www.facebook.com/plugins/video/oembed.json/', true ), |
|
106 '#https?://(www\.)?screencast\.com/.*#i' => array( 'https://api.screencast.com/external/oembed', true ), |
|
107 '#https?://([a-z0-9-]+\.)?amazon\.(com|com\.mx|com\.br|ca)/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
|
108 '#https?://([a-z0-9-]+\.)?amazon\.(co\.uk|de|fr|it|es|in|nl|ru)/.*#i' => array( 'https://read.amazon.co.uk/kp/api/oembed', true ), |
|
109 '#https?://([a-z0-9-]+\.)?amazon\.(co\.jp|com\.au)/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ), |
|
110 '#https?://([a-z0-9-]+\.)?amazon\.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ), |
|
111 '#https?://(www\.)?a\.co/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
|
112 '#https?://(www\.)?amzn\.to/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
|
113 '#https?://(www\.)?amzn\.eu/.*#i' => array( 'https://read.amazon.co.uk/kp/api/oembed', true ), |
|
114 '#https?://(www\.)?amzn\.in/.*#i' => array( 'https://read.amazon.in/kp/api/oembed', true ), |
|
115 '#https?://(www\.)?amzn\.asia/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ), |
|
116 '#https?://(www\.)?z\.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ), |
|
117 '#https?://www\.someecards\.com/.+-cards/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ), |
|
118 '#https?://www\.someecards\.com/usercards/viewcard/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ), |
|
119 '#https?://some\.ly\/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ), |
72 ); |
120 ); |
73 |
121 |
74 if ( ! empty( self::$early_providers['add'] ) ) { |
122 if ( ! empty( self::$early_providers['add'] ) ) { |
75 foreach ( self::$early_providers['add'] as $format => $data ) { |
123 foreach ( self::$early_providers['add'] as $format => $data ) { |
76 $providers[ $format ] = $data; |
124 $providers[ $format ] = $data; |
84 } |
132 } |
85 |
133 |
86 self::$early_providers = array(); |
134 self::$early_providers = array(); |
87 |
135 |
88 /** |
136 /** |
89 * Filter the list of oEmbed providers. |
137 * Filters the list of whitelisted oEmbed providers. |
90 * |
138 * |
91 * Discovery is disabled for users lacking the unfiltered_html capability. |
139 * Since WordPress 4.4, oEmbed discovery is enabled for all users and allows embedding of sanitized |
92 * Only providers in this array will be used for those users. |
140 * iframes. The providers in this list are whitelisted, meaning they are trusted and allowed to |
|
141 * embed any content, such as iframes, videos, JavaScript, and arbitrary HTML. |
93 * |
142 * |
94 * Supported providers: |
143 * Supported providers: |
95 * |
144 * |
96 * | ------------ | -------------------- | ----- | --------- | |
145 * | Provider | Flavor | Supports HTTPS | Since | |
97 * | Provider | Flavor | SSL | Since | |
146 * | ------------ | --------------------------------- | :------------: | ------- | |
98 * | ------------ | -------------------- | ----- | --------- | |
147 * | Dailymotion | dailymotion.com | Yes | 2.9.0 | |
99 * | Blip | blip.tv | ! | 2.9.0 | |
148 * | Flickr | flickr.com | Yes | 2.9.0 | |
100 * | Dailymotion | dailymotion.com | Yes | 2.9.0 | |
149 * | Hulu | hulu.com | Yes | 2.9.0 | |
101 * | Flickr | flickr.com | Yes | 2.9.0 | |
150 * | Photobucket | photobucket.com | No | 2.9.0 | |
102 * | Hulu | hulu.com | Yes | 2.9.0 | |
151 * | Scribd | scribd.com | Yes | 2.9.0 | |
103 * | Photobucket | photobucket.com | ! | 2.9.0 | |
152 * | Vimeo | vimeo.com | Yes | 2.9.0 | |
104 * | Scribd | scribd.com | Yes | 2.9.0 | |
153 * | WordPress.tv | wordpress.tv | Yes | 2.9.0 | |
105 * | Vimeo | vimeo.com | Yes | 2.9.0 | |
154 * | YouTube | youtube.com/watch | Yes | 2.9.0 | |
106 * | WordPress.tv | wordpress.tv | Yes | 2.9.0 | |
155 * | Funny or Die | funnyordie.com | Yes | 3.0.0 | |
107 * | YouTube | youtube.com/watch | Yes | 2.9.0 | |
156 * | Polldaddy | polldaddy.com | Yes | 3.0.0 | |
108 * | ------------ | -------------------- | ----- | --------- | |
157 * | SmugMug | smugmug.com | Yes | 3.0.0 | |
109 * | Funny or Die | funnyordie.com | Yes | 3.0.0 | |
158 * | YouTube | youtu.be | Yes | 3.0.0 | |
110 * | Polldaddy | polldaddy.com | Yes | 3.0.0 | |
159 * | Twitter | twitter.com | Yes | 3.4.0 | |
111 * | SmugMug | smugmug.com | Yes | 3.0.0 | |
160 * | Instagram | instagram.com | Yes | 3.5.0 | |
112 * | YouTube | youtu.be | Yes | 3.0.0 | |
161 * | Instagram | instagr.am | Yes | 3.5.0 | |
113 * | ------------ | -------------------- | ----- | --------- | |
162 * | Slideshare | slideshare.net | Yes | 3.5.0 | |
114 * | Twitter | twitter.com | Yes | 3.4.0 | |
163 * | SoundCloud | soundcloud.com | Yes | 3.5.0 | |
115 * | ------------ | -------------------- | ----- | --------- | |
164 * | Dailymotion | dai.ly | Yes | 3.6.0 | |
116 * | Instagram | instagram.com | Yes | 3.5.0 | |
165 * | Flickr | flic.kr | Yes | 3.6.0 | |
117 * | Instagram | instagr.am | Yes | 3.5.0 | |
166 * | Spotify | spotify.com | Yes | 3.6.0 | |
118 * | Slideshare | slideshare.net | Yes | 3.5.0 | |
167 * | Imgur | imgur.com | Yes | 3.9.0 | |
119 * | SoundCloud | soundcloud.com | Yes | 3.5.0 | |
168 * | Meetup.com | meetup.com | Yes | 3.9.0 | |
120 * | ------------ | -------------------- | ----- | --------- | |
169 * | Meetup.com | meetu.ps | Yes | 3.9.0 | |
121 * | Dailymotion | dai.ly | ! | 3.6.0 | |
170 * | Animoto | animoto.com | Yes | 4.0.0 | |
122 * | Flickr | flic.kr | Yes | 3.6.0 | |
171 * | Animoto | video214.com | Yes | 4.0.0 | |
123 * | Rdio | rdio.com | Yes | 3.6.0 | |
172 * | CollegeHumor | collegehumor.com | Yes | 4.0.0 | |
124 * | Rdio | rd.io | Yes | 3.6.0 | |
173 * | Issuu | issuu.com | Yes | 4.0.0 | |
125 * | Spotify | spotify.com | Yes | 3.6.0 | |
174 * | Mixcloud | mixcloud.com | Yes | 4.0.0 | |
126 * | ------------ | -------------------- | ----- | --------- | |
175 * | Polldaddy | poll.fm | Yes | 4.0.0 | |
127 * | Imgur | imgur.com | Yes | 3.9.0 | |
176 * | TED | ted.com | Yes | 4.0.0 | |
128 * | Meetup.com | meetup.com | Yes | 3.9.0 | |
177 * | YouTube | youtube.com/playlist | Yes | 4.0.0 | |
129 * | Meetup.com | meetu.ps | Yes | 3.9.0 | |
178 * | Tumblr | tumblr.com | Yes | 4.2.0 | |
130 * | ------------ | -------------------- | ----- | --------- | |
179 * | Kickstarter | kickstarter.com | Yes | 4.2.0 | |
131 * | Animoto | animoto.com | Yes | 4.0.0 | |
180 * | Kickstarter | kck.st | Yes | 4.2.0 | |
132 * | Animoto | video214.com | Yes | 4.0.0 | |
181 * | Cloudup | cloudup.com | Yes | 4.3.0 | |
133 * | CollegeHumor | collegehumor.com | Yes | 4.0.0 | |
182 * | ReverbNation | reverbnation.com | Yes | 4.4.0 | |
134 * | Issuu | issuu.com | Yes | 4.0.0 | |
183 * | VideoPress | videopress.com | Yes | 4.4.0 | |
135 * | Mixcloud | mixcloud.com | Yes | 4.0.0 | |
184 * | Reddit | reddit.com | Yes | 4.4.0 | |
136 * | Polldaddy | poll.fm | Yes | 4.0.0 | |
185 * | Speaker Deck | speakerdeck.com | Yes | 4.4.0 | |
137 * | TED | ted.com | Yes | 4.0.0 | |
186 * | Twitter | twitter.com/timelines | Yes | 4.5.0 | |
138 * | YouTube | youtube.com/playlist | Yes | 4.0.0 | |
187 * | Twitter | twitter.com/moments | Yes | 4.5.0 | |
139 * | ------------ | -------------------- | ----- | --------- | |
188 * | Facebook | facebook.com | Yes | 4.7.0 | |
140 * | Vine | vine.co | Yes | 4.1.0 | |
189 * | Twitter | twitter.com/user | Yes | 4.7.0 | |
141 * | ------------ | -------------------- | ----- | --------- | |
190 * | Twitter | twitter.com/likes | Yes | 4.7.0 | |
142 * | Tumblr | tumblr.com | Yes | 4.2.0 | |
191 * | Twitter | twitter.com/lists | Yes | 4.7.0 | |
143 * | Kickstarter | kickstarter.com | Yes | 4.2.0 | |
192 * | Screencast | screencast.com | Yes | 4.8.0 | |
144 * | Kickstarter | kck.st | Yes | 4.2.0 | |
193 * | Amazon | amazon.com|com.mx|com.br|ca | Yes | 4.9.0 | |
145 * | ------------ | -------------------- | ----- | --------- | |
194 * | Amazon | amazon.de|fr|it|es|in|nl|ru|co.uk | Yes | 4.9.0 | |
|
195 * | Amazon | amazon.co.jp|com.au | Yes | 4.9.0 | |
|
196 * | Amazon | amazon.cn | Yes | 4.9.0 | |
|
197 * | Amazon | a.co | Yes | 4.9.0 | |
|
198 * | Amazon | amzn.to|eu|in|asia | Yes | 4.9.0 | |
|
199 * | Amazon | z.cn | Yes | 4.9.0 | |
|
200 * | Someecards | someecards.com | Yes | 4.9.0 | |
|
201 * | Someecards | some.ly | Yes | 4.9.0 | |
146 * |
202 * |
147 * No longer supported providers: |
203 * No longer supported providers: |
148 * |
204 * |
149 * | ------------ | -------------------- | ----- | --------- | --------- | |
205 * | Provider | Flavor | Supports HTTPS | Since | Removed | |
150 * | Provider | Flavor | SSL | Since | Removed | |
206 * | ------------ | -------------------- | :------------: | --------- | --------- | |
151 * | ------------ | -------------------- | ----- | --------- | --------- | |
207 * | Qik | qik.com | Yes | 2.9.0 | 3.9.0 | |
152 * | Qik | qik.com | Yes | 2.9.0 | 3.9.0 | |
208 * | Viddler | viddler.com | Yes | 2.9.0 | 4.0.0 | |
153 * | ------------ | -------------------- | ----- | --------- | --------- | |
209 * | Revision3 | revision3.com | No | 2.9.0 | 4.2.0 | |
154 * | Viddler | viddler.com | Yes | 2.9.0 | 4.0.0 | |
210 * | Blip | blip.tv | No | 2.9.0 | 4.4.0 | |
155 * | ------------ | -------------------- | ----- | --------- | --------- | |
211 * | Rdio | rdio.com | Yes | 3.6.0 | 4.4.1 | |
156 * | Revision3 | revision3.com | ! | 2.9.0 | 4.2.0 | |
212 * | Rdio | rd.io | Yes | 3.6.0 | 4.4.1 | |
157 * | ------------ | -------------------- | ----- | --------- | --------- | |
213 * | Vine | vine.co | Yes | 4.1.0 | 4.9.0 | |
158 * |
214 * |
159 * @see wp_oembed_add_provider() |
215 * @see wp_oembed_add_provider() |
160 * |
216 * |
161 * @since 2.9.0 |
217 * @since 2.9.0 |
162 * |
218 * |
273 |
330 |
274 self::$early_providers['remove'][] = $format; |
331 self::$early_providers['remove'][] = $format; |
275 } |
332 } |
276 |
333 |
277 /** |
334 /** |
|
335 * Takes a URL and attempts to return the oEmbed data. |
|
336 * |
|
337 * @see WP_oEmbed::fetch() |
|
338 * |
|
339 * @since 4.8.0 |
|
340 * |
|
341 * @param string $url The URL to the content that should be attempted to be embedded. |
|
342 * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. |
|
343 * @return false|object False on failure, otherwise the result in the form of an object. |
|
344 */ |
|
345 public function get_data( $url, $args = '' ) { |
|
346 $args = wp_parse_args( $args ); |
|
347 |
|
348 $provider = $this->get_provider( $url, $args ); |
|
349 |
|
350 if ( ! $provider ) { |
|
351 return false; |
|
352 } |
|
353 |
|
354 $data = $this->fetch( $provider, $url, $args ); |
|
355 |
|
356 if ( false === $data ) { |
|
357 return false; |
|
358 } |
|
359 |
|
360 return $data; |
|
361 } |
|
362 |
|
363 /** |
278 * The do-it-all function that takes a URL and attempts to return the HTML. |
364 * The do-it-all function that takes a URL and attempts to return the HTML. |
279 * |
365 * |
280 * @see WP_oEmbed::fetch() |
366 * @see WP_oEmbed::fetch() |
281 * @see WP_oEmbed::data2html() |
367 * @see WP_oEmbed::data2html() |
282 * |
368 * |
283 * @param string $url The URL to the content that should be attempted to be embedded. |
369 * @since 2.9.0 |
284 * @param array $args Optional arguments. Usually passed from a shortcode. |
370 * |
|
371 * @param string $url The URL to the content that should be attempted to be embedded. |
|
372 * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. |
285 * @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed. |
373 * @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed. |
286 */ |
374 */ |
287 public function get_html( $url, $args = '' ) { |
375 public function get_html( $url, $args = '' ) { |
288 $provider = $this->get_provider( $url, $args ); |
|
289 |
|
290 if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) ) |
|
291 return false; |
|
292 |
|
293 /** |
376 /** |
294 * Filter the HTML returned by the oEmbed provider. |
377 * Filters the oEmbed result before any HTTP requests are made. |
|
378 * |
|
379 * This allows one to short-circuit the default logic, perhaps by |
|
380 * replacing it with a routine that is more optimal for your setup. |
|
381 * |
|
382 * Passing a non-null value to the filter will effectively short-circuit retrieval, |
|
383 * returning the passed value instead. |
|
384 * |
|
385 * @since 4.5.3 |
|
386 * |
|
387 * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null. |
|
388 * @param string $url The URL to the content that should be attempted to be embedded. |
|
389 * @param array $args Optional. Arguments, usually passed from a shortcode. Default empty. |
|
390 */ |
|
391 $pre = apply_filters( 'pre_oembed_result', null, $url, $args ); |
|
392 |
|
393 if ( null !== $pre ) { |
|
394 return $pre; |
|
395 } |
|
396 |
|
397 $data = $this->get_data( $url, $args ); |
|
398 |
|
399 if ( false === $data ) { |
|
400 return false; |
|
401 } |
|
402 |
|
403 /** |
|
404 * Filters the HTML returned by the oEmbed provider. |
295 * |
405 * |
296 * @since 2.9.0 |
406 * @since 2.9.0 |
297 * |
407 * |
298 * @param string $data The returned oEmbed HTML. |
408 * @param string $data The returned oEmbed HTML. |
299 * @param string $url URL of the content to be embedded. |
409 * @param string $url URL of the content to be embedded. |
379 } |
496 } |
380 |
497 |
381 /** |
498 /** |
382 * Connects to a oEmbed provider and returns the result. |
499 * Connects to a oEmbed provider and returns the result. |
383 * |
500 * |
384 * @param string $provider The URL to the oEmbed provider. |
501 * @since 2.9.0 |
385 * @param string $url The URL to the content that is desired to be embedded. |
502 * |
386 * @param array $args Optional arguments. Usually passed from a shortcode. |
503 * @param string $provider The URL to the oEmbed provider. |
387 * @return bool|object False on failure, otherwise the result in the form of an object. |
504 * @param string $url The URL to the content that is desired to be embedded. |
|
505 * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. |
|
506 * @return false|object False on failure, otherwise the result in the form of an object. |
388 */ |
507 */ |
389 public function fetch( $provider, $url, $args = '' ) { |
508 public function fetch( $provider, $url, $args = '' ) { |
390 $args = wp_parse_args( $args, wp_embed_defaults( $url ) ); |
509 $args = wp_parse_args( $args, wp_embed_defaults( $url ) ); |
391 |
510 |
392 $provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider ); |
511 $provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider ); |
393 $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider ); |
512 $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider ); |
394 $provider = add_query_arg( 'url', urlencode($url), $provider ); |
513 $provider = add_query_arg( 'url', urlencode($url), $provider ); |
|
514 $provider = add_query_arg( 'dnt', 1, $provider ); |
395 |
515 |
396 /** |
516 /** |
397 * Filter the oEmbed URL to be fetched. |
517 * Filters the oEmbed URL to be fetched. |
398 * |
518 * |
399 * @since 2.9.0 |
519 * @since 2.9.0 |
|
520 * @since 4.9.0 The `dnt` (Do Not Track) query parameter was added to all oEmbed provider URLs. |
400 * |
521 * |
401 * @param string $provider URL of the oEmbed provider. |
522 * @param string $provider URL of the oEmbed provider. |
402 * @param string $url URL of the content to be embedded. |
523 * @param string $url URL of the content to be embedded. |
403 * @param array $args Optional arguments, usually passed from a shortcode. |
524 * @param array $args Optional arguments, usually passed from a shortcode. |
404 */ |
525 */ |
405 $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args ); |
526 $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args ); |
406 |
527 |
407 foreach( array( 'json', 'xml' ) as $format ) { |
528 foreach ( array( 'json', 'xml' ) as $format ) { |
408 $result = $this->_fetch_with_format( $provider, $format ); |
529 $result = $this->_fetch_with_format( $provider, $format ); |
409 if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() ) |
530 if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() ) |
410 continue; |
531 continue; |
411 return ( $result && ! is_wp_error( $result ) ) ? $result : false; |
532 return ( $result && ! is_wp_error( $result ) ) ? $result : false; |
412 } |
533 } |