Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Rick Roll YouTube URLs
- Description: Exactly what it says.
- Author: Jan Dembowski
- */
- add_filter( 'the_content' , 'mh_rick_roll_content' , 0 );
- function mh_rick_roll_content( $content ) {
- /*
- Replace YouTube videos with a Rickroll
- http://www.youtube.com/watch?v=dQw4w9WgXcQ
- */
- $mh_url_regex = "/http\:\/\/www\.youtube\.com\/watch\?v\=[a-zA-Z0-9\-]+/";
- preg_match_all( $mh_url_regex , $content, $mh_matches );
- for ( $mh_count = 0; $mh_count < count( $mh_matches[0] ); $mh_count++ )
- {
- $mh_old_url = $mh_matches[0][$mh_count];
- $mh_new_url = 'http://www.youtube.com/watch?v=dQw4w9WgXcQ';
- $content = str_replace( $mh_old_url , $mh_new_url , $content );
- }
- return $content;
- }
Advertisement
Add Comment
Please, Sign In to add comment