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

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-beta12
Comparing to
See all releases

Code changes from version 9.0.0-beta11 to 9.0.0-beta12

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-beta11
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-beta11';
25
  const PRO_VERSION_REQUIRED = '5.0.0-beta5';
26
  const NUM_TRACKS = 3;
27
  const PLUGIN_FILE = __FILE__;
@@ -115,16 +115,18 @@ function activation_hook() {
115
  update_option( 'nextgenthemes_arve_oembed_recache', time() );
116
  }
117
 
118
- register_uninstall_hook( __FILE__, __NAMESPACE__ . '\uninstall_hook' );
119
- function uninstall_hook() {
120
 
 
121
  global $wpdb;
122
 
123
  $wpdb->query(
124
  $wpdb->prepare(
125
- "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s AND meta_value LIKE %s",
126
  '%_oembed_%',
127
- '%' . $wpdb->esc_like( 'id="arve-' ) . '%'
 
128
  )
129
  );
130
  }
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-beta12
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-beta12';
25
  const PRO_VERSION_REQUIRED = '5.0.0-beta5';
26
  const NUM_TRACKS = 3;
27
  const PLUGIN_FILE = __FILE__;
115
  update_option( 'nextgenthemes_arve_oembed_recache', time() );
116
  }
117
 
118
+ register_deactivation_hook( __FILE__, __NAMESPACE__ . '\delete_oembed_cache' );
119
+ register_uninstall_hook( __FILE__, __NAMESPACE__ . '\delete_oembed_cache' );
120
 
121
+ function delete_oembed_cache() {
122
  global $wpdb;
123
 
124
  $wpdb->query(
125
  $wpdb->prepare(
126
+ "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s AND (meta_value LIKE %s OR meta_value LIKE %s)",
127
  '%_oembed_%',
128
+ '%' . $wpdb->esc_like( 'id="arve' ) . '%',
129
+ '%' . $wpdb->esc_like( 'Advanced Responsive Video Embedder' ) . '%'
130
  )
131
  );
132
  }
php/functions-host-properties.php CHANGED
@@ -367,7 +367,7 @@ function get_host_properties() {
367
  ],
368
  'twitch' => [
369
  'name' => 'Twitch',
370
- 'oembed' => true,
371
  'regex' => '#https?://(www\.)?twitch.tv/(?!directory)(?|[a-z0-9_]+/v/(?<id>[0-9]+)|(?<id>[a-z0-9_]+))#i',
372
  'embed_url' => 'https://player.twitch.tv/?channel=%s', # if numeric id https://player.twitch.tv/?video=v%s
373
  'auto_thumbnail' => true,
@@ -608,10 +608,10 @@ function get_host_properties() {
608
  'url' => 'http://www.youtube.com/watch?v=GjL82KUHVb0&list=PLI46g-I12_9qGBq-4epxOay0hotjys5iA&index=10', # The index part will be ignored
609
  'id' => 'GjL82KUHVb0&list=PLI46g-I12_9qGBq-4epxOay0hotjys5iA',
610
  ],
611
- // [
612
- // 'url' => 'https://youtu.be/b8m9zhNAgKs?list=PLI_7Mg2Z_-4I-W_lI55D9lBUkC66ftHMg',
613
- // 'id' => 'b8m9zhNAgKs?list=PLI_7Mg2Z_-4I-W_lI55D9lBUkC66ftHMg',
614
- // ],
615
  ],
616
  'specific_tests' => [
617
  __( 'URL from youtu.be shortener', 'advanced-responsive-video-embedder' ),
367
  ],
368
  'twitch' => [
369
  'name' => 'Twitch',
370
+ 'oembed' => false,
371
  'regex' => '#https?://(www\.)?twitch.tv/(?!directory)(?|[a-z0-9_]+/v/(?<id>[0-9]+)|(?<id>[a-z0-9_]+))#i',
372
  'embed_url' => 'https://player.twitch.tv/?channel=%s', # if numeric id https://player.twitch.tv/?video=v%s
373
  'auto_thumbnail' => true,
608
  'url' => 'http://www.youtube.com/watch?v=GjL82KUHVb0&list=PLI46g-I12_9qGBq-4epxOay0hotjys5iA&index=10', # The index part will be ignored
609
  'id' => 'GjL82KUHVb0&list=PLI46g-I12_9qGBq-4epxOay0hotjys5iA',
610
  ],
611
+ [
612
+ 'url' => 'https://youtu.be/b8m9zhNAgKs?list=PLI_7Mg2Z_-4I-W_lI55D9lBUkC66ftHMg',
613
+ 'id' => 'b8m9zhNAgKs?list=PLI_7Mg2Z_-4I-W_lI55D9lBUkC66ftHMg',
614
+ ],
615
  ],
616
  'specific_tests' => [
617
  __( 'URL from youtu.be shortener', 'advanced-responsive-video-embedder' ),
php/functions-oembed.php CHANGED
@@ -6,12 +6,6 @@ namespace Nextgenthemes\ARVE;
6
  * https://github.com/iamcal/oembed/tree/master/providers
7
  */
8
  function add_oembed_providers() {
9
- wp_oembed_add_provider( 'http://clips.twitch.tv/*', 'https://api.twitch.tv/v5/oembed' );
10
- wp_oembed_add_provider( 'https://clips.twitch.tv/*', 'https://api.twitch.tv/v5/oembed' );
11
- wp_oembed_add_provider( 'http://www.twitch.tv/*', 'https://api.twitch.tv/v5/oembed' );
12
- wp_oembed_add_provider( 'https://www.twitch.tv/*', 'https://api.twitch.tv/v5/oembed' );
13
- wp_oembed_add_provider( 'http://twitch.tv/*', 'https://api.twitch.tv/v5/oembed' );
14
- wp_oembed_add_provider( 'https://twitch.tv/*', 'https://api.twitch.tv/v5/oembed' );
15
  wp_oembed_add_provider( 'https://fast.wistia.com/embed/iframe/*', 'https://fast.wistia.com/oembed.json' );
16
  wp_oembed_add_provider( 'https://fast.wistia.com/embed/playlists/*', 'https://fast.wistia.com/oembed.json' );
17
  wp_oembed_add_provider( 'https://*.wistia.com/medias/*', 'https://fast.wistia.com/oembed.json' );
@@ -76,30 +70,46 @@ function vimeo_referer( $args, $url ) {
76
 
77
  function trigger_cache_rebuild( $ttl, $url, $attr, $post_id ) {
78
 
79
- if ( ! did_action( 'nextgenthemes/arve/oembed_recache' ) ) {
80
- // Get the time when oEmbed HTML was last cached (based on the WP_Embed class)
81
- $key_suffix = md5( $url . serialize( $attr ) ); // phpcs:ignore
82
- $cachekey_time = '_oembed_time_' . $key_suffix;
83
- $cache_time = get_post_meta( $post_id, $cachekey_time, true );
84
-
85
- // Get the cached HTML
86
- $cachekey = '_oembed_' . $key_suffix;
87
- $cache_html = strtolower( get_post_meta( $post_id, $cachekey, true ) );
88
-
89
- // time after a recache should be done
90
- $trigger_time = get_option( 'nextgenthemes_arve_oembed_recache' );
91
-
92
- // Check if we need to regenerate the oEmbed HTML:
93
- if ( $cache_time < $trigger_time &&
94
- Common\contains_any( $cache_html, [ 'video', 'tube', 'dailymotion', 'vimeo', 'twitch', 'ted.com', 'wistia' ] ) &&
95
- $GLOBALS['wp_embed']->usecache
96
- ) {
97
- // What we need to skip the oembed cache part
98
- $GLOBALS['wp_embed']->usecache = false;
99
- $ttl = 0;
100
-
101
- do_action( 'nextgenthemes/arve/oembed_recache' );
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
 
105
  return $ttl;
6
  * https://github.com/iamcal/oembed/tree/master/providers
7
  */
8
  function add_oembed_providers() {
 
 
 
 
 
 
9
  wp_oembed_add_provider( 'https://fast.wistia.com/embed/iframe/*', 'https://fast.wistia.com/oembed.json' );
10
  wp_oembed_add_provider( 'https://fast.wistia.com/embed/playlists/*', 'https://fast.wistia.com/oembed.json' );
11
  wp_oembed_add_provider( 'https://*.wistia.com/medias/*', 'https://fast.wistia.com/oembed.json' );
70
 
71
  function trigger_cache_rebuild( $ttl, $url, $attr, $post_id ) {
72
 
73
+ if ( did_action( 'nextgenthemes/arve/oembed_recache' ) ) {
74
+ return $ttl;
75
+ }
76
+
77
+ // Get the time when oEmbed HTML was last cached (based on the WP_Embed class)
78
+ $key_suffix = md5( $url . serialize( $attr ) ); // phpcs:ignore
79
+ $cachekey_time = '_oembed_time_' . $key_suffix;
80
+ $cache_time = get_post_meta( $post_id, $cachekey_time, true );
81
+
82
+ // Get the cached HTML
83
+ $cachekey = '_oembed_' . $key_suffix;
84
+ $metadata = get_post_custom( $post_id );
85
+ $cache_exists = isset( $metadata[ $cachekey ][0] );
86
+ $cache_html = $cache_exists ? strtolower( get_post_meta( $post_id, $cachekey, true ) ) : false;
87
+ // $cache_exists2 = metadata_exists( 'post', $post_id, $cachekey ); // TODO not sure of 'post' is always right for embeds outside of
88
+
89
+ // time after a recache should be done
90
+ $trigger_time = get_option( 'nextgenthemes_arve_oembed_recache' );
91
+
92
+ $not_touching = [
93
+ 'platform.twitter.com',
94
+ 'embed.redditmedia.com',
95
+ 'embedr.flickr.com',
96
+ 'open.spotify.com',
97
+ 'secure.polldaddy.com',
98
+ 'embed.tumblr.com',
99
+ 'imgur.com'
100
+ ];
101
+
102
+ // Check if we need to regenerate the oEmbed HTML:
103
+ if ( $cache_exists &&
104
+ $cache_time < $trigger_time &&
105
+ ! Common\contains_any( $cache_html, $not_touching ) &&
106
+ $GLOBALS['wp_embed']->usecache
107
+ ) {
108
+ // What we need to skip the oembed cache part
109
+ $GLOBALS['wp_embed']->usecache = false;
110
+ $ttl = 0;
111
+
112
+ do_action( 'nextgenthemes/arve/oembed_recache' );
113
  }
114
 
115
  return $ttl;
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-beta11
9
  License: GPL-3.0
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -16,9 +16,15 @@ 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-12 9.0.0-beta10 ###
20
 
21
- * Improved: Reset buttons for settings sections.
 
 
 
 
 
 
22
  * Fix: Issues with error handling #2.
23
  * Fix: Hide non critical errors relating to private Vimeo videos.
24
  * Fix: Make sure 8.0 settings are moved over with right datatype. Hopefully fixes issues with not being able to save settings.
5
  Requires at least: 4.4.0
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
+ Stable tag: 9.0.0-beta12
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-13 9.0.0-beta12 ###
20
 
21
+ * Fix: When deactivating or uninstalling ARVE, it will delete its embeds from the oembed cache.
22
+ * Improved: Caching system.
23
+ * Improved: Removed Twitch oembed handler (not provided anymore, still works without it).
24
+
25
+ ### 2020-12-12 9.0.0-beta11 ###
26
+
27
+ * New: Reset buttons for settings sections.
28
  * Fix: Issues with error handling #2.
29
  * Fix: Hide non critical errors relating to private Vimeo videos.
30
  * Fix: Make sure 8.0 settings are moved over with right datatype. Hopefully fixes issues with not being able to save settings.