Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: MyBBCode
- Version: 1.0.0
- Description: Implements du bbCode Personnel
- Author: VILLERS Mickael
- */
- class MyBBCode {
- function __construct() {
- if ( !function_exists('add_shortcode') ) return;
- add_shortcode( 'b' , array(&$this, 'shortcode_bold') );
- add_shortcode( 'i' , array(&$this, 'shortcode_italics') );
- add_shortcode( 'u' , array(&$this, 'shortcode_underline') );
- add_shortcode( 'infobulle' , array(&$this, 'shortcode_url') );
- }
- function shortcode_bold( $atts = array(), $content = NULL ) {
- return '<strong>' . do_shortcode( $content ) . '</strong>';
- }
- function shortcode_italics( $atts = array(), $content = NULL ) {
- return '<em>' . do_shortcode( $content ) . '</em>';
- }
- function shortcode_underline( $atts = array(), $content = NULL ) {
- return '<span style="text-decoration:underline">' . do_shortcode( $content ) . '</span>';
- }
- function shortcode_url( $atts = array(), $content = NULL ) {
- $attribut = substr($atts[0], 1);
- $array = explode("|", $content);
- $content = (isset($array[1])) ? $array[1] : $attribut;
- return '<a href="'.$attribut.'" title="'.$array[0].'">'.do_shortcode($content).'</a>';
- }
- }
- add_action( 'plugins_loaded', create_function( '', 'global $BBCode; $BBCode = new MyBBCode();' ) );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement