ARVE Advanced Responsive Video Embedder (YouTube, Vimeo, HTML5 Video …) - Version 9.3.1

Version Description

Download this release

Release Info

Developer nico23
Plugin Icon 128x128 ARVE Advanced Responsive Video Embedder (YouTube, Vimeo, HTML5 Video …)
Version 9.3.1
Comparing to
See all releases

Code changes from version 9.3.0 to 9.3.1

advanced-responsive-video-embedder.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ARVE Advanced Responsive Video Embedder
4
  * Plugin URI: https://nextgenthemes.com/plugins/arve-pro/
5
  * Description: Easy responsive video embeds via URL (like WordPress) or Shortcodes. Supports almost anything you can imagine.
6
- * Version: 9.3.0
7
  * Author: Nicolas Jonas
8
  * Author URI: https://nextgenthemes.com
9
  * License: GPL-3.0
@@ -21,7 +21,7 @@
21
 
22
  namespace Nextgenthemes\ARVE;
23
 
24
- const VERSION = '9.3.0';
25
  const PRO_VERSION_REQUIRED = '5.1.5';
26
  const NUM_TRACKS = 3;
27
  const PLUGIN_FILE = __FILE__;
3
  * Plugin Name: ARVE Advanced Responsive Video Embedder
4
  * Plugin URI: https://nextgenthemes.com/plugins/arve-pro/
5
  * Description: Easy responsive video embeds via URL (like WordPress) or Shortcodes. Supports almost anything you can imagine.
6
+ * Version: 9.3.1
7
  * Author: Nicolas Jonas
8
  * Author URI: https://nextgenthemes.com
9
  * License: GPL-3.0
21
 
22
  namespace Nextgenthemes\ARVE;
23
 
24
+ const VERSION = '9.3.1';
25
  const PRO_VERSION_REQUIRED = '5.1.5';
26
  const NUM_TRACKS = 3;
27
  const PLUGIN_FILE = __FILE__;
changelog.md CHANGED
@@ -4,6 +4,12 @@
4
  * [ARVE Pro changelog](https://nextgenthemes.com/plugins/arve-pro/#changelog)
5
  * [ARVE Random Videos changelog](https://nextgenthemes.com/plugins/random-video/#changelog)
6
 
 
 
 
 
 
 
7
  ### 2021-01-24 9.3.0 ###
8
 
9
  Improved:
4
  * [ARVE Pro changelog](https://nextgenthemes.com/plugins/arve-pro/#changelog)
5
  * [ARVE Random Videos changelog](https://nextgenthemes.com/plugins/random-video/#changelog)
6
 
7
+ ### 2021-01-25 9.3.1 ###
8
+
9
+ * Fix: Avoid passing `null` to `str_contains`.
10
+ * Improved: Code related to the above.
11
+ * Improved: Added back Installation section to the readme.
12
+
13
  ### 2021-01-24 9.3.0 ###
14
 
15
  Improved:
php/ShortcodeArgs.php CHANGED
@@ -314,74 +314,92 @@ class ShortcodeArgs {
314
  return $a;
315
  }
316
 
317
- private function special_iframe_src_mods( array $a ) {
318
-
319
- switch ( $a['provider'] ) {
320
- case 'youtube':
321
- $yt_v = Common\get_url_arg( $a['url'], 'v' );
322
- $yt_list = Common\get_url_arg( $a['url'], 'list' );
323
 
324
- if ( str_contains( $a['src'], '/embed/videoseries?' ) &&
325
- $yt_v
326
- ) {
327
- $a['src'] = str_replace( '/embed/videoseries?', "/embed/$yt_v?", $a['src'] );
328
- }
329
 
330
- if ( $yt_list ) {
331
- $a['src'] = remove_query_arg( 'feature', $a['src'] );
332
- $a['src'] = add_query_arg( 'list', $yt_list, $a['src'] );
333
- $a['src_gen'] = add_query_arg( 'list', $yt_list, $a['src_gen'] );
334
- }
335
- break;
336
- case 'vimeo':
337
- $a['src'] = add_query_arg( 'dnt', 1, $a['src'] );
338
- $a['src_gen'] = add_query_arg( 'dnt', 1, $a['src_gen'] );
339
 
340
- $parsed_url = wp_parse_url( $a['url'] );
341
 
342
- if ( ! empty( $parsed_url['fragment'] ) && str_starts_with( $parsed_url['fragment'], 't' ) ) {
343
- $a['src'] .= '#' . $parsed_url['fragment'];
344
- $a['src_gen'] .= '#' . $parsed_url['fragment'];
345
- }
346
- break;
347
- case 'wistia':
348
- $a['src'] = add_query_arg( 'dnt', 1, $a['src'] );
349
- $a['src_gen'] = add_query_arg( 'dnt', 1, $a['src_gen'] );
350
- break;
351
  }
352
 
353
- return $a;
 
 
 
354
  }
355
 
356
- private function arg_iframe_src( array $a ) {
357
 
358
- if ( 'html5' === $a['provider'] ) {
359
- return false;
 
 
360
  }
361
 
362
- if ( ! $a['provider'] || ! $a['id'] ) {
363
- $this->errors->add( 'no-provider-and-id', 'Need Provider and ID to build iframe src' );
364
- return false;
 
 
 
 
365
  }
366
 
367
- $options = options();
368
- $a['src_gen'] = build_iframe_src( $a );
369
- $a = special_iframe_src_mods( $a );
370
 
371
- $this->compare_oembed_src_with_generated_src( $a );
372
 
373
- if ( ! valid_url( $a['src'] ) && valid_url( $a['src_gen'] ) ) {
374
- $a['src'] = $a['src_gen'];
 
375
  }
376
 
377
- $a['src'] = iframe_src_args( $a['src'], $a );
378
- $a['src'] = iframe_src_autoplay_args( $a['autoplay'], $a );
 
379
 
380
- if ( 'youtube' === $a['provider'] && $options['youtube_nocookie'] ) {
381
- $a['src'] = str_replace( 'https://www.youtube.com', 'https://www.youtube-nocookie.com', $a['src'] );
 
 
382
  }
383
 
384
- return $a['src'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  }
386
 
387
  private function compare_oembed_src_with_generated_src( $a ) {
314
  return $a;
315
  }
316
 
317
+ private function arg_iframe_src( array $a ) {
 
 
 
 
 
318
 
319
+ if ( 'html5' === $a['provider'] ) {
320
+ return false;
321
+ }
 
 
322
 
323
+ $options = options();
324
+ $a['src_gen'] = $this->build_iframe_src( $a );
325
+ $a['src_gen'] = special_iframe_src_mods( $a['src_gen'], $a );
326
+ $a['src'] = special_iframe_src_mods( $a['src'], $a, 'oembed src' );
 
 
 
 
 
327
 
328
+ $this->compare_oembed_src_with_generated_src( $a );
329
 
330
+ if ( ! valid_url( $a['src'] ) && valid_url( $a['src_gen'] ) ) {
331
+ $a['src'] = $a['src_gen'];
 
 
 
 
 
 
 
332
  }
333
 
334
+ $a['src'] = iframe_src_args( $a['src'], $a );
335
+ $a['src'] = iframe_src_autoplay_args( $a['autoplay'], $a );
336
+
337
+ return $a['src'];
338
  }
339
 
340
+ private function build_iframe_src( array $a ) {
341
 
342
+ if ( ! $a['provider'] || ! $a['id'] ) {
343
+ throw new \Exception(
344
+ __( 'Need Provider and ID to build iframe src.', 'advanced-responsive-video-embedder' )
345
+ );
346
  }
347
 
348
+ $options = options();
349
+ $properties = get_host_properties();
350
+
351
+ if ( isset( $properties[ $a['provider'] ]['embed_url'] ) ) {
352
+ $pattern = $properties[ $a['provider'] ]['embed_url'];
353
+ } else {
354
+ $pattern = '%s';
355
  }
356
 
357
+ if ( 'facebook' === $a['provider'] && is_numeric( $a['id'] ) ) {
 
 
358
 
359
+ $a['id'] = "https://www.facebook.com/facebook/videos/{$a['id']}/";
360
 
361
+ } elseif ( 'twitch' === $a['provider'] && is_numeric( $a['id'] ) ) {
362
+
363
+ $pattern = 'https://player.twitch.tv/?video=v%s';
364
  }
365
 
366
+ if ( isset( $properties[ $a['provider'] ]['url_encode_id'] ) && $properties[ $a['provider'] ]['url_encode_id'] ) {
367
+ $a['id'] = rawurlencode( str_replace( '&', '&', $a['id'] ) );
368
+ }
369
 
370
+ if ( 'brightcove' === $a['provider'] ) {
371
+ $src = sprintf( $pattern, $a['account_id'], $a['brightcove_player'], $a['brightcove_embed'], $a['id'] );
372
+ } else {
373
+ $src = sprintf( $pattern, $a['id'] );
374
  }
375
 
376
+ switch ( $a['provider'] ) {
377
+
378
+ case 'youtube':
379
+ $t_arg = Common\get_url_arg( $a['url'], 't' );
380
+ $time_continue = Common\get_url_arg( $a['url'], 'time_continue' );
381
+ $list_arg = Common\get_url_arg( $a['url'], 'list' );
382
+
383
+ if ( $t_arg ) {
384
+ $src = add_query_arg( 'start', youtube_time_to_seconds( $t_arg ), $src );
385
+ }
386
+ if ( $time_continue ) {
387
+ $src = add_query_arg( 'start', youtube_time_to_seconds( $time_continue ), $src );
388
+ }
389
+
390
+ if ( $list_arg ) {
391
+ $src = add_query_arg( 'list', $list_arg, $src );
392
+ }
393
+ break;
394
+ case 'ted':
395
+ $lang = Common\get_url_arg( $a['url'], 'language' );
396
+ if ( $lang ) {
397
+ $src = str_replace( 'ted.com/talks/', "ted.com/talks/lang/{$lang}/", $src );
398
+ }
399
+ break;
400
+ }
401
+
402
+ return $src;
403
  }
404
 
405
  private function compare_oembed_src_with_generated_src( $a ) {
php/functions-shortcode-filters.php CHANGED
@@ -147,98 +147,47 @@ function args_video( array $a ) {
147
  return $a;
148
  }
149
 
150
- function special_iframe_src_mods( array $a ) {
 
 
 
 
151
 
152
  switch ( $a['provider'] ) {
153
  case 'youtube':
154
  $yt_v = Common\get_url_arg( $a['url'], 'v' );
155
  $yt_list = Common\get_url_arg( $a['url'], 'list' );
156
 
157
- if ( str_contains( $a['src'], '/embed/videoseries?' ) &&
 
158
  $yt_v
159
  ) {
160
- $a['src'] = str_replace( '/embed/videoseries?', "/embed/$yt_v?", $a['src'] );
161
  }
162
 
163
  if ( $yt_list ) {
164
- $a['src'] = remove_query_arg( 'feature', $a['src'] );
165
- $a['src'] = add_query_arg( 'list', $yt_list, $a['src'] );
166
- $a['src_gen'] = add_query_arg( 'list', $yt_list, $a['src_gen'] );
 
 
 
 
 
167
  }
 
168
  break;
169
  case 'vimeo':
170
- $a['src'] = add_query_arg( 'dnt', 1, $a['src'] );
171
- $a['src_gen'] = add_query_arg( 'dnt', 1, $a['src_gen'] );
172
 
173
  $parsed_url = wp_parse_url( $a['url'] );
174
 
175
  if ( ! empty( $parsed_url['fragment'] ) && str_starts_with( $parsed_url['fragment'], 't' ) ) {
176
- $a['src'] .= '#' . $parsed_url['fragment'];
177
- $a['src_gen'] .= '#' . $parsed_url['fragment'];
178
  }
179
  break;
180
  case 'wistia':
181
- $a['src'] = add_query_arg( 'dnt', 1, $a['src'] );
182
- $a['src_gen'] = add_query_arg( 'dnt', 1, $a['src_gen'] );
183
- break;
184
- }
185
-
186
- return $a;
187
- }
188
-
189
- function build_iframe_src( array $a ) {
190
-
191
- $options = options();
192
- $properties = get_host_properties();
193
-
194
- if ( isset( $properties[ $a['provider'] ]['embed_url'] ) ) {
195
- $pattern = $properties[ $a['provider'] ]['embed_url'];
196
- } else {
197
- $pattern = '%s';
198
- }
199
-
200
- if ( 'facebook' === $a['provider'] && is_numeric( $a['id'] ) ) {
201
-
202
- $a['id'] = "https://www.facebook.com/facebook/videos/{$a['id']}/";
203
-
204
- } elseif ( 'twitch' === $a['provider'] && is_numeric( $a['id'] ) ) {
205
-
206
- $pattern = 'https://player.twitch.tv/?video=v%s';
207
- }
208
-
209
- if ( isset( $properties[ $a['provider'] ]['url_encode_id'] ) && $properties[ $a['provider'] ]['url_encode_id'] ) {
210
- $a['id'] = rawurlencode( str_replace( '&', '&', $a['id'] ) );
211
- }
212
-
213
- if ( 'brightcove' === $a['provider'] ) {
214
- $src = sprintf( $pattern, $a['account_id'], $a['brightcove_player'], $a['brightcove_embed'], $a['id'] );
215
- } else {
216
- $src = sprintf( $pattern, $a['id'] );
217
- }
218
-
219
- switch ( $a['provider'] ) {
220
-
221
- case 'youtube':
222
- $t_arg = Common\get_url_arg( $a['url'], 't' );
223
- $time_continue = Common\get_url_arg( $a['url'], 'time_continue' );
224
- $list_arg = Common\get_url_arg( $a['url'], 'list' );
225
-
226
- if ( $t_arg ) {
227
- $src = add_query_arg( 'start', youtube_time_to_seconds( $t_arg ), $src );
228
- }
229
- if ( $time_continue ) {
230
- $src = add_query_arg( 'start', youtube_time_to_seconds( $time_continue ), $src );
231
- }
232
-
233
- if ( $list_arg ) {
234
- $src = add_query_arg( 'list', $list_arg, $src );
235
- }
236
- break;
237
- case 'ted':
238
- $lang = Common\get_url_arg( $a['url'], 'language' );
239
- if ( $lang ) {
240
- $src = str_replace( 'ted.com/talks/', "ted.com/talks/lang/{$lang}/", $src );
241
- }
242
  break;
243
  }
244
 
147
  return $a;
148
  }
149
 
150
+ function special_iframe_src_mods( $src, array $a, $oembed_src = false ) {
151
+
152
+ if ( empty( $src ) ) {
153
+ return $src;
154
+ }
155
 
156
  switch ( $a['provider'] ) {
157
  case 'youtube':
158
  $yt_v = Common\get_url_arg( $a['url'], 'v' );
159
  $yt_list = Common\get_url_arg( $a['url'], 'list' );
160
 
161
+ if ( $oembed_src &&
162
+ str_contains( $src, '/embed/videoseries?' ) &&
163
  $yt_v
164
  ) {
165
+ $src = str_replace( '/embed/videoseries?', "/embed/$yt_v?", $src );
166
  }
167
 
168
  if ( $yt_list ) {
169
+ $src = remove_query_arg( 'feature', $src );
170
+ $src = add_query_arg( 'list', $yt_list, $src );
171
+ }
172
+
173
+ $options = options();
174
+
175
+ if ( $options['youtube_nocookie'] ) {
176
+ $src = str_replace( 'https://www.youtube.com', 'https://www.youtube-nocookie.com', $src );
177
  }
178
+
179
  break;
180
  case 'vimeo':
181
+ $src = add_query_arg( 'dnt', 1, $src );
 
182
 
183
  $parsed_url = wp_parse_url( $a['url'] );
184
 
185
  if ( ! empty( $parsed_url['fragment'] ) && str_starts_with( $parsed_url['fragment'], 't' ) ) {
186
+ $src .= '#' . $parsed_url['fragment'];
 
187
  }
188
  break;
189
  case 'wistia':
190
+ $src = add_query_arg( 'dnt', 1, $src );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  break;
192
  }
193