WordPress.org

Ready to get started?Download WordPress

Forums

Plugin: Text Replace (18 posts)

  1. Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

    Hello, all! Sorry for what will be a burst of plugin announcements for me, but I haven't been able to make available the plugins I've developed over the last couple of weeks until now.
    Plugin: Text Replace
    Description: Replace text with other text in posts, etc. Very handy to create shortcuts to commonly-typed and/or lengthy text/HTML.
    Details can be found at
    http://www.coffee2code.com/archives/2004/06/29/plugin-text-replace/
    All of my plugins can be found at http://www.coffee2code.com/wp-plugins/
    Example:
    You have to edit the plugin file to add additional shortcuts and their replacement text. The plugin is primed with one shortcut:
    ":wp:" => "WordPress",
    This plugin could also be used to do smilies:
    "8)" => "<img alt='cool' src='http://mysite.org/wp-images/cool.gif' />",
    For former Movable Type users, this should be able to replicate the functionality of <MTMacroDefine> under MT (or at least my usage of it).
    -Scott

  2. davidchait
    Member
    Posted 10 years ago #

    interesting! I'm about to release something that should be rather complementary -- mine does functional replacements/insertions, while sounds like yours does 'shorcut' replacements... hmmm.
    -d

  3. Anonymous
    Unregistered
    Posted 10 years ago #

    Another great hack (not a plugin) is Tony Bierman's phpGiggle. It a tool to automatically link key words and phrases in HTML documents. I've been using it since I made the switch to WordPress and it is easy to install and configure.

  4. Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

    David: Looking forward to your plugin!
    Bill: I came across phpGiggle when I first switched over to WordPress, and based on a cursory look at its description, for some reason thought it did text replacement. But once I sat down to make use of it, I realized it hyperlinked matching text. Which unfortunately was not what I needed. I was converting posts that made use of shortcuts already, and I wanted to continue to do so. Hence, Text Replace.
    -Scott

  5. JetMax3
    Member
    Posted 10 years ago #

    I need some help with this plugin. I'm using it for several smilies, but I keep getting this error:
    Warning: Cannot add header information - headers already sent by (output started at /usr/local/psa/home/vhosts/therandomist.net/httpdocs/journal/wp-content/plugins/text-replace.php:105) in /usr/local/psa/home/vhosts/therandomist.net/httpdocs/journal/wp-admin/options.php on line 115
    Sometimes the line number changes, and the second path changes, but generally it's a common problem that occurs whenever I edit anything in WordPress, and it's pretty annoying. I don't have any functional knowledge of PHP, so with that in mind, any solutions? I probably just set it up wrong or something... thanks. :)
    -JMX

  6. Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

    Did you install the plugin from the .zip or by copying the text from the .phps file? With the later, I've heard of extra spaces after the ?> at the end of the script could cause problems(??).
    Also, what sort of smilies are you defining? Remember that '(' and ')' need to be escaped:
    ":\(" => "<img alt=':(' src='/wp-images/sad.gif' />",
    Other non alpha-numeric characters might also need to be escaped, such as '{', '}', but I'm not positive.
    -Scott

  7. Mark (podz)
    Support Maven
    Posted 10 years ago #

    @Jetmax3 - "headers already sent"
    Do a search for that or "whitespace"

  8. JetMax3
    Member
    Posted 10 years ago #

    Thank you very much. That did the trick. Just one simple space after the closing tag, how dumb...
    Again, thank you. :-)
    Coffee2Code, I appreciate your help, as well. With the '?>' closing tag, you hit the nail on the head. One space after. Also, as a recommendation, try defining other characters that need to be escaped within your instructions. I had a lot of problems with this, turned out that I needed to escape the question mark symbol I was using to define one of my smilies. I don't know if you have to do the same with brackets or not, but it was a problem that took me about thirty minutes of trial and error to solve. But very nice software, works perfectly now. :)
    -JMX

  9. emsdc
    Member
    Posted 10 years ago #

    Is it possible to use the Text Replace plugin for the_author?
    Looks like it only works for the_content and the_excerpt.
    Thanks.

  10. emsdc
    Member
    Posted 10 years ago #

    I was looking for a way to do text replace for the_author, and I think I have a way to do text teplace for the whole index now. I save my index.php as index_unfiltered.php and upload, and then create a new index.php that contains this and only this:
    <?php
    ob_start();
    require("index_unfiltered.php");
    $index_page = ob_get_clean();
    ob_start();
    $text = $index_page;
    $oldWord = array("phrase1","phrase2","phrase3","and so on");
    $newWord = array("new1","new2","new3","and so on");
    $filtered = str_replace($oldWord , $newWord , $text);
    echo $filtered;
    ob_end_flush();
    ?>
    ...and then I only edit index.php if I want to add new words/phrases to the array. Otherwise I edit and upload index_unfiltered.php as if it were my index. I'm very, very new at PHP so I don't know if this approach will slow things down if my array gets long. I'm just putting it out there... but of course if you're looking for a way to focus your find/replace on just the_content or the_excerpt then the text teplace plugin is great for that. Someone please yell at me if there's a downside to how I'm doing things.

  11. Plugin updated to v0.92
    http://www.coffee2code.com/archives/2004/06/29/plugin-text-replace/

    • Added argument to set case sensitivity of search for text replacement.
    • Also, in a previous release of this plugin (though not mentioned here), the need to escape special characters in the shortcut text (as noted above in discussion with JetMax3) is no longer necessary.
  12. Anonymous
    Unregistered
    Posted 9 years ago #

    Anyway to get this to work with Mt.DewVirus's Recemt Comment Plugin?
    thanks

  13. Anonymous
    Unregistered
    Posted 9 years ago #

    I have an idea.. How can i change the below.. to make it scan the entire index php. or perhaps the menu..
    or somthing..
    add_filter('the_content', 'text_replace', 50);

  14. Anonymous
    Unregistered
    Posted 9 years ago #

    Got it to work. There was a fix for the whole index page. 3 posts up. my bad.
    Thanks alot guys

  15. Plugin updated to v1.0
    http://www.coffee2code.com/archives/2004/06/29/plugin-text-replace/

    Updates in this release:
    * 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+

    Note to upgraders: Be sure to save a copy of your $text_to_replace array from your current version of the plugin so that you may include it in the newer version.

  16. mcmike
    Member
    Posted 9 years ago #

    Maybe *just an idea* you can use either:
    1) seperate file for the text to replace OR )better IMO(
    2) MySQL support for replace texts
    And have an admin-item to do that :)

  17. Dgold
    Member
    Posted 9 years ago #

    Having a bit of trouble with the cool Text-Replace plug-in. It seems to only work on new posts for me, so far, maybe. If you can help please see the thread http://wordpress.org/support/topic/39189

  18. ewald
    Member
    Posted 7 years ago #

    im trying to change source code so links will automatically bypassed trough my tradescript, but when i have this:
    "<a href='" => "<a href='http://www.naughtylog.com/cgi-bin/at3/out.cgi?trade=",
    it just wont work, could anybody help me?
    thanks in advance

Topic Closed

This topic has been closed to new replies.

About this Topic