Package/plugin/module WordPress

Dynamic Text Replace v2.0

I’d like to announce the official release of the updated Dynamic Text Replace plugin (v2.0) for WordPress.

Define your own custom dynamic text replacement pseudo-functions (i.e. ::google("search terms here")::)

The plugin’s official homepage is located at :

This release debuts the admin options page for the plugin, which provides an interface to define the dynamic text replacement shortcuts and expansions. Options are now stored in the database (negating the need to edit the plugin file). The substitution strings %text_altered% and %display% are now filterable. The release also brings with it full compatibility with WordPress 2.3+ and 2.5.

This update is part of coffee2code’s 14 Days of Plugins (updated plugin #13).

Comments welcome on this post for this version of the plugin. Comments will be closed once this release has been superseded by another.

Read more for a detailed ChangeLog of the release.

Detailed ChangeLog

These are the detailed changes, which may or may not make sense to you depending on your familiarity with the previous features and internals of the plugin.

  • Created its own class to encapsulate plugin functionality
  • Added an admin options page
  • Use preg_replace_callback() instead of preg_replace() and thus modified the argument handling of the replacement helper function
  • Added ‘yahoo’ pseudo-function
  • Removed hard-coded inclusion of text alternation for known pseudo-functions from dynamic_text_replace_helper()
  • %text_altered% now more easily user-definable by filter on ‘dynamic_text_replace_$pseudofunction’ where $pseudofunction is the pseudo-function name
  • %display% now also filterable via filter on ‘dynamic_text_replace_display_$pseudofunction’
  • Added documentation on the %text_altered% and %display% filtering
  • Fixed replacement string for ‘amazon’ pseudo-function
  • Added extended description
  • Tweaked description and installation instructions
  • Added compatibility note
  • Updated copyright date and version to 2.0
  • Moved into its own subdirectory; added readme.txt and screenshot
  • Tested compatibility with WP 2.3.3 and 2.5

6 replies on “Dynamic Text Replace v2.0”

very nice
I am looking forward to taking advantage of this.
just to let you know you seem to make some of the most useful plugins I have found for WP. keep up the good work.


Great plugin! Had been looking for something like this for a while. And I can confirm it’s working in WP 2.7.1.

I’d like to modify the plugin slightly so that users don’t need to do the double colons, and ideally not the parentheses either. So shortcuts would look like


Currently, they have to do


For my use this would be the only shortcut on the site, and that simplicity would help a lot.

But I’m looking at the code and realizing I don’t speak regex. Any hints on how to change this?

Okay, figured out how to get rid of the :: and :: requirements — just delete them. So now I’ve got


but I’d still like to get it to


Here’s the original code:

  function dynamic_text_replace( $text ) {
    $text = preg_replace_callback(
  //      "#(::([^\(]+)\(([^\)]+)([ ]*,[ ]*([^\)]+))?\)::)#imseU",
        "#(::([A-Za-z0-9\-]+)\([ ]*\"?([^\"][^\)]+)\"?([ ]*,[ ]*\"?([^ \"][^\)]+))?\"?[ ]*\)::)#imsU",
        array(&$this, 'dynamic_text_replace_helper'),
    return $text;
  } // end dynamic_text_replace()

What’s the difference with the commented-out line?

I have a strange situation about this plugin (or maybe there is something that I do not understand about it).
I forgot to give “write” permissions to the plugin file on the server but I edited the functions through the administration panel and it worked. Then I realised that the function itself wasn’t saved in the plugin file (dynamic-text-replace.php) but somewhere else (I can’t seem to find it in any other place). I was wondering if you might give me a short notice about where the functions edited in the settings panel get saved to.

Best regards,

Victor: It sounds as though you were using the administration panel provided by the plugin to edit the dynamic text replace shortcuts? If so, that data doesn’t get saved back to the plugin’s file; it gets saved into the database. It’ll be in your blog’s wp_options table associated with the c2c_dynamic_text_replace option_name field. You don’t need to make the plugin’s file writable (and you shouldn’t) since that is not necessary.

Comments are closed.