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

Version Description

Download this release

Release Info

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

Code changes from version 9.0.0-beta7 to 9.0.0-beta8

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.0.0-beta7
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.0.0-beta7';
25
  const PRO_VERSION_REQUIRED = '5.0.0-beta5';
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.0.0-beta8
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.0.0-beta8';
25
  const PRO_VERSION_REQUIRED = '5.0.0-beta5';
26
  const NUM_TRACKS = 3;
27
  const PLUGIN_FILE = __FILE__;
php/Common/Admin/functions-settings.php CHANGED
@@ -16,7 +16,7 @@ function label_text( $option ) {
16
 
17
  printf(
18
  ' <a href="https://nextgenthemes.com/plugins/arve-%s">(%s)</a>',
19
- esc_attr( $option['tag'] ),
20
  esc_html( ucfirst( $option['tag'] ) . ' Addon' )
21
  );
22
  }
16
 
17
  printf(
18
  ' <a href="https://nextgenthemes.com/plugins/arve-%s">(%s)</a>',
19
+ esc_attr( str_replace( 'randomvideo', 'random-video', $option['tag'] ) ),
20
  esc_html( ucfirst( $option['tag'] ) . ' Addon' )
21
  );
22
  }
php/functions-settings.php CHANGED
@@ -1,11 +1,6 @@
1
  <?php
2
  namespace Nextgenthemes\ARVE;
3
 
4
- function setup_settings() {
5
- settings_instance();
6
- upgrade_options();
7
- }
8
-
9
  function options() {
10
  $i = settings_instance();
11
  return $i->get_options();
@@ -33,6 +28,8 @@ function settings_instance() {
33
  );
34
  }
35
 
 
 
36
  return $inst;
37
  }
38
 
@@ -166,31 +163,33 @@ function shortcode_pairs() {
166
  return apply_filters( 'nextgenthemes/arve/shortcode_pairs', $pairs );
167
  }
168
 
169
- function upgrade_options() {
170
 
171
- $options_ver = get_option( 'nextgenthemes_arve_options_ver' );
 
172
 
173
- if ( \version_compare( $options_ver, '9.0', '>=' ) ) {
174
  return;
175
  }
176
 
177
- $new_options = options();
178
- $old_options = get_option( 'arve_options_main' );
179
- $old_params = get_option( 'arve_options_params' );
180
- $old_pro_options = get_option( 'arve_options_pro' );
 
181
 
182
- if ( ! empty( $old_pro_options ) && is_array( $old_pro_options ) ) {
183
  $old_options = array_merge( $old_options, $old_pro_options );
184
  }
185
 
186
- if ( ! empty( $old_params ) && is_array( $old_params ) ) {
187
 
188
  foreach ( $old_params as $provider => $params ) {
189
  $old_options[ 'url_params_' . $provider ] = $params;
190
  }
191
  }
192
 
193
- if ( ! empty( $old_options ) && is_array( $old_options ) ) {
194
 
195
  if ( isset( $old_options['promote_link'] ) ) {
196
  $old_options['arve_link'] = $old_options['promote_link'];
@@ -200,9 +199,18 @@ function upgrade_options() {
200
  $old_options['maxwidth'] = $old_options['video_maxwidth'];
201
  }
202
 
203
- $new_options = array_diff_assoc( $old_options, default_options() );
 
 
 
 
 
 
 
 
 
204
  update_option( 'nextgenthemes_arve', $new_options );
205
- update_option( 'nextgenthemes_arve_options_ver', '9.0' );
206
  }
207
  }
208
 
1
  <?php
2
  namespace Nextgenthemes\ARVE;
3
 
 
 
 
 
 
4
  function options() {
5
  $i = settings_instance();
6
  return $i->get_options();
28
  );
29
  }
30
 
31
+ upgrade_options( $inst );
32
+
33
  return $inst;
34
  }
35
 
163
  return apply_filters( 'nextgenthemes/arve/shortcode_pairs', $pairs );
164
  }
165
 
166
+ function upgrade_options( $settings_instance ) {
167
 
168
+ $options_ver = get_option( 'nextgenthemes_arve_options_ver' );
169
+ $options_ver_when_done = '9.0.0-beta8';
170
 
171
+ if ( \version_compare( $options_ver, $options_ver_when_done, '>=' ) ) {
172
  return;
173
  }
174
 
175
+ $new_options = $settings_instance->get_options();
176
+ $default_options = $settings_instance->get_options_defaults();
177
+ $old_options = (array) get_option( 'arve_options_main' );
178
+ $old_params = (array) get_option( 'arve_options_params' );
179
+ $old_pro_options = (array) get_option( 'arve_options_pro' );
180
 
181
+ if ( ! empty( $old_pro_options ) ) {
182
  $old_options = array_merge( $old_options, $old_pro_options );
183
  }
184
 
185
+ if ( ! empty( $old_params ) ) {
186
 
187
  foreach ( $old_params as $provider => $params ) {
188
  $old_options[ 'url_params_' . $provider ] = $params;
189
  }
190
  }
191
 
192
+ if ( ! empty( $old_options ) ) {
193
 
194
  if ( isset( $old_options['promote_link'] ) ) {
195
  $old_options['arve_link'] = $old_options['promote_link'];
199
  $old_options['maxwidth'] = $old_options['video_maxwidth'];
200
  }
201
 
202
+ // Not storing options with default values
203
+ $new_options = array_diff_assoc( $old_options, $default_options );
204
+
205
+ // Filter out options that got removed or renamed
206
+ foreach ( $new_options as $key => $val ) {
207
+ if ( ! array_key_exists( $key, $default_options ) ) {
208
+ unset( $new_options[ $key ] );
209
+ }
210
+ }
211
+
212
  update_option( 'nextgenthemes_arve', $new_options );
213
+ update_option( 'nextgenthemes_arve_options_ver', $options_ver_when_done );
214
  }
215
  }
216
 
php/functions-shortcode-filters.php CHANGED
@@ -3,6 +3,10 @@ namespace Nextgenthemes\ARVE;
3
 
4
  function sc_filter_set_uid( array $a ) {
5
 
 
 
 
 
6
  static $i = 1;
7
 
8
  $a['uid'] = sanitize_key( uniqid( "arve-{$a['provider']}-{$a['id']}-$i", true) );
@@ -14,6 +18,10 @@ function sc_filter_set_uid( array $a ) {
14
 
15
  function sc_filter_aspect_ratio( array $a ) {
16
 
 
 
 
 
17
  if ( ! empty( $a['aspect_ratio'] ) ) {
18
  return $a;
19
  }
@@ -41,6 +49,10 @@ function sc_filter_aspect_ratio( array $a ) {
41
 
42
  function sc_filter_dimensions( array $a ) {
43
 
 
 
 
 
44
  $a['width'] = $a['maxwidth'];
45
 
46
  if ( $a['aspect_ratio'] ) {
@@ -52,6 +64,10 @@ function sc_filter_dimensions( array $a ) {
52
 
53
  function sc_filter_maxwidth( array $a ) {
54
 
 
 
 
 
55
  $options = options();
56
 
57
  if ( empty( $a['maxwidth'] ) ) {
@@ -74,6 +90,10 @@ function sc_filter_maxwidth( array $a ) {
74
 
75
  function sc_filter_liveleak_id_fix( array $a ) {
76
 
 
 
 
 
77
  if ( 'liveleak' !== $a['provider'] ) {
78
  return $a;
79
  }
@@ -91,6 +111,10 @@ function sc_filter_liveleak_id_fix( array $a ) {
91
 
92
  function sc_filter_mode( array $a ) {
93
 
 
 
 
 
94
  if ( in_array( $a['mode'], [ 'lazyload-lightbox', 'thumbnail' ], true ) ) {
95
  $a['mode'] = 'lightbox';
96
  }
@@ -113,6 +137,10 @@ function sc_filter_mode( array $a ) {
113
 
114
  function sc_filter_validate( array $a ) {
115
 
 
 
 
 
116
  foreach ( $a as $key => $value ) {
117
 
118
  switch ( $key ) {
@@ -157,6 +185,10 @@ function sc_filter_validate( array $a ) {
157
 
158
  function sc_filter_validate_again( array $a ) {
159
 
 
 
 
 
160
  if ( 'html5' !== $a['provider'] ) {
161
 
162
  if ( ! is_int( $a['width'] ) ) {
@@ -187,6 +219,10 @@ function sc_filter_validate_again( array $a ) {
187
 
188
  function sc_filter_autoplay( array $a ) {
189
 
 
 
 
 
190
  if ( 'normal' === $a['mode'] ) { // Prevent more then one vid autoplaying
191
 
192
  static $did_run = false;
@@ -203,14 +239,32 @@ function sc_filter_autoplay( array $a ) {
203
  return apply_filters( 'nextgenthemes/arve/sc_filter/autoplay', $a );
204
  }
205
 
 
 
 
 
206
  function sc_filter_missing_attribute_check( array $a ) {
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  // Old shortcodes
209
  if ( $a['legacy_sc'] ) {
210
 
211
  if ( ! $a['id'] || ! $a['provider'] ) {
212
  $a['errors']->add( 'fatal', 'need id and provider' );
213
- remove_all_filters( 'shortcode_atts_arve' );
214
  }
215
 
216
  return $a;
@@ -244,6 +298,10 @@ function sc_filter_missing_attribute_check( array $a ) {
244
 
245
  function sc_filter_thumbnail( array $a ) {
246
 
 
 
 
 
247
  $a = apply_filters( 'nextgenthemes/arve/sc_filter/thumbnail', $a );
248
 
249
  if ( $a['thumbnail'] ) :
@@ -274,6 +332,10 @@ function sc_filter_thumbnail( array $a ) {
274
 
275
  function sc_filter_video( array $a ) {
276
 
 
 
 
 
277
  foreach ( VIDEO_FILE_EXTENSIONS as $ext ) {
278
 
279
  if ( ! empty( $a[ $ext ] ) && is_numeric( $a[ $ext ] ) ) {
@@ -286,6 +348,10 @@ function sc_filter_video( array $a ) {
286
 
287
  function sc_filter_detect_provider_and_id_from_url( array $a ) {
288
 
 
 
 
 
289
  if ( 'html5' === $a['provider'] ||
290
  ( $a['provider'] && $a['id'] )
291
  ) {
@@ -297,7 +363,6 @@ function sc_filter_detect_provider_and_id_from_url( array $a ) {
297
  'fatal',
298
  __( 'sc_filter_detect_provider_and_id_from_url function needs url.', 'advanced-responsive-video-embedder' )
299
  );
300
- remove_all_filters( 'shortcode_atts_arve' );
301
  return $a;
302
  }
303
 
@@ -381,6 +446,10 @@ function special_iframe_src_mods( array $a ) {
381
 
382
  function sc_filter_iframe_src( array $a ) {
383
 
 
 
 
 
384
  if ( 'html5' === $a['provider'] ) {
385
  return $a;
386
  }
@@ -656,6 +725,10 @@ function get_video_type( $ext ) {
656
 
657
  function sc_filter_detect_html5( array $a ) {
658
 
 
 
 
 
659
  if ( $a['provider'] && 'html5' !== $a['provider'] ) {
660
  return $a;
661
  }
3
 
4
  function sc_filter_set_uid( array $a ) {
5
 
6
+ if ( has_fatal_error( $a ) ) {
7
+ return $a;
8
+ }
9
+
10
  static $i = 1;
11
 
12
  $a['uid'] = sanitize_key( uniqid( "arve-{$a['provider']}-{$a['id']}-$i", true) );
18
 
19
  function sc_filter_aspect_ratio( array $a ) {
20
 
21
+ if ( has_fatal_error( $a ) ) {
22
+ return $a;
23
+ }
24
+
25
  if ( ! empty( $a['aspect_ratio'] ) ) {
26
  return $a;
27
  }
49
 
50
  function sc_filter_dimensions( array $a ) {
51
 
52
+ if ( has_fatal_error( $a ) ) {
53
+ return $a;
54
+ }
55
+
56
  $a['width'] = $a['maxwidth'];
57
 
58
  if ( $a['aspect_ratio'] ) {
64
 
65
  function sc_filter_maxwidth( array $a ) {
66
 
67
+ if ( has_fatal_error( $a ) ) {
68
+ return $a;
69
+ }
70
+
71
  $options = options();
72
 
73
  if ( empty( $a['maxwidth'] ) ) {
90
 
91
  function sc_filter_liveleak_id_fix( array $a ) {
92
 
93
+ if ( has_fatal_error( $a ) ) {
94
+ return $a;
95
+ }
96
+
97
  if ( 'liveleak' !== $a['provider'] ) {
98
  return $a;
99
  }
111
 
112
  function sc_filter_mode( array $a ) {
113
 
114
+ if ( has_fatal_error( $a ) ) {
115
+ return $a;
116
+ }
117
+
118
  if ( in_array( $a['mode'], [ 'lazyload-lightbox', 'thumbnail' ], true ) ) {
119
  $a['mode'] = 'lightbox';
120
  }
137
 
138
  function sc_filter_validate( array $a ) {
139
 
140
+ if ( has_fatal_error( $a ) ) {
141
+ return $a;
142
+ }
143
+
144
  foreach ( $a as $key => $value ) {
145
 
146
  switch ( $key ) {
185
 
186
  function sc_filter_validate_again( array $a ) {
187
 
188
+ if ( has_fatal_error( $a ) ) {
189
+ return $a;
190
+ }
191
+
192
  if ( 'html5' !== $a['provider'] ) {
193
 
194
  if ( ! is_int( $a['width'] ) ) {
219
 
220
  function sc_filter_autoplay( array $a ) {
221
 
222
+ if ( has_fatal_error( $a ) ) {
223
+ return $a;
224
+ }
225
+
226
  if ( 'normal' === $a['mode'] ) { // Prevent more then one vid autoplaying
227
 
228
  static $did_run = false;
239
  return apply_filters( 'nextgenthemes/arve/sc_filter/autoplay', $a );
240
  }
241
 
242
+ function has_fatal_error( array $a ) {
243
+ ( '' !== $a['errors']->get_error_message( 'fatal' ) ) ? true : false;
244
+ }
245
+
246
  function sc_filter_missing_attribute_check( array $a ) {
247
 
248
+ if ( has_fatal_error( $a ) ) {
249
+ return $a;
250
+ }
251
+
252
+ // Old shortcodes
253
+ if ( ! is_wp_error( $a['errors'] ) ) {
254
+
255
+ $a['errors'] = new \WP_Error();
256
+
257
+ $msg = 'WP Error was not initialized, attributes were: <pre>' . var_export( $a, true ) . '</pre>';
258
+ $a['errors']->add( 'no-wp-error', $msg );
259
+
260
+ return $a;
261
+ }
262
+
263
  // Old shortcodes
264
  if ( $a['legacy_sc'] ) {
265
 
266
  if ( ! $a['id'] || ! $a['provider'] ) {
267
  $a['errors']->add( 'fatal', 'need id and provider' );
 
268
  }
269
 
270
  return $a;
298
 
299
  function sc_filter_thumbnail( array $a ) {
300
 
301
+ if ( has_fatal_error( $a ) ) {
302
+ return $a;
303
+ }
304
+
305
  $a = apply_filters( 'nextgenthemes/arve/sc_filter/thumbnail', $a );
306
 
307
  if ( $a['thumbnail'] ) :
332
 
333
  function sc_filter_video( array $a ) {
334
 
335
+ if ( has_fatal_error( $a ) ) {
336
+ return $a;
337
+ }
338
+
339
  foreach ( VIDEO_FILE_EXTENSIONS as $ext ) {
340
 
341
  if ( ! empty( $a[ $ext ] ) && is_numeric( $a[ $ext ] ) ) {
348
 
349
  function sc_filter_detect_provider_and_id_from_url( array $a ) {
350
 
351
+ if ( has_fatal_error( $a ) ) {
352
+ return $a;
353
+ }
354
+
355
  if ( 'html5' === $a['provider'] ||
356
  ( $a['provider'] && $a['id'] )
357
  ) {
363
  'fatal',
364
  __( 'sc_filter_detect_provider_and_id_from_url function needs url.', 'advanced-responsive-video-embedder' )
365
  );
 
366
  return $a;
367
  }
368
 
446
 
447
  function sc_filter_iframe_src( array $a ) {
448
 
449
+ if ( has_fatal_error( $a ) ) {
450
+ return $a;
451
+ }
452
+
453
  if ( 'html5' === $a['provider'] ) {
454
  return $a;
455
  }
725
 
726
  function sc_filter_detect_html5( array $a ) {
727
 
728
+ if ( has_fatal_error( $a ) ) {
729
+ return $a;
730
+ }
731
+
732
  if ( $a['provider'] && 'html5' !== $a['provider'] ) {
733
  return $a;
734
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: YouTube, Vimeo, lazyload, thumbnail, video, responsive, embeds, video-embe
5
  Requires at least: 4.4.0
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
- Stable tag: 9.0.0-beta7
9
  License: GPL-3.0
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -16,6 +16,11 @@ Easy responsive video embeds via URLs or shortcodes. Perfect drop-in replacement
16
  * [ARVE Pro addon changelog](https://nextgenthemes.com/plugins/arve-pro/changelog/)
17
  * [ARVE AMP addon changelog](https://nextgenthemes.com/plugins/arve-amp/)
18
 
 
 
 
 
 
19
  ### 2020-12-02 9.0.0-beta7 ###
20
 
21
  * Fix: YouTube timestamp urls not working with only seconds `t=1234`.
5
  Requires at least: 4.4.0
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
+ Stable tag: 9.0.0-beta8
9
  License: GPL-3.0
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
16
  * [ARVE Pro addon changelog](https://nextgenthemes.com/plugins/arve-pro/changelog/)
17
  * [ARVE AMP addon changelog](https://nextgenthemes.com/plugins/arve-amp/)
18
 
19
+ ### 2020-12-09 9.0.0-beta8 ###
20
+
21
+ * New: Transfer settings from version 8.0 to version 9.0. [Sorry](https://api.ipfsbrowser.com/ipfs/get.php?hash=QmTHuTcq4iYsoHYomBwV7Xp3KSuLVT1pAnoWQP5uH78d3A) this was supposed to work with the first 9.0 beta.
22
+ * Fix: Issues with error handling.
23
+
24
  ### 2020-12-02 9.0.0-beta7 ###
25
 
26
  * Fix: YouTube timestamp urls not working with only seconds `t=1234`.