Skip to content

Commit

Permalink
Ensure WP_ShortCodeShield class is not already defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
vicchi committed Nov 11, 2012
1 parent 57efff7 commit bdcd24d
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions wp-shortcode-shield.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,49 @@

require_once (WPSHORTCODESHIELD_PATH . '/includes/wp-plugin-base/wp-plugin-base.php');

class WP_ShortCodeShield extends WP_PluginBase_v1_1 {
static $instance;
if (!class_exists ('WP_ShortCodeShield')) {
class WP_ShortCodeShield extends WP_PluginBase_v1_1 {
static $instance;

const LANGB = '[';
const RANGB = ']';
const LANGB = '[';
const RANGB = ']';

function __construct () {
self::$instance = $this;
function __construct () {
self::$instance = $this;

$this->hook ('plugins_loaded');
}

function plugins_loaded () {
add_shortcode ('wp_scs', array ($this, 'shortcode'));
add_shortcode ('wp_shortcode_shield', array ($this, 'shortcode'));
}
$this->hook ('plugins_loaded');
}

function shortcode ($atts, $content=null) {
extract (shortcode_atts (array ('code' => ''), $atts));

// Self-closing shortcode form ...
if (empty ($content) && !empty ($code)) {
return $this->enclose ($code);
function plugins_loaded () {
add_shortcode ('wp_scs', array ($this, 'shortcode'));
add_shortcode ('wp_shortcode_shield', array ($this, 'shortcode'));
}

function shortcode ($atts, $content=null) {
extract (shortcode_atts (array ('code' => ''), $atts));

// Enclosing shortcode form ...
else {
if (strpos ($content, '[') === false) {
return $this->enclose ($content);
// Self-closing shortcode form ...
if (empty ($content) && !empty ($code)) {
return $this->enclose ($code);
}


// Enclosing shortcode form ...
else {
return $content;
if (strpos ($content, '[') === false) {
return $this->enclose ($content);
}

else {
return $content;
}
}
}
}

function enclose ($content) {
return self::LANGB . $content . self::RANGB;
}
} // end-class WP_ShortCodeShield
function enclose ($content) {
return self::LANGB . $content . self::RANGB;
}
} // end-class WP_ShortCodeShield
} // if (!class_exists ('WP_ShortCodeShield'))

$__wp_shortcode_shield_instance = new WP_ShortCodeShield;

Expand Down

0 comments on commit bdcd24d

Please sign in to comment.