an7_filter replaces text strings defined by a customizable array. In short, this lets you insert emoticons, instant messenger style! It can also be used for undesirable language filtering or keyword link insertion.
While an7_filter does not automate this process entirely, it makes it fairly easy. Used as a wrap tag, it will filter the contained text using an array specified in the plugin (the default is setup for emoticon replacement).
... $imga = '<img src="/images/emoticons/'; $imgb = '.png" class="emoticon" />'; $replacements = array( "text" => "****", ": )" => $imga."smile".$imgb, ...
... <txp:an7_filter><txp:body /></txp:an7_filter> ...
this text is being filtered. : )
this **** is being filtered.
Please note that the plugin is currently case-sensitive.
an7_filter comes ready for use as an emoticon plugin. It’s suggested that you wrap
<txp:search_result_excerpt />, and similar tags, as these are the most common places to find replaceable text. I’m not sure about the impact on the server if one were to try to wrapping an entire page, it might not be the best idea. The listed tags should be sufficient, and keep PHP processing time to a minimum.
To avoid some specific code issues, I’ve added a space before each text string. This prevents links from being corrupted by
:/ (short variation of
:undecided:), but still allows a string of emoticons separated only by single spaces.
>:o :[ 8) :’( :! :( :o :D :angry: :blush: :cool: :cry: :eeeih: :frown: :gasp: :grin:
0:) :* :P :$ :x :) :/ :halo: :kiss: :laugh: :money: :sealed: :smile: :undecided:
(this is a partial list, there are other variations for many of the emoticons, and of course this is entirely customizable)
For emoticon images, you must edit the
'imgb' attributes to reflect your file structure and image types. For other text replacement features, the array can be edited to handle just about anything.
This plugin is currently in beta
an7_filter (version 0.2.0)
Copy the plugin text into your textpattern “install plugin” field and click “upload”. Enable the plugin and edit the source to customize the replacement array (
"text" => "replacement";).
If you want to use emoticons, find a good icon pack and upload it to your images folder (for organization, probably under a “emoticons” subfolder). I don’t have an “official” pack yet, but once the plugin goes live I hope to have a default installation ready.
Edit your page or article templates by wrapping desired tags with
</txp:an7_filter>. Save any changes, and that should be it!
— beta, added simple documentation and correctly validating image code
— alpha, undergoing testing
help and support
For questions and support, please visit the an7_filter post in the Textpattern Forums.
The template from thresholdstate.com was helpful as always. <3