~canonical-sysadmins/wordpress/4.9

« back to all changes in this revision

Viewing changes to wp-includes/class-oembed.php

  • Committer: Barry Price
  • Date: 2017-06-09 02:09:58 UTC
  • mfrom: (1.1.26 upstream)
  • Revision ID: barry.price@canonical.com-20170609020958-838whhwt2196f2vk
Merge WP4.8 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
         * @access private
45
45
         * @var array
46
46
         */
47
 
        private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_body' );
 
47
        private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_xml_body' );
48
48
 
49
49
        /**
50
50
         * Constructor.
108
108
                        '#https?://www\.facebook\.com/notes/.*#i'                  => array( 'https://www.facebook.com/plugins/post/oembed.json/',        true  ),
109
109
                        '#https?://www\.facebook\.com/.*/videos/.*#i'              => array( 'https://www.facebook.com/plugins/video/oembed.json/',       true  ),
110
110
                        '#https?://www\.facebook\.com/video\.php.*#i'              => array( 'https://www.facebook.com/plugins/video/oembed.json/',       true  ),
 
111
                        '#https?://(www\.)?screencast\.com/.*#i'                   => array( 'https://api.screencast.com/external/oembed',                true  ),
111
112
                );
112
113
 
113
114
                if ( ! empty( self::$early_providers['add'] ) ) {
181
182
                 * | Twitter      | twitter.com/user      |      Yes       | 4.7.0     |
182
183
                 * | Twitter      | twitter.com/likes     |      Yes       | 4.7.0     |
183
184
                 * | Twitter      | twitter.com/lists     |      Yes       | 4.7.0     |
 
185
                 * | Screencast   | screencast.com        |      Yes       | 4.8.0     |
184
186
                 *
185
187
                 * No longer supported providers:
186
188
                 *
317
319
        }
318
320
 
319
321
        /**
 
322
         * Takes a URL and attempts to return the oEmbed data.
 
323
         *
 
324
         * @see WP_oEmbed::fetch()
 
325
         *
 
326
         * @since 4.8.0
 
327
         * @access public
 
328
         *
 
329
         * @param string       $url  The URL to the content that should be attempted to be embedded.
 
330
         * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty.
 
331
         * @return false|object False on failure, otherwise the result in the form of an object.
 
332
         */
 
333
        public function get_data( $url, $args = '' ) {
 
334
                $args = wp_parse_args( $args );
 
335
 
 
336
                $provider = $this->get_provider( $url, $args );
 
337
 
 
338
                if ( ! $provider ) {
 
339
                        return false;
 
340
                }
 
341
 
 
342
                $data = $this->fetch( $provider, $url, $args );
 
343
 
 
344
                if ( false === $data ) {
 
345
                        return false;
 
346
                }
 
347
 
 
348
                return $data;
 
349
        }
 
350
 
 
351
        /**
320
352
         * The do-it-all function that takes a URL and attempts to return the HTML.
321
353
         *
322
354
         * @see WP_oEmbed::fetch()
330
362
         * @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
331
363
         */
332
364
        public function get_html( $url, $args = '' ) {
333
 
                $args = wp_parse_args( $args );
334
 
 
335
365
                /**
336
366
                 * Filters the oEmbed result before any HTTP requests are made.
337
367
                 *
353
383
                        return $pre;
354
384
                }
355
385
 
356
 
                $provider = $this->get_provider( $url, $args );
 
386
                $data = $this->get_data( $url, $args );
357
387
 
358
 
                if ( ! $provider || false === $data = $this->fetch( $provider, $url, $args ) ) {
 
388
                if ( false === $data ) {
359
389
                        return false;
360
390
                }
361
391