WordPress.org

Plugin Directory

Text Replace

Replace text with other text. Handy for creating shortcuts to common, lengthy, or frequently changing text/HTML, or for smilies.

Filters

The plugin exposes five filters for hooking. Typically, the code to utilize these hooks would go inside your active theme's functions.php file. Bear in mind that all of the features controlled by these filters are configurable via the plugin's settings page. These filters are likely only of interest to advanced users able to code.

c2c_text_replace_filters (filter)

The 'c2c_text_replace_filters' hook allows you to customize what hooks get text replacement applied to them.

Arguments:

  • $hooks (array): Array of hooks that will be text replaced.

Example:

// Enable text replacement for post/page titles
function more_text_replacements( $filters ) {
    $filters[] = 'the_title'; // Here you could put in the name of any filter you want
    return $filters;
}
add_filter( 'c2c_text_replace_filters', 'more_text_replacements' );

c2c_text_replace_comments (filter)

The 'c2c_text_replace_comments' hook allows you to customize or override the setting indicating if text replacement should be enabled in comments.

Arguments:

  • $state (bool): Either true or false indicating if text replacement is enabled for comments. This will be the value set via the plugin's settings page.

Example:

// Prevent text replacement from ever being enabled.
add_filter( 'c2c_text_replace_comments', '__return_false' );

c2c_text_replace (filter)

The 'c2c_text_replace' hook allows you to customize or override the setting defining all of the text replacement shortcuts and their replacements.

Arguments:

  • $text_replacement_array (array): Array of text replacement shortcuts and their replacements. This will be the value set via the plugin's settings page.

Example:

// Add dynamic shortcuts
function my_text_replacements( $replacements ) {
    // Add replacement
    $replacements[':matt:'] => 'Matt Mullenweg';
    // Unset a replacement that we never want defined
    if ( isset( $replacements[':wp:'] ) )
        unset( $replacements[':wp:'] );
    // Important!
    return $replacements;
}
add_filter( 'c2c_text_replace', 'my_text_replacements' );

c2c_text_replace_comments (filter)

The 'c2c_text_replace_comments' hook allows you to customize or override the setting indicating if text replacement should be enabled in comments.

Arguments:

  • $state (bool): Either true or false indicating if text replacement is enabled for comments. The default value will be the value set via the plugin's settings page.

Example:

// Prevent text replacements from ever being enabled in comments.
add_filter( 'c2c_text_replace_comments', '__return_false' );

c2c_text_replace_case_sensitive (filter)

The 'c2c_text_replace_case_sensitive' hook allows you to customize or override the setting indicating if text replacement should be case sensitive.

Arguments:

  • $state (bool): Either true or false indicating if text replacement is case sensitive. This will be the value set via the plugin's settings page.

Example:

// Prevent text replacement from ever being case sensitive.
add_filter( 'c2c_text_replace_case_sensitive', '__return_false' );

c2c_text_replace_once (filter)

The 'c2c_text_replace_once' hook allows you to customize or override the setting indicating if text replacement should be limited to once per term per piece of text being processed regardless of how many times the term appears.

Arguments:

  • $state (bool): Either true or false indicating if text replacement is to only occur once per term. The default value will be the value set via the plugin's settings page.

Example:

// Only replace a term/shortcut once per post.
add_filter( 'c2c_text_replace_once', '__return_true' );

Requires: 3.6 or higher
Compatible up to: 4.1.7
Last Updated: 2015-2-19
Active Installs: 4,000+

Ratings

4.1 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1 100,1,1
0,1,0 100,1,1
100,2,2
100,1,1
100,1,1
100,1,1 40,5,2
0,2,0
0,1,0 100,1,1
0,1,0
0,1,0
100,1,1
100,1,1
0,1,0