Text Replace
- Author:Scott Reilly
- Version:2.0
- Last update:08 April 2008
- Compatibility:WP 2.2+, 2.3+ and 2.5+
- Comments:go here
- Download:[ zip ]
- Description:
Replace text with other text in posts, etc. Very handy to create shortcuts to commonly-typed and/or lengthy text/HTML, or for smilies.
-
-
Extended Description
This plugin can be utilized to make shortcuts for frequently typed text, but keep these things in mind:
Your best bet with defining shortcuts is to define something that would never otherwise appear in your text. For instance, bookend the shortcut with colons:
:wp: => <a href='http://wordpress.org'>WordPress</a> :aol: => <a href='http://www.aol.com'>America Online, Inc.</a>
Otherwise, you risk proper but undesired replacements:
Hi => Hello
Would have the effect of changing “His majesty” to “Hellos majesty”. List the more specific matches early, to avoid stomping on another of your shortcuts. For example, if you have both:pand:pout:as shortcuts, put:pout:first, otherwise, the:pwill match against all the:pout:in your text. If you intend to use this plugin to handle smilies, you should probably disable WordPress’s default smilie handler. This plugin is set to filter the_content, the_excerpt, and optionally, get_comment_text and get_comment_excerpt. SPECIAL CONSIDERATION: Be aware that the shortcut text that you use in your posts will be stored that way in the database (naturally). While calls to display the posts will see the filtered, text replaced version, anything that operates directly on the database will not see the expanded replacement text. So if you only ever referred to “America Online” as “:aol:” (where:aol: => <a href='http://www.aol.com'>America Online</a>), visitors to your site will see the linked, expanded text due to the text replace, but a database search would never turn up a match for “America Online”. However, a benefit of the replacement text not being saved to the database and instead evaluated when the data is being loaded into a web page is that if the replacement text is modified, all pages making use of the shortcut will henceforth use the updated replacement text. -
Screenshots
Installation
Download the file text-replace.zip and unzip it into your wp-content/plugins/ directory. Activate the plugin through the ‘Plugins’ admin menu in WordPress. Go to the Options → Text Replace (or in WP 2.5: Settings → Text Replace) admin options page. Optionally customize the settings (notably to define the shortcuts and their replacements). Start using the shortcuts in posts. (Also applies to shortcuts already defined in older posts as well) SPECIAL NOTE FOR UPGRADERS: If you have used v1.0 or prior of this plugin, you will have to copy your $text_to_replace array contents into the plugin’s option’s page input field.-
Frequently Asked Questions
Q: Does this plugin modify the post content in the database?A: No. The plugin filters post content on-the-fly.
Q: Will this work for posts I wrote prior to installing this plugin?A: Yes, if they include strings that you’ve now defined as shortcuts.
Q: What post fields get handled by this plugin?A: The plugin filters the post content and post excerpt fields, and optionally comments and comment excerpts.
Q: Is the plugin case sensitive?A: Yes.
Q: I use:wp:all the time as a shortcut for WordPress, but when I search posts for the term “WordPress”, I don’t see posts where I used the shortcut; why not?A: Search engines will see those posts since they only ever see the posts after the shortcuts have been replaced. However, WordPress’s search function searches the database directly, where only the shortcut exists, so WordPress doesn’t know about the replacement text you’ve defined.
Release Log
08 Apr 2008 : v2.0 — Release notes. NOTE: Versions prior to v2.0 were documented here 27 Mar 2005 : v1.0 released –Moved the array $text_to_replace outside of the function and into global space Renamed function from text_replace() to c2c_text_replace() Changed license from BSD-New to MIT Added installation instruction and notes to plugin file Verified that plugin works for WordPress v1.2+ and v1.5+23 Sep 2004 : v0.92 released — added optional argument $case_sensitive (defaulted to ‘false’); changed from BSD-new to MIT license 09 Jul 2004 : v0.91 released, see comments 29 Jun 2004: v0.9 released to the public
Copyright & Disclaimer
Copyright © 2004-2008 by Scott Reilly (aka coffee2code)Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Acknowledgements
Thanks to all those who have contributed feedback and support!
