Skip to content

Instantly share code, notes, and snippets.

@fenixkim
Last active January 3, 2016 03:39
Show Gist options
  • Save fenixkim/8403948 to your computer and use it in GitHub Desktop.
Save fenixkim/8403948 to your computer and use it in GitHub Desktop.
Same than `kirbytext()` but only allows the tags in `allowedTags`
<?php
/**
* Same than `kirbytext()` but only allows the tags in `allowedTags`
*
* <code>
*
* $text = 'This is a html text with a **strong** and *em* text';
*
* // Remove all tags except strong tags
* cleanKirbytext($text, '<strong>');
* // output: This is a html text with a <strong>strong</strong> and em text
*
* <code>
*
* @param string $text The normal text.
* @param string $allowdTags The list of allowed tags as is described here: http://php.net/manual/es/function.strip-tags.php
*
*/
function cleanKirbytext($text, $allowedTags = '') {
return strip_tags(kirbytext($text), $allowedTags);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment