Advanced filtering functions for WordPress, including the Talk Like a Pirate Day filters.
Technically, all you need to do is copy the "text-filter-suite" folder into your "wp-content/plugins" directory, then activate the "TFS Core" plugin from the WordPress admin interface. But, more generally, you'll probably want some of the other filter files, as well. The easiest thing to do will be to just copy all of the ".php" files to your plugins directory, and only activate the ones that interest you. But you can omit any of the "tfs-whatever.php" files (other than tfs-core) that don't interest you.
Generally, you'll probably want to activate a filter just for specific posts. You do this by adding special "post custom fields" in the "Write Post" form.
Custom fields are composed of two parts: the "key" and the "value". The two special keys that activate TFS are "post_filter" and "comment_filter". In either case, the value should be the short name of the TFS filter you wish to apply, e.g. "pirate" or "fudd" (without the quotation marks).
Setting the "post_filter" key will apply the filter to the main post text. Setting the "comment_filter" key will apply the filter to the text of all comments on the post.
There are only two core TFS functions, plus two more to support the per-post content and comment filtering based on post custom fields. The main entry point is the "filter_cdata_content" function. A TFS filter will call filter_cdata_content, passing the content and the name of a second function. The magic of filter_cdata_content() is that it will only mangle regular text, leaving HTML tags alone. It will automatically call out to the named function, passing it each chunk of non-HTML-tag text (AKA "CDATA", or "Character Data", in XML parlance) in turn.
The other core function is "array_apply_regexp". This support function isn't required for every filter, but it is at the core of the included TFS filters, such as the "pirate" filter. It accepts an associative array of regular expressions and replacements, and the content to be filtered. Examine the source of the "chef" and "fudd" filters for some simple examples.
The per-post support functions are "tfs_content_filter" and "tfs_comment_filter". These functions are automatically applied to each post and its contents. They look for the "content_filter" and "comment_filter" post custom fields, and apply the appropriate filter functions if they are found.
Requires: 1.5 or higher
Compatible up to: 4.3.7
Last Updated: 2 years ago
Active Installs: Less than 10
Got something to say? Need help?