X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8ab4a4532479e8db471032b51042ec8c4716d091..e0feb3b2e5b436a06bbb04fbc838d1cd6ec95399:/wp-includes/class-oembed.php?ds=inline diff --git a/wp-includes/class-oembed.php b/wp-includes/class-oembed.php index 4e888367..18c24903 100644 --- a/wp-includes/class-oembed.php +++ b/wp-includes/class-oembed.php @@ -19,6 +19,10 @@ */ class WP_oEmbed { public $providers = array(); + /** + * @static + * @var array + */ public static $early_providers = array(); private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_body' ); @@ -30,10 +34,10 @@ class WP_oEmbed { */ public function __construct() { $providers = array( - '#http://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), - '#https://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), - '#http://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed', true ), - '#https://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), + '#http://((m|www)\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), + '#https://((m|www)\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), + '#http://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed', true ), + '#https://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), '#http://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed', true ), '#https://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), 'http://blip.tv/*' => array( 'http://blip.tv/oembed/', false ), @@ -69,6 +73,7 @@ class WP_oEmbed { '#https?://(.+)\.tumblr\.com/post/.*#i' => array( 'https://www.tumblr.com/oembed/1.0', true ), '#https?://(www\.)?kickstarter\.com/projects/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), '#https?://kck\.st/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), + '#https?://cloudup\.com/.*#i' => array( 'https://cloudup.com/oembed', true ), ); if ( ! empty( self::$early_providers['add'] ) ) { @@ -195,7 +200,7 @@ class WP_oEmbed { * * @param string $url The URL to the content. * @param string|array $args Optional provider arguments. - * @return bool|string False on failure, otherwise the oEmbed provider URL. + * @return false|string False on failure, otherwise the oEmbed provider URL. */ public function get_provider( $url, $args = '' ) { @@ -306,7 +311,7 @@ class WP_oEmbed { * Attempts to discover link tags at the given URL for an oEmbed provider. * * @param string $url The URL that should be inspected for discovery `` tags. - * @return bool|string False on failure, otherwise the oEmbed provider URL. + * @return false|string False on failure, otherwise the oEmbed provider URL. */ public function discover( $url ) { $providers = array(); @@ -384,7 +389,7 @@ class WP_oEmbed { * @param string $provider The URL to the oEmbed provider. * @param string $url The URL to the content that is desired to be embedded. * @param array $args Optional arguments. Usually passed from a shortcode. - * @return bool|object False on failure, otherwise the result in the form of an object. + * @return false|object False on failure, otherwise the result in the form of an object. */ public function fetch( $provider, $url, $args = '' ) { $args = wp_parse_args( $args, wp_embed_defaults( $url ) ); @@ -420,7 +425,7 @@ class WP_oEmbed { * @access private * @param string $provider_url_with_args URL to the provider with full arguments list (url, maxheight, etc.) * @param string $format Format to use - * @return bool|object False on failure, otherwise the result in the form of an object. + * @return false|object|WP_Error False on failure, otherwise the result in the form of an object. */ private function _fetch_with_format( $provider_url_with_args, $format ) { $provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args ); @@ -442,9 +447,13 @@ class WP_oEmbed { * * @since 3.0.0 * @access private + * + * @param string $response_body + * @return object|false */ private function _parse_json( $response_body ) { - return ( ( $data = json_decode( trim( $response_body ) ) ) && is_object( $data ) ) ? $data : false; + $data = json_decode( trim( $response_body ) ); + return ( $data && is_object( $data ) ) ? $data : false; } /** @@ -452,6 +461,9 @@ class WP_oEmbed { * * @since 3.0.0 * @access private + * + * @param string $response_body + * @return object|false */ private function _parse_xml( $response_body ) { if ( ! function_exists( 'libxml_disable_entity_loader' ) ) @@ -473,6 +485,9 @@ class WP_oEmbed { * * @since 3.6.0 * @access private + * + * @param string $response_body + * @return object|false */ private function _parse_xml_body( $response_body ) { if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument' ) ) @@ -601,15 +616,15 @@ class WP_oEmbed { * @since 2.9.0 * @access private * - * @see WP_oEmbed + * @staticvar WP_oEmbed $wp_oembed * * @return WP_oEmbed object. */ function _wp_oembed_get_object() { - static $wp_oembed; + static $wp_oembed = null; - if ( is_null($wp_oembed) ) + if ( is_null( $wp_oembed ) ) { $wp_oembed = new WP_oEmbed(); - + } return $wp_oembed; }