mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-04 20:27:40 +02:00
Shortcodes API: delete() clear() exist() methods added
This commit is contained in:
@@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add shortcode
|
* Add new shortcode
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* function returnSiteUrl() {
|
* function returnSiteUrl() {
|
||||||
@@ -80,6 +80,59 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Parse a string, and replace any registered shortcodes within it with the result of the mapped callback.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user