Linkify Text
- Author:Scott Reilly
- Version:1.0
- Last update:2011-12-05
- Compatibility:WP 3.1 – 3.3.2
- Comments:go here
- Download:[ zip ]
- Description:
Automatically hyperlink words or phrases in your posts.
-
Extended Description
Automatically hyperlink words or phrases in your posts.
This plugin allows you to define words or phrases that, whenever they appear in your posts or pages, get automatically linked to the URLs of your choosing. For instance, wherever you may mention the word “WordPress”, that can get automatically linked as “WordPress“.
Links: Plugin Homepage | Author Homepage
Find out more at the plugin’s WordPress Plugin Repository page.
Installation
- Unzip
linkify-text.zipinside the/wp-content/plugins/directory (or install via the built-in WordPress plugin installer) - Activate the plugin through the ‘Plugins’ admin menu in WordPress
- (optional) Go to the
Settings->Linkify Textadmin options page and define text and the URLs they should point to
- Unzip
-
Filters
The plugin exposes four filters for hooking. Typically, the code to utilize these hooks would go inside your active theme’s functions.php file.
c2c_linkify_text_filters (filter)
The ‘c2c_linkify_text_filters’ hook allows you to customize what hooks get text linkification applied to them.
Arguments:
- $hooks (array): Array of hooks that will be text linkified.
Example:
// Enable text linkification for custom fields add_filter( 'c2c_linkify_text_filters', 'more_text_replacements' ); function more_text_replacements( $filters ) { $filters[] = 'the_meta'; // Here you could put in the name of any filter you want return $filters; }c2c_linkify_text_comments (filter)
The ‘c2c_linkify_text_comments’ hook allows you to customize or override the setting indicating if text linkification should be enabled in comments.
Arguments:
- $state (bool): Either true or false indicating if text linkification is enabled for comments. The default value will be the value set via the plugin’s settings page.
Example:
// Prevent text linkification from ever being enabled in comments. add_filter( 'c2c_linkify_text_comments', '__return_false' );c2c_linkify_text (filter)
The ‘c2c_linkify_text’ hook allows you to customize or override the setting defining all of the text phrases and their associated links.
Arguments:
- $linkify_text_array (array): Array of text and their associated links. The default value will be the value set via the plugin’s settings page.
Example:
// Add more text to be linked add_filter( 'c2c_linkify_text', 'my_text_linkifications' ); function my_text_linkifications( $replacements ) { // Add text link $replacements['Matt Mullenweg'] => 'http://ma.tt'; // Unset a text link that we never want defined if ( isset( $replacements['WordPress'] ) ) unset( $replacements['WordPress'] ); // Important! return $replacements; }c2c_linkify_text_case_sensitive (filter)
The ‘c2c_linkify_text_case_sensitive’ hook allows you to customize or override the setting indicating if text matching for potential text linkification should be case sensitive or not.
Arguments:
- $state (bool): Either true or false indicating if text matching is case sensitive. The default value will be the value set via the plugin’s settings page.
Example:
// Prevent text matching from ever being case sensitive. add_filter( 'c2c_linkify_text_case_sensitive', '__return_false' );
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 with links.Q. What post fields get handled by this plugin?
A. By default, the plugin filters the post content, post excerpt fields, widget text, and optionally comments and comment excerpts. You can use the ‘c2c_linkify_text_filters’ filter to modify that behavior (see Filters section).Q. How can I get text linkification to apply for custom fields (or something not linkified by default)?
A. You can add to the list of filters that get text linkified using something like this (added to your theme’s functions.php file, for instance):// Enable text linkification for custom fields add_filter( 'c2c_linkify_text_filters', 'more_text_replacements' ); function more_text_replacements( $filters ) { $filters[] = 'the_meta'; // Here you could put in the name of any filter you want return $filters; }Q. Is the plugin case sensitive?
A. By default, yes. There is a setting you can change to make it case insensitive. Or you can use the ‘c2c_linkify_text_case_sensitive’ filter (see Filters section).Q. What if the word or phrase is already linked in a post?
A. Already linked text will not get linked again by this plugin (regardless of what the link may be).
Release Log
1.0
- Initial release
Copyright & Disclaimer
Copyright © 2011 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.
