| @@ -117,8 +117,28 @@ | ||
| 117 | 117 | $time_text = date( 'H\hi\ms\s', $options['start'] ); // PHPCS:Ignore WordPress.DateTime.RestrictedFunctions.date_date |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | $replacements['{TIME}'] = $time_text; |
| 121 | + | |
| 122 | + /** | |
| 123 | + * Handle Vimeo private videos | |
| 124 | + * | |
| 125 | + * Vimeo requires an additional parameter when displaying private/unlisted videos. It has two ways of | |
| 126 | + * passing that parameter: | |
| 127 | + * * as an endpoint - vimeo.com/{video_id}/{privacy_token} | |
| 128 | + * OR | |
| 129 | + * * as a GET parameter named `h` - vimeo.com/{video_id}?h={privacy_token} | |
| 130 | + * | |
| 131 | + * The following regex match looks for either of these methods in the Vimeo URL, and if it finds a privacy | |
| 132 | + * token, it adds it to the embed params array as the `h` parameter (which is how Vimeo can receive it when | |
| 133 | + * using Oembed). | |
| 134 | + */ | |
| 135 | + $h_param = []; | |
| 136 | + preg_match( '/(?|(?:[\?|\&]h={1})([\w]+)|\d\/([\w]+))/', $video_url, $h_param ); | |
| 137 | + | |
| 138 | + if ( ! empty( $h_param ) ) { | |
| 139 | + $embed_url_params['h'] = $h_param[1]; | |
| 140 | + } | |
| 121 | 141 | } |
| 122 | 142 | |
| 123 | 143 | $embed_pattern = str_replace( array_keys( $replacements ), $replacements, $embed_pattern ); |
| 124 | 144 | |