1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-03 19:57:57 +02:00

Shortcodes API: delete() clear() exist() methods added

This commit is contained in:
Sergey Romaneko
2012-10-24 15:24:36 +03:00
parent adc1aa9237
commit c1f2725be9

View File

@@ -56,7 +56,7 @@
/**
* Add shortcode
* Add new shortcode
*
* <code>
* function returnSiteUrl() {
@@ -79,6 +79,59 @@
if (is_callable($callback_function)) Shortcode::$shortcode_tags[$shortcode] = $callback_function;
}
/**
* Remove a specific registered shortcode.
*
* <code>
* Shortcode::delete('shortcode_name');
* </code>
*
* @param string $shortcode Shortcode tag.
*/
pubic static function delete($shortcode) {
// Redefine vars
$shortcode = (string) $shortcode;
// Delete shortcode
if (Shortcode::exist($shortcode)) unset(Shortcode::$shortcode_tags[$shortcode]);
}
/**
* Remove all registered shortcodes.
*
* <code>
* Shortcode::clear();
* </code>
*
*/
public static function clear() {
Shortcode::$shortcode_tags = array();
}
/**
* Check if a shortcode has been registered.
*
* <code>
* if (Shortcode::exist('shortcode_name')) {
* // do something...
* }
* </code>
*
* @param string $shortcode Shortcode tag.
*/
pulbic static function exist($shortcode) {
// Redefine vars
$shortcode = (string) $shortcode;
// Check shortcode
return array_key_exists($shortcode, Shortcode::$shortcode_tags);
}
/**
* Parse a string, and replace any registered shortcodes within it with the result of the mapped callback.