Advertisement
Guest User

Pastebin Embed Plugin Code

a guest
Mar 12th, 2015
1,714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Pastebin Embed
  4. Description: Embed pastes from pastebin.com
  5. Version: 1.1
  6. Author: Rami Yushuvaev
  7. Author URI: http://GenerateWP.com/
  8. Text Domain: pastebin-embed
  9. Domain Path: /languages
  10. License: GPL2+
  11. */
  12. function pastebin_embed_handler( $matches, $attr, $url, $rawattr ) {
  13.  
  14.     $embed = sprintf(
  15.         '<script src="http://pastebin.com/embed_js.php?i=%1$s"></script>',
  16.         esc_attr( $matches[1] )
  17.     );
  18.  
  19.     return apply_filters( 'embed_pastebin', $embed, $matches, $attr, $url, $rawattr );
  20.  
  21. }
  22.  
  23. function pastebin_embed() {
  24.  
  25.     wp_embed_register_handler(
  26.         'pastebin',
  27.         '#http://pastebin.com/(.*)#i',
  28.         'pastebin_embed_handler'
  29.     );
  30.  
  31. }
  32.  
  33. add_action( 'init', 'pastebin_embed' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement