| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * VideoPress Shortcode Handler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * This file may or may not be included from the Jetpack VideoPress module. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class VideoPress_Shortcode { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 	/** @var VideoPress_Shortcode */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 	protected static $instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 	protected function __construct() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 		// By explicitly declaring the provider here, we can speed things up by not relying on oEmbed discovery. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 		wp_oembed_add_provider( '#^https?://videopress.com/v/.*#', 'http://public-api.wordpress.com/oembed/1.0/', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 		add_shortcode( 'videopress', array( $this, 'shortcode_callback' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 		add_shortcode( 'wpvideo',    array( $this, 'shortcode_callback' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 		add_filter('wp_video_shortcode_override', array( $this, 'video_shortcode_override' ), 10, 4); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		add_filter( 'oembed_fetch_url', array( $this, 'add_oembed_for_parameter' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 		$this->add_video_embed_hander(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	 * @return VideoPress_Shortcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	public static function initialize() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 		if ( ! isset ( self::$instance ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 			self::$instance = new self(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 		return self::$instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	 * Translate a 'videopress' or 'wpvideo' shortcode and arguments into a video player display. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	 * Expected input formats: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	 * [videopress OcobLTqC] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	 * [wpvideo OcobLTqC] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	 * @link http://codex.wordpress.org/Shortcode_API Shortcode API | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	 * @param array $attr shortcode attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	 * @return string HTML markup or blank string on fail | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	public function shortcode_callback( $attr ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		global $content_width; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		 * We only accept GUIDs as a first unnamed argument. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		$guid = isset( $attr[0] ) ? $attr[0] : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		if ( isset( $attr['postid'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			$guid = get_post_meta( $attr['postid'], 'videopress_guid', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		 * Make sure the GUID passed in matches how actual GUIDs are formatted. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		if ( ! videopress_is_valid_guid( $guid ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 			return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		 * Set the defaults | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 			'w'               => 0,     // Width of the video player, in pixels | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 			'at'              => 0,     // How many seconds in to initially seek to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 			'hd'              => true,  // Whether to display a high definition version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 			'loop'            => false, // Whether to loop the video repeatedly | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 			'freedom'         => false, // Whether to use only free/libre codecs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			'autoplay'        => false, // Whether to autoplay the video on load | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			'permalink'       => true,  // Whether to display the permalink to the video | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 			'flashonly'       => false, // Whether to support the Flash player exclusively | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 			'defaultlangcode' => false, // Default language code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 		$attr = shortcode_atts( $defaults, $attr, 'videopress' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		 * Cast the attributes, post-input. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		$attr['width']   = absint( $attr['w'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		$attr['hd']      = (bool) $attr['hd']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 		$attr['freedom'] = (bool) $attr['freedom']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 		 * If the provided width is less than the minimum allowed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 		 * width, or greater than `$content_width` ignore. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		if ( $attr['width'] < VIDEOPRESS_MIN_WIDTH ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			$attr['width'] = 0; | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 100 |  | View Code Duplication | 		} elseif ( isset( $content_width ) && $content_width > VIDEOPRESS_MIN_WIDTH && $attr['width'] > $content_width ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 			$attr['width'] = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		 * If there was an invalid or unspecified width, set the width equal to the theme's `$content_width`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 107 |  | View Code Duplication | 		if ( 0 === $attr['width'] && isset( $content_width ) && $content_width >= VIDEOPRESS_MIN_WIDTH ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 			$attr['width'] = $content_width; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		 * If the width isn't an even number, reduce it by one (making it even). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		if ( 1 === ( $attr['width'] % 2 ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 			$attr['width'] --; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		 * Filter the default VideoPress shortcode options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 		 * @module videopress | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 		 * @since 2.5.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 		 * @param array $args Array of VideoPress shortcode options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		$options = apply_filters( 'videopress_shortcode_options', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 			'at'              => (int) $attr['at'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 			'hd'              => $attr['hd'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 			'loop'            => $attr['autoplay'] || $attr['loop'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 			'freedom'         => $attr['freedom'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 			'autoplay'        => $attr['autoplay'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 			'permalink'       => $attr['permalink'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 			'force_flash'     => (bool) $attr['flashonly'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 			'defaultlangcode' => $attr['defaultlangcode'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 			'forcestatic'     => false, // This used to be a displayed option, but now is only | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 			// accessible via the `videopress_shortcode_options` filter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 		// Register VideoPress scripts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 		wp_register_script( 'videopress', 'https://v0.wordpress.com/js/videopress.js', array( 'jquery', 'swfobject' ), '1.09' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		require_once( dirname( __FILE__ ) . '/class.videopress-video.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 		require_once( dirname( __FILE__ ) . '/class.videopress-player.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		$player = new VideoPress_Player( $guid, $attr['width'], $options ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		if ( is_feed() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 			return $player->asXML(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 			return $player->asHTML(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 	 * Override the standard video short tag to also process videopress files as well. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	 * This will, parse the src given, and if it is a videopress file, it will parse as the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	 * VideoPress shortcode instead. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 	 * @param string $html     Empty variable to be replaced with shortcode markup. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 	 * @param array  $attr     Attributes of the video shortcode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	 * @param string $content  Video shortcode content. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 	 * @param int    $instance Unique numeric ID of this video shortcode instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	public function video_shortcode_override($html, $attr, $content, $instance) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		$videopress_guid = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		if ( isset( $attr['videopress_guid'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 			$videopress_guid = $attr['videopress_guid']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 			// Handle the different possible url attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 			$url_keys = array( 'src', 'mp4' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 			foreach ( $url_keys as $key ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 				if ( isset ( $attr[ $key ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 					$url = $attr[ $key ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 					if ( preg_match( '@videos.(videopress\.com|files\.wordpress\.com)/([a-z0-9]{8})/@i', $url, $matches ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 						$videopress_guid = $matches[2]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 					// Also test for videopress oembed url, which is used by the Video Media Widget. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 					if ( ! $videopress_guid && preg_match( '@https://videopress.com/v/([a-z0-9]{8})@i', $url, $matches ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 						$videopress_guid = $matches[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 		if ( $videopress_guid ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 			$videopress_attr = array( $videopress_guid ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 			if ( isset( $attr['width'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 				$videopress_attr['w'] = (int) $attr['width']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 			if ( isset( $attr['autoplay'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 				$videopress_attr['autoplay'] = $attr['autoplay']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 			if ( isset( $attr['loop'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 				$videopress_attr['loop'] = $attr['loop']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 			// Then display the VideoPress version of the stored GUID! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 			return $this->shortcode_callback( $videopress_attr ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 	 * Adds a `for` query parameter to the oembed provider request URL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 	 * @param String $oembed_provider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 	 * @return String $ehnanced_oembed_provider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 	public function add_oembed_for_parameter( $oembed_provider ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 		if ( false === stripos( $oembed_provider, 'videopress.com' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 			return $oembed_provider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 		return add_query_arg( 'for', parse_url( home_url(), PHP_URL_HOST ), $oembed_provider ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 	 * Register a VideoPress handler for direct links to .mov files (and potential other non-handled types later). | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 231 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  | 	public function add_video_embed_hander() { | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  | 		// These are the video extensions that VideoPress can transcode and considers video as well (even if core does not). | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  | 		$extensions          = array( 'mov' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  | 		$override_extensions = implode( '|', $extensions ); | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 237 |  |  | 		$regex = "#^https?://videos.(videopress.com|files.wordpress.com)/.+?.($override_extensions)$#i"; | 
            
                                                                        
                            
            
                                    
            
            
                | 238 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 239 |  |  | 		/** This filter is already documented in core/wp-includes/embed.php */ | 
            
                                                                        
                            
            
                                    
            
            
                | 240 |  |  | 		$filter = apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 241 |  |  | 		wp_embed_register_handler( 'video', $regex, $filter, 10 ); | 
            
                                                                        
                            
            
                                    
            
            
                | 242 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 245 |  |  | VideoPress_Shortcode::initialize(); | 
            
                                                        
            
                                    
            
            
                | 246 |  |  |  | 
            
                        
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: