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

Version Description

Download this release

Release Info

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

Code changes from version 9.5.1-beta6 to 9.5.1-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.5.1-beta6
7
  * Author: Nicolas Jonas
8
  * Author URI: https://nextgenthemes.com
9
  * License: GPL-3.0
@@ -19,7 +19,7 @@
19
 
20
  namespace Nextgenthemes\ARVE;
21
 
22
- const VERSION = '9.5.1-beta6';
23
  const PRO_VERSION_REQUIRED = '5.1.11';
24
  const NUM_TRACKS = 3;
25
  const PLUGIN_FILE = __FILE__;
@@ -28,23 +28,3 @@ const VIDEO_FILE_EXTENSIONS = array( 'av1mp4', 'mp4', 'm4v', 'webm', 'ogv' );
28
  const DEFAULT_MAXWIDTH = 900;
29
 
30
  require_once __DIR__ . '/php/init.php';
31
-
32
- register_activation_hook( __FILE__, __NAMESPACE__ . '\activation_hook' );
33
- function activation_hook() {
34
- update_option( 'nextgenthemes_arve_oembed_recache', time() );
35
- }
36
-
37
- register_deactivation_hook( __FILE__, __NAMESPACE__ . '\delete_oembed_cache' );
38
- register_uninstall_hook( __FILE__, __NAMESPACE__ . '\delete_oembed_cache' );
39
-
40
- function delete_oembed_cache() {
41
- global $wpdb;
42
-
43
- $wpdb->query(
44
- $wpdb->prepare(
45
- "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s AND meta_value LIKE %s",
46
- '%_oembed_%',
47
- '%' . $wpdb->esc_like( 'data-arve-oembed' ) . '%'
48
- )
49
- );
50
- }
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.5.1-beta8
7
  * Author: Nicolas Jonas
8
  * Author URI: https://nextgenthemes.com
9
  * License: GPL-3.0
19
 
20
  namespace Nextgenthemes\ARVE;
21
 
22
+ const VERSION = '9.5.1-beta8';
23
  const PRO_VERSION_REQUIRED = '5.1.11';
24
  const NUM_TRACKS = 3;
25
  const PLUGIN_FILE = __FILE__;
28
  const DEFAULT_MAXWIDTH = 900;
29
 
30
  require_once __DIR__ . '/php/init.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
changelog.md CHANGED
@@ -4,6 +4,10 @@
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-02-13 9.5.1-beta1 ###
8
 
9
  * New video hosts support for
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-02-13 9.5.1-beta7 ###
8
+
9
+ * Fixed and further simplified oembed caching.
10
+
11
  ### 2021-02-13 9.5.1-beta1 ###
12
 
13
  * New video hosts support for
php/Admin/functions-settings-page.php CHANGED
@@ -67,8 +67,6 @@ function print_settings_box_html( $file ) {
67
 
68
  function filter_save_options( $options ) {
69
 
70
- update_option( 'nextgenthemes_arve_oembed_recache', time() );
71
-
72
  $action = json_decode( $options['action'] );
73
  $options['action'] = '';
74
 
67
 
68
  function filter_save_options( $options ) {
69
 
 
 
70
  $action = json_decode( $options['action'] );
71
  $options['action'] = '';
72
 
php/Common/Settings.php CHANGED
@@ -85,8 +85,6 @@ class Settings {
85
 
86
  $options[ $action->product . '_status' ] = api_action( $product_id, $product_key, $action->action );
87
  }
88
- } elseif ( 'nextgenthemes_arve' === $this->slugged_namespace ) {
89
- update_option( 'nextgenthemes_arve_oembed_recache', time() );
90
  }
91
 
92
  // remove all items from options that are not also in defaults.
85
 
86
  $options[ $action->product . '_status' ] = api_action( $product_id, $product_key, $action->action );
87
  }
 
 
88
  }
89
 
90
  // remove all items from options that are not also in defaults.
php/functions-html-output.php CHANGED
@@ -55,7 +55,9 @@ function build_iframe_tag( array $a ) {
55
  }
56
 
57
  if ( 'wistia' === $a['provider'] ) {
58
- $class .= ' wistia_embed';
 
 
59
  }
60
 
61
  if ( 'zoom' === $a['provider'] ) {
55
  }
56
 
57
  if ( 'wistia' === $a['provider'] ) {
58
+ $class .= ' wistia_embed';
59
+ $sandbox .= ' allow-forms';
60
+
61
  }
62
 
63
  if ( 'zoom' === $a['provider'] ) {
php/functions-oembed.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  namespace Nextgenthemes\ARVE;
3
 
4
- const JSON_REGEX = '#<script data-arve-oembed type="application/json">(?<json>{[^}]+})</script>#i';
 
5
 
6
  /**
7
  * Info: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-oembed.php
@@ -17,13 +18,13 @@ function add_oembed_providers() {
17
  function filter_oembed_dataparse( $result, $data, $url ) {
18
 
19
  if ( $data && 'video' === $data->type ) {
20
-
 
21
  $data->arve_cachetime = time();
22
-
23
  if ( 'YouTube' === $data->provider_name ) {
24
  $data->arve_srcset = yt_srcset( $data->thumbnail_url );
25
  }
26
- $result .= '<script data-arve-oembed type="application/json">' . \wp_json_encode( $data, JSON_PRETTY_PRINT ) . '</script>';
27
  }
28
 
29
  return $result;
@@ -31,14 +32,10 @@ function filter_oembed_dataparse( $result, $data, $url ) {
31
 
32
  function filter_embed_oembed_html( $cache, $url, array $attr, $post_ID ) {
33
 
34
- if ( disabled_on_feeds() ) {
35
- return \preg_replace( JSON_REGEX, '', $cache, 1 );
36
- }
37
-
38
- \preg_match( JSON_REGEX, $cache, $matches );
39
 
40
- if ( ! empty( $matches['json'] ) ) {
41
- $attr['oembed_data'] = json_decode( $matches['json'] );
42
  $attr['url'] = $url;
43
  $attr['post_id'] = (string) $post_ID;
44
 
@@ -90,59 +87,3 @@ function vimeo_referer( $args, $url ) {
90
 
91
  return $args;
92
  }
93
-
94
- function trigger_cache_rebuild( $ttl, $url, $attr, $post_id ) {
95
-
96
- if ( did_action( 'nextgenthemes/arve/oembed_recache' ) ) {
97
- return $ttl;
98
- }
99
-
100
- // Get the time when oEmbed HTML was last cached (based on the WP_Embed class)
101
- $key_suffix = md5( $url . serialize( $attr ) ); // phpcs:ignore
102
- $cachekey_time = '_oembed_time_' . $key_suffix;
103
- $cache_time = get_post_meta( $post_id, $cachekey_time, true );
104
-
105
- // Get the cached HTML
106
- $cachekey = '_oembed_' . $key_suffix;
107
- $metadata = get_post_custom( $post_id );
108
- $cache_exists = isset( $metadata[ $cachekey ][0] );
109
- $cache_html = $cache_exists ? strtolower( get_post_meta( $post_id, $cachekey, true ) ) : false;
110
- // $cache_exists2 = metadata_exists( 'post', $post_id, $cachekey ); // TODO not sure of 'post' is always right for embeds outside of
111
-
112
- // time after a recache should be done
113
- $trigger_time = get_option( 'nextgenthemes_arve_oembed_recache' );
114
-
115
- $not_touching = array(
116
- 'platform.twitter.com',
117
- 'embed.redditmedia.com',
118
- 'embedr.flickr.com',
119
- 'open.spotify.com',
120
- 'secure.polldaddy.com',
121
- 'embed.tumblr.com',
122
- 'imgur.com',
123
- );
124
-
125
- // Check if we need to regenerate the oEmbed HTML:
126
- if ( $cache_exists &&
127
- $cache_time < $trigger_time &&
128
- ! Common\str_contains_any( $cache_html, $not_touching ) &&
129
- $GLOBALS['wp_embed']->usecache
130
- ) {
131
- // What we need to skip the oembed cache part
132
- $GLOBALS['wp_embed']->usecache = false;
133
- $ttl = 0;
134
-
135
- do_action( 'nextgenthemes/arve/oembed_recache' );
136
- }
137
-
138
- return $ttl;
139
- }
140
-
141
- function reenable_oembed_cache( $discover ) {
142
-
143
- if ( did_action( 'nextgenthemes/arve/oembed_recache' ) ) {
144
- $GLOBALS['wp_embed']->usecache = true;
145
- }
146
-
147
- return $discover;
148
- }
1
  <?php
2
  namespace Nextgenthemes\ARVE;
3
 
4
+ const JSON_REGEX = '#<script type="application/json" data-arve-oembed>({[^}]+})</script>#s';
5
+ const DATA_REGEX = '#(?<=data-arve-oembed>).*?(?=</script>)#s';
6
 
7
  /**
8
  * Info: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-oembed.php
18
  function filter_oembed_dataparse( $result, $data, $url ) {
19
 
20
  if ( $data && 'video' === $data->type ) {
21
+ $data->html = str_replace( '<script', '<ESCAPED-cript', $data->html );
22
+ $data->html = str_replace( '</script', '</ESCAPED-cript', $data->html );
23
  $data->arve_cachetime = time();
 
24
  if ( 'YouTube' === $data->provider_name ) {
25
  $data->arve_srcset = yt_srcset( $data->thumbnail_url );
26
  }
27
+ $result .= '<script type="text" data-arve-oembed>' . \serialize( $data ) . '</script>';
28
  }
29
 
30
  return $result;
32
 
33
  function filter_embed_oembed_html( $cache, $url, array $attr, $post_ID ) {
34
 
35
+ \preg_match( '#(?<=data-arve-oembed>).*?(?=</script>)#s', $cache, $matches );
 
 
 
 
36
 
37
+ if ( ! empty( $matches[0] ) ) {
38
+ $attr['oembed_data'] = unserialize( $matches[0] );
39
  $attr['url'] = $url;
40
  $attr['post_id'] = (string) $post_ID;
41
 
87
 
88
  return $args;
89
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
php/init.php CHANGED
@@ -12,8 +12,8 @@ function init_public() {
12
 
13
  add_option( 'arve_install_date', time() );
14
 
15
- if ( version_compare( get_option( 'arve_version' ), '9.5.0', '<' ) ) {
16
- update_option( 'nextgenthemes_arve_oembed_recache', time() );
17
  }
18
  update_option( 'arve_version', VERSION );
19
 
@@ -41,8 +41,6 @@ function init_public() {
41
  add_filter( 'language_attributes', __NAMESPACE__ . '\html_id' );
42
  add_filter( 'oembed_dataparse', __NAMESPACE__ . '\filter_oembed_dataparse', 11, 3 );
43
  add_filter( 'embed_oembed_html', __NAMESPACE__ . '\filter_embed_oembed_html', 20, 4 );
44
- add_filter( 'oembed_ttl', __NAMESPACE__ . '\trigger_cache_rebuild', 10, 4 );
45
- add_filter( 'embed_oembed_discover', __NAMESPACE__ . '\reenable_oembed_cache' );
46
  }
47
 
48
  function init_admin() {
12
 
13
  add_option( 'arve_install_date', time() );
14
 
15
+ if ( version_compare( get_option( 'arve_version' ), '9.5.1-beta7', '<' ) ) {
16
+ $GLOBALS['wpdb']->query( "DELETE FROM {$GLOBALS['wpdb']->postmeta} WHERE meta_key LIKE '%_oembed_%'" );
17
  }
18
  update_option( 'arve_version', VERSION );
19
 
41
  add_filter( 'language_attributes', __NAMESPACE__ . '\html_id' );
42
  add_filter( 'oembed_dataparse', __NAMESPACE__ . '\filter_oembed_dataparse', 11, 3 );
43
  add_filter( 'embed_oembed_html', __NAMESPACE__ . '\filter_embed_oembed_html', 20, 4 );
 
 
44
  }
45
 
46
  function init_admin() {
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: YouTube, Vimeo, lazyload, thumbnail, video, responsive, embeds, video-embe
5
  Requires at least: 4.9.16
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
- Stable tag: 9.5.1-beta6
9
  License: GPL-3.0
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -56,6 +56,7 @@ It is very likely the one and only plugin you will ever need to handle video emb
56
 
57
  [All providers with iframe embed codes](https://nextgenthemes.com/plugins/arve/documentation/#general-iframe-embedding)
58
  Alugha, Archive.org, Banned.video, Bitchute, Break, Mail.ru, Brightcove, cantcensortruth.com, Comedy Central, Dailymotion, Dailymotion Playlist, DTube, Facebook, Google Drive, mp4 or webm video files, ARVE general iframe embed, IGN, IMDB, Kickstarter, kla.tv, LiveLeak, Livestream.com, Metacafe, myspace, ooyala, Rumble.com, RuTube.ru, Snotr, Spike, TED Talks, Twitch, Ustream, Viddler, Vimeo, VK, vzaar, Wistia, XTube, Yahoo, Youku, YouTube, YouTube Playlist
 
59
  ### Reviews ###
60
 
61
  #### &#9733; &#9733; &#9733; &#9733; &#9733; Great plugin, great support ####
@@ -172,6 +173,11 @@ Please read the [official documentation](https://wordpress.org/support/article/m
172
  * [ARVE Pro changelog](https://nextgenthemes.com/plugins/arve-pro/#changelog)
173
  * [ARVE Random Videos changelog](https://nextgenthemes.com/plugins/random-video/#changelog)
174
 
 
 
 
 
 
175
  ### 2021-02-13 9.5.1-beta1 ###
176
 
177
  * New video hosts support for
5
  Requires at least: 4.9.16
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
+ Stable tag: 9.4.2
9
  License: GPL-3.0
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
56
 
57
  [All providers with iframe embed codes](https://nextgenthemes.com/plugins/arve/documentation/#general-iframe-embedding)
58
  Alugha, Archive.org, Banned.video, Bitchute, Break, Mail.ru, Brightcove, cantcensortruth.com, Comedy Central, Dailymotion, Dailymotion Playlist, DTube, Facebook, Google Drive, mp4 or webm video files, ARVE general iframe embed, IGN, IMDB, Kickstarter, kla.tv, LiveLeak, Livestream.com, Metacafe, myspace, ooyala, Rumble.com, RuTube.ru, Snotr, Spike, TED Talks, Twitch, Ustream, Viddler, Vimeo, VK, vzaar, Wistia, XTube, Yahoo, Youku, YouTube, YouTube Playlist
59
+
60
  ### Reviews ###
61
 
62
  #### &#9733; &#9733; &#9733; &#9733; &#9733; Great plugin, great support ####
173
  * [ARVE Pro changelog](https://nextgenthemes.com/plugins/arve-pro/#changelog)
174
  * [ARVE Random Videos changelog](https://nextgenthemes.com/plugins/random-video/#changelog)
175
 
176
+ ### 2021-02-13 9.5.1-beta7 ###
177
+
178
+ * Fixed and further simplified oembed caching.
179
+ * Improved: Allow forms for Wistia.
180
+
181
  ### 2021-02-13 9.5.1-beta1 ###
182
 
183
  * New video hosts support for