{"id":2118,"date":"2004-12-10T02:41:41","date_gmt":"2004-12-10T02:41:41","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/text-filter-suite\/"},"modified":"2015-06-03T20:38:47","modified_gmt":"2015-06-03T20:38:47","slug":"text-filter-suite","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/text-filter-suite\/","author":5,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.4","stable_tag":"1.4","tested":"4.3.34","requires":"1.5","requires_php":"","requires_plugins":"","header_name":"TFS Acronymit","header_author":"Dougal Campbell","header_description":"","assets_banners_color":"","last_updated":"2015-06-03 20:38:47","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/dougal.gunters.org\/donate","header_plugin_uri":"http:\/\/dougal.gunters.org\/blog\/2004\/08\/30\/text-filter-suite","header_author_uri":"http:\/\/dougal.gunters.org\/","rating":4.5,"author_block_rating":0,"active_installs":0,"downloads":5675,"num_ratings":2,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":"1","5":"1"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.2","1.3","1.4"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[107,529,2755,6129,5783],"plugin_category":[44],"plugin_contributors":[77598],"plugin_business_model":[],"class_list":["post-2118","plugin","type-plugin","status-publish","hentry","plugin_tags-comments","plugin_tags-content","plugin_tags-filters","plugin_tags-fun","plugin_tags-funny","plugin_category-discussion-and-community","plugin_contributors-dougal","plugin_committers-dougal"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/text-filter-suite.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>The Text Filter Suite (\"TFS\", hereafter) is a WordPress plugin which\nadds some new text filtering functions. In a sense, the core TFS\nfunctions could be considered a \"meta filter\", because they actually\nprovide a framework that let you construct new filters fairly easily.\nThey also provide an easy way to apply filters to post content and\ncomments on a per-post basis.<\/p>\n\n<h4>Huh? Can you repeat that in English?<\/h4>\n\n<p>Okay, let's try a real-world example. A common feature on many web\nsites is the automatic handling of acronyms. You'll often see an\nacronym such as \"XHTML\" displayed in an alternate style, and when you\nhover your mouse pointer over it, you get a tool-tip which displays the\ndefinition (\"eXtended HyperText Markup Language\", in this case). You\ndon't want to have to type in the markup for this every time you post\nsomething, and automation is what computers are for, right? So, there\nare several plugins available to handle this sort of automated text\nsubsitution.<\/p>\n\n<p>TFS comes with the \"TFS Acronymit\" plugin to perform this function.\nIt's based on Matt Mullenweg's original \"Acronymit\" function, but with\na couple of improvements. In Matt's original function, you had to keep\nthe acronym list sorted, longest-to-shortest, and it could get confused\nby recursive acronyms like 'PHP' (\"PHP Hyptertext Processor\") or GNU\n(\"GNU's Not Unix\"). TFS Acronymit does not have those restrictions.<\/p>\n\n<p>For those who think that expansion of technical acronyms is \"teh sux0r\"\n(i.e. \"boring\"), TFS comes with a variety of more entertaining filters.\nThe current set includes \"chef\", \"fudd\", \"jive\", \"kraut\", \"pirate\", and\nof course, the aforementioned \"acronymit\". As a word of caution, the\n\"jive\" and \"kraut\" filters are not what you would call \"politically\ncorrect\".\nBy default, if the \"TFS Pirate\" filter is active, it will automatically\napply itself to all content on Talk Like a Pirate Day (September 19).\nIf you do not want this filter to automatically activate, set the value\nof the \"$talk_like_a_pirate\" variable at the top of the plugin source\nto \"false\".<\/p>\n\n<p>The \"TFS Acronymit\" filter is automatically applied to all posts\nwhenever it is active. You do not need to set special post custom\nfields in order to use it. Just activate the plugin, and you're ready.\nTo modify which acronyms are defined, see the list at the beginning of\nthe plugin, and modify it as you like, following the format you see\nthere.<\/p>\n\n<p>It is possible to use the TFS core without activating any additional\nplugins. You can do this with any built-in PHP function accepts a\nsingle string as a parameter and returns a string. For example, you\ncould set a post custom \"content_filter\" with the value \"strrev\", and\nthe contents of the post would be displayed backwards, or with a value\nof \"strtoupper\" to convert the content to all uppercase text.<\/p>\n\n<p>You can only specify a single function in each post custom field.\nHowever, you can chain multiple functions together by using the key\nmore than once. For instance, if you wanted all comments for a post to\ndisplay in uppercase Elmer Fudd text, you would set two post custom\nfields:<\/p>\n\n<p>comment_filter = strtoupper\n  comment_filter = fudd<\/p>\n\n<p>HOWEVER, note that using PHP built-in functions in this way will bypass\nthe power of the filter_cdata_content() function, which means that it\ncan and will mangle your HTML tags, possibly rendering them useless.\nFor example, applying the strrev function to the string \"<\/p>\n\n<p>&lt;<\/p>\n\n<p>p&gt;\" will\ntransform it into \"&gt;p&lt;\", which will confuse your browser in new and\nwonderful ways.<\/p>\n\n<p>NOTE: These filters can be very CPU intensive. For one thing, they make\nextensive use of regular expressions, which can be expensive on their own. \nAnd for another, they break your content into many small chunks, in order to\nseparate the filterable text from the HTML code, and the filters run\nseparately on each text chunk found.  This probably won't be a problem in\nmost cases.  But if you have long posts being filtered, and you get a lot of\ntraffic, it could start to add up.  A caching plugin (e.g., WP Super Cache,\nor W3 Total Cache) would probably help in that case.<\/p>\n\n<h3>The Future<\/h3>\n\n<p>I will one day release a version 2.0 of this plugin which will be completely\nrefactored. You can probably expect to see:\n* Consolidate the code so that it is not a collection of separately-enabled\n  mini-plugins.\n* PHP5 OOP architecture to encapsulate everything.\n* An actual admin interface to select which filters are enabled, which \n  bits of content you will allow to be filtered (post titles, post content, comments,\n  blog title, widget titles, etc), whether to auto-activate the Pirate\n  filter on Talk Like a Pirate Day, etc.<\/p>\n\n<p>Eventually, there may also be a way to edit the string substitutions so that\nyou can tailor it to your tastes.<\/p>\n\n<h3>Credits<\/h3>\n\n<p>I created TFS on my own, but I borrowed ideas from several sources. Here are\nsome links you might also want to check out:<\/p>\n\n<pre><code>PhotoMatt's original Acronymit code:\n  http:\/\/photomatt.net\/scripts\/acronymit\n\nSimon Willison and I traded some ideas when I started my original hack\nfor Talk Like a Pirate Day, in 2003:\n  http:\/\/simon.incutio.com\/archive\/2003\/09\/19\/aaar\n\nI borrowed, modified, and mangled a ton of stuff from Adam Kalsey's\n\"MovableJive\" plugin for Movable Type. See tfs-jive, tfs-chef, tfs-fudd,\nand tfs-kraut.\n  http:\/\/kalsey.com\/2003\/02\/movablejive\/\n\nIf all you want to do is stuff like the acronym definitions (or similar\n\"turn this shorthand into a tag\" substitions), then Michel Valdrighi's\n\"Tag, You're It\" plugin is really a better solution:\n  http:\/\/zengun.org\/weblog\/archives\/2004\/05\/tag-you-re-it\n\nThe original inspiration that led to TFS was my desire to apply a\n\"pirate\" filter on my blog for \"Talk Like a Pirate Day\", which is on\nSeptember 19 of each year:\n  http:\/\/talklikeapirate.com\/\n<\/code><\/pre>\n\n<!--section=installation-->\n<p>Technically, all you need to do is copy the \"text-filter-suite\" folder\ninto your \"wp-content\/plugins\" directory, then activate the \"TFS Core\"\nplugin from the WordPress admin interface. But, more generally, you'll\nprobably want some of the other filter files, as well. The easiest\nthing to do will be to just copy all of the \".php\" files to your\nplugins directory, and only activate the ones that interest you. But\nyou can omit any of the \"tfs-whatever.php\" files (other than tfs-core)\nthat don't interest you.<\/p>\n\n<h4>Using the filters<\/h4>\n\n<p>Generally, you'll probably want to activate a filter just for specific\nposts. You do this by adding special \"post custom fields\" in the\n\"Write Post\" form.<\/p>\n\n<p>Custom fields are composed of two parts: the \"key\" and the \"value\". The\ntwo special keys that activate TFS are \"post_filter\" and\n\"comment_filter\". In either case, the value should be the short name of\nthe TFS filter you wish to apply, e.g. \"pirate\" or \"fudd\" (without the\nquotation marks).<\/p>\n\n<p>Setting the \"post_filter\" key will apply the filter to the main post\ntext. Setting the \"comment_filter\" key will apply the filter to the\ntext of all comments on the post.<\/p>\n\n<h4>Technical mumbo-jumbo<\/h4>\n\n<p>There are only two core TFS functions, plus two more to support the\nper-post content and comment filtering based on post custom fields. The\nmain entry point is the \"filter_cdata_content\" function. A TFS filter\nwill call filter_cdata_content, passing the content and the name of a\nsecond function. The magic of filter_cdata_content() is that it will\nonly mangle regular text, leaving HTML tags alone. It will\nautomatically call out to the named function, passing it each chunk of\nnon-HTML-tag text (AKA \"CDATA\", or \"Character Data\", in XML parlance)\nin turn.<\/p>\n\n<p>The other core function is \"array_apply_regexp\". This support function\nisn't required for every filter, but it is at the core of the included\nTFS filters, such as the \"pirate\" filter. It accepts an associative\narray of regular expressions and replacements, and the content to be\nfiltered. Examine the source of the \"chef\" and \"fudd\" filters for some\nsimple examples.<\/p>\n\n<p>The per-post support functions are \"tfs_content_filter\" and\n\"tfs_comment_filter\". These functions are automatically applied to each\npost and its contents. They look for the \"content_filter\" and\n\"comment_filter\" post custom fields, and apply the appropriate filter\nfunctions if they are found.<\/p>\n\n<!--section=changelog-->\n<h4>1.4 - 2015-06-03<\/h4>\n\n<ul>\n<li>Added '?filter=foo' URL option back in, with a whitelist of allowed\nfunctions.<\/li>\n<\/ul>\n\n<h4>1.3 - 2012-09-18<\/h4>\n\n<ul>\n<li>Fixed PHP opening shorttag in tfs-acroymit.php<\/li>\n<li>Eliminated PHP warnings in debug mode<\/li>\n<li>Removed all closing ?&gt; php tags per WP standards<\/li>\n<li>Killed generic 'filter' $_REQUEST variable checking<\/li>\n<\/ul>\n\n<h4>1.2 - 2010-12-10<\/h4>\n\n<ul>\n<li>Added this changelog to the readme<\/li>\n<li>Moved the is_feed() handling into the init, to avoid breaking in\nWordPress 3.1.<\/li>\n<li>Added notes about the filters being CPU intensive.<\/li>\n<\/ul>","raw_excerpt":"Advanced filtering functions for WordPress, including the Talk Like a Pirate Day filters.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/2118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=2118"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/dougal"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=2118"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=2118"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=2118"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=2118"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=2118"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=2118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}