Hide YouTube Related Videos - Version 1.0

Version Description

(Dec 23, 2011) = * Initial Release

Download this release

Release Info

Developer sparkweb
Plugin Icon 128x128 Hide YouTube Related Videos
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (2) hide show
  1. hide-youtube-related-videos.php +54 -0
  2. readme.txt +28 -0
hide-youtube-related-videos.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /*
2
+ **************************************************************************
3
+ 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.0
8
+ Author URI: http://www.soapboxdave.com/
9
+
10
+ **************************************************************************
11
+
12
+ Copyright (C) 2012 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
16
+ as published by the Free Software Foundation; either version 2
17
+ of the License, or (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
+
28
+ **************************************************************************/
29
+
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
+ return str_replace('&feature=oembed', '&feature=oembed&rel=0', $data);
34
+ }
35
+
36
+
37
+ //On Activation, all oembed caches are cleared
38
+ register_activation_hook(__FILE__, 'hide_youtube_related_videos_activation');
39
+ function hide_youtube_related_videos_activation() {
40
+ global $wpdb;
41
+
42
+ $post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'" );
43
+ if ( $post_ids ) {
44
+ $postmetaids = $wpdb->get_col( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'" );
45
+ $in = implode( ',', array_fill( 1, count($postmetaids), '%d' ) );
46
+ do_action( 'delete_postmeta', $postmetaids );
47
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids ) );
48
+ do_action( 'deleted_postmeta', $postmetaids );
49
+ foreach ( $post_ids as $post_id )
50
+ wp_cache_delete( $post_id, 'post_meta' );
51
+ return true;
52
+ }
53
+
54
+ }
readme.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Hide YouTube Related Videos ===
2
+ Contributors: sparkweb
3
+ Tags: youtube, video, oembed, related
4
+ Requires at least: 2.9
5
+ Tested up to: 3.4.2
6
+ Stable tag: 1.0
7
+ This is a simple plugin to keep the YouTube oEmbed from showing related videos.
8
+
9
+ == Description ==
10
+
11
+ WordPress' built-in oEmbed feature is fantastic. I've heard several complaints, though, about the related videos that show up after the video is done playing so I put together this very simple plugin that keeps the YouTube oEmbed code from showing related videos.
12
+
13
+ On activation, the plugin clears the oEmbed cache so that the videos can be successfully re-cached with the new setting.
14
+
15
+ == Installation ==
16
+
17
+ Copy the folder to your WordPress
18
+ '*/wp-content/plugins/*' folder.
19
+
20
+ 1. Activate the plugin in your WordPress admin
21
+ 1. That's it. There's nothing else to do. Really!
22
+
23
+
24
+
25
+ == Changelog ==
26
+
27
+ = 1.0 (Dec 23, 2011) =
28
+ * Initial Release