Advertisement
villers

wp_pluging

May 26th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2. /*
  3.     Plugin Name:    MyBBCode
  4.     Version:    1.0.0
  5.     Description:    Implements du bbCode Personnel
  6.     Author:     VILLERS Mickael
  7.  */
  8. class MyBBCode {
  9.     function __construct() {
  10.         if ( !function_exists('add_shortcode') ) return;
  11.  
  12.         add_shortcode( 'b' , array(&$this, 'shortcode_bold') );
  13.         add_shortcode( 'i' , array(&$this, 'shortcode_italics') );
  14.         add_shortcode( 'u' , array(&$this, 'shortcode_underline') );
  15.         add_shortcode( 'infobulle' , array(&$this, 'shortcode_url') );
  16.     }
  17.  
  18.     function shortcode_bold( $atts = array(), $content = NULL ) {
  19.         return '<strong>' . do_shortcode( $content ) . '</strong>';
  20.     }
  21.  
  22.     function shortcode_italics( $atts = array(), $content = NULL ) {
  23.         return '<em>' . do_shortcode( $content ) . '</em>';
  24.     }
  25.  
  26.     function shortcode_underline( $atts = array(), $content = NULL ) {
  27.         return '<span style="text-decoration:underline">' . do_shortcode( $content ) . '</span>';
  28.     }
  29.  
  30.     function shortcode_url( $atts = array(), $content = NULL ) {
  31.         $attribut = substr($atts[0], 1);
  32.             $array = explode("|", $content);
  33.             $content = (isset($array[1])) ? $array[1] : $attribut;
  34.  
  35.             return '<a href="'.$attribut.'" title="'.$array[0].'">'.do_shortcode($content).'</a>';
  36.     }
  37.  
  38. }
  39. add_action( 'plugins_loaded', create_function( '', 'global $BBCode; $BBCode = new MyBBCode();' ) );
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement