Skip to content

Instantly share code, notes, and snippets.

@eoghanobrien
Created July 8, 2009 12:30
Show Gist options
  • Save eoghanobrien/142778 to your computer and use it in GitHub Desktop.
Save eoghanobrien/142778 to your computer and use it in GitHub Desktop.
Strip Tags: Expression Engine plugin to strip tags from text blocks
<?php
/*
=====================================================
ExpressionEngine - by pMachine
-----------------------------------------------------
http://www.pmachine.com/
=====================================================
This plugin was created by Eoghan O'Brien
- http://eoghanobrien.com/
This work is licensed under a
Creative Commons Attribution-ShareAlike 2.5 License.
- http://creativecommons.org/licenses/by-sa/2.5/
=====================================================
File: pi.strip_tags.php
-----------------------------------------------------
Purpose: Strip tags
=====================================================
*/
$plugin_info = array
(
'pi_name' => 'Strip Tags',
'pi_version' => '1.0',
'pi_author' => 'Eoghan OBrien',
'pi_author_url' => 'http://eoghanobrien.com/',
'pi_description' => 'Strips tags out of text.',
'pi_usage' => Strip_tags::usage()
);
class Strip_tags {
var $return_data;
// ----------------------------------------
// Find and Replace
// ----------------------------------------
function Strip_tags()
{
global $TMPL;
$allowable = ($TMPL->fetch_param('allowable') !== FALSE) ? $TMPL->fetch_param('replace') : '';
$text = $TMPL->tagdata;
$this->return_data = strip_tags($text, $allowable);
}
// END
// ----------------------------------------
// Plugin Usage
// ----------------------------------------
// This function describes how the plugin is used.
function usage()
{
ob_start();
?>
This plugin works pretty much the same as the php strip_tags() function.
*** PARAMETERS ***
allowable="<p><a><ul><ol><li><blockquote>"
*** EXAMPLES ***
{exp:strip_tags allowable="<p><a>"}<p>This is a <a href="http://google.com">link</a></p>{/exp:strip_tags}
<?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
// END
}
// END CLASS
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment