Version Description
(Sep 24, 2015) = Added support for playlists, added clear cache button to plugin page
Download this release
Release Info
Developer | sparkweb |
Plugin | Hide YouTube Related Videos |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3 to 1.4
- hide-youtube-related-videos.php +61 -25
- readme.txt +7 -4
hide-youtube-related-videos.php
CHANGED
@@ -4,12 +4,12 @@ Plugin Name: Hide YouTube Related Videos
|
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/hide-youtube-related-videos/
|
5 |
Description: This is a simple plugin to keep the YouTube oEmbed from showing related videos.
|
6 |
Author: SparkWeb Interactive, Inc.
|
7 |
-
Version: 1.
|
8 |
Author URI: http://www.soapboxdave.com/
|
9 |
|
10 |
**************************************************************************
|
11 |
|
12 |
-
Copyright (C)
|
13 |
|
14 |
This program is free software; you can redistribute it and/or
|
15 |
modify it under the terms of the GNU General Public License
|
@@ -30,38 +30,74 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
30 |
//The Filter That Does the Work
|
31 |
add_filter('oembed_result', 'hide_youtube_related_videos', 10, 3);
|
32 |
function hide_youtube_related_videos($data, $url, $args = array()) {
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
return $data;
|
35 |
}
|
36 |
|
37 |
//Disable the Jetpack
|
|
|
38 |
function hyrv_remove_jetpack_shortcode_function( $shortcodes ) {
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
}
|
48 |
-
add_filter('jetpack_shortcodes_to_include', 'hyrv_remove_jetpack_shortcode_function');
|
49 |
|
50 |
//On Activation, all oembed caches are cleared
|
51 |
-
register_activation_hook(__FILE__, '
|
52 |
-
function
|
53 |
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
-
$post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'" );
|
56 |
-
if ( $post_ids ) {
|
57 |
-
$postmetaids = $wpdb->get_col( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'" );
|
58 |
-
$in = implode( ',', array_fill( 1, count($postmetaids), '%d' ) );
|
59 |
-
do_action( 'delete_postmeta', $postmetaids );
|
60 |
-
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids ) );
|
61 |
-
do_action( 'deleted_postmeta', $postmetaids );
|
62 |
-
foreach ( $post_ids as $post_id )
|
63 |
-
wp_cache_delete( $post_id, 'post_meta' );
|
64 |
-
return true;
|
65 |
-
}
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/hide-youtube-related-videos/
|
5 |
Description: This is a simple plugin to keep the YouTube oEmbed from showing related videos.
|
6 |
Author: SparkWeb Interactive, Inc.
|
7 |
+
Version: 1.4
|
8 |
Author URI: http://www.soapboxdave.com/
|
9 |
|
10 |
**************************************************************************
|
11 |
|
12 |
+
Copyright (C) 2015 SparkWeb Interactive, Inc.
|
13 |
|
14 |
This program is free software; you can redistribute it and/or
|
15 |
modify it under the terms of the GNU General Public License
|
30 |
//The Filter That Does the Work
|
31 |
add_filter('oembed_result', 'hide_youtube_related_videos', 10, 3);
|
32 |
function hide_youtube_related_videos($data, $url, $args = array()) {
|
33 |
+
|
34 |
+
//Setup the string to inject into the url
|
35 |
+
$str_to_add = apply_filters("hyrv_extra_querystring_parameters", "wmode=transparent&") . 'rel=0';
|
36 |
+
|
37 |
+
//Regular oembed
|
38 |
+
if (strpos($data, "?feature=oembed") !== false) {
|
39 |
+
$data = str_replace('?feature=oembed', '?' . $str_to_add . '&feature=oembed', $data);
|
40 |
+
|
41 |
+
//Playlist
|
42 |
+
} elseif (strpos($data, "videoseries?list=") !== false) {
|
43 |
+
$data = str_replace('videoseries?list=', 'videoseries?' . $str_to_add . '&list=', $data);
|
44 |
+
}
|
45 |
+
|
46 |
+
//All Set
|
47 |
return $data;
|
48 |
}
|
49 |
|
50 |
//Disable the Jetpack
|
51 |
+
add_filter('jetpack_shortcodes_to_include', 'hyrv_remove_jetpack_shortcode_function');
|
52 |
function hyrv_remove_jetpack_shortcode_function( $shortcodes ) {
|
53 |
+
$jetpack_shortcodes_dir = WP_CONTENT_DIR . '/plugins/jetpack/modules/shortcodes/';
|
54 |
+
$shortcodes_to_unload = array('youtube.php');
|
55 |
+
foreach ($shortcodes_to_unload as $shortcode) {
|
56 |
+
if ($key = array_search($jetpack_shortcodes_dir . $shortcode, $shortcodes)) {
|
57 |
+
unset($shortcodes[$key]);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
return $shortcodes;
|
61 |
}
|
|
|
62 |
|
63 |
//On Activation, all oembed caches are cleared
|
64 |
+
register_activation_hook(__FILE__, 'hyrv_clear_cache');
|
65 |
+
function hyrv_clear_cache() {
|
66 |
global $wpdb;
|
67 |
+
$post_ids = $wpdb->get_col("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'");
|
68 |
+
if ($post_ids) {
|
69 |
+
$postmetaids = $wpdb->get_col("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'");
|
70 |
+
$in = implode(',', array_fill(1, count($postmetaids), '%d'));
|
71 |
+
do_action('delete_postmeta', $postmetaids);
|
72 |
+
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN ($in)", $postmetaids));
|
73 |
+
do_action('deleted_postmeta', $postmetaids);
|
74 |
+
foreach ($post_ids as $post_id) {
|
75 |
+
wp_cache_delete($post_id, 'post_meta');
|
76 |
+
}
|
77 |
+
return true;
|
78 |
+
}
|
79 |
+
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
//Display Clear Oembed Cache Link on Plugin Screen
|
83 |
+
add_filter('plugin_action_links', 'hyrv_plugin_action_links', 10, 2);
|
84 |
+
function hyrv_plugin_action_links($links, $file) {
|
85 |
+
static $this_plugin;
|
86 |
+
if (!$this_plugin) {
|
87 |
+
$this_plugin = "hide-youtube-related-videos/hide-youtube-related-videos.php";
|
88 |
+
}
|
89 |
+
if ($file == $this_plugin) {
|
90 |
+
$custom_link = '<a href="' . admin_url('plugins.php?hyrv_clear_cache=1') . '">Clear Oembed Cache</a>';
|
91 |
+
array_unshift($links, $custom_link);
|
92 |
+
}
|
93 |
+
return $links;
|
94 |
+
}
|
95 |
+
|
96 |
+
//Clear Cache On Admin Page Load
|
97 |
+
add_action('admin_notices', 'hyrv_execute_cache_reload');
|
98 |
+
function hyrv_execute_cache_reload() {
|
99 |
+
if (isset($_GET['hyrv_clear_cache'])) {
|
100 |
+
hyrv_clear_cache();
|
101 |
+
echo '<div class="updated"><p><strong>Success!</strong> Your oembed cache has been cleared.</p></div>';
|
102 |
+
}
|
103 |
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: sparkweb
|
3 |
Tags: youtube, video, oembed, related
|
4 |
Requires at least: 2.9
|
5 |
-
Tested up to: 4.3
|
6 |
-
Stable tag: 1.
|
7 |
This is a simple plugin to keep the YouTube oEmbed from showing related videos.
|
8 |
|
9 |
== Description ==
|
@@ -44,6 +44,9 @@ Be sure to leave an & at the end of your string. After installing your filte
|
|
44 |
|
45 |
== Changelog ==
|
46 |
|
|
|
|
|
|
|
47 |
= 1.3 (Feb 10, 2014) =
|
48 |
Disabled Jetpack YouTube shortcode embed as it kills this feature
|
49 |
|
@@ -59,5 +62,5 @@ Added wmode=transparent to the url structure
|
|
59 |
|
60 |
== Upgrade Notice ==
|
61 |
|
62 |
-
= 1.
|
63 |
-
|
2 |
Contributors: sparkweb
|
3 |
Tags: youtube, video, oembed, related
|
4 |
Requires at least: 2.9
|
5 |
+
Tested up to: 4.3.1
|
6 |
+
Stable tag: 1.4
|
7 |
This is a simple plugin to keep the YouTube oEmbed from showing related videos.
|
8 |
|
9 |
== Description ==
|
44 |
|
45 |
== Changelog ==
|
46 |
|
47 |
+
= 1.4 (Sep 24, 2015) =
|
48 |
+
Added support for playlists, added clear cache button to plugin page
|
49 |
+
|
50 |
= 1.3 (Feb 10, 2014) =
|
51 |
Disabled Jetpack YouTube shortcode embed as it kills this feature
|
52 |
|
62 |
|
63 |
== Upgrade Notice ==
|
64 |
|
65 |
+
= 1.4 =
|
66 |
+
Added support for playlists, added clear cache button to plugin page
|