WordPress – Stop readers from escaping your blog

Version: 23.1
Revision: 12 Build 16a

Wordpress – Stop readers from escaping your blog!

Introduction:
when I was reading my novel, I have a strange feeling that many WordPress owners, they will be very angry when a user escape their blog, when they clicked on another reader’s avatar / url. So, to prevent that, we need to implement a single tweak, by opening a new website in a new window.

All you have to do is insert this code: “_blank” into your “comment-template.php” directory and save your file for the changes to take effect.

Simple As Pie!

1.] Log into your Cpanel or FTP server and navigate yourself to this directory…

…/wp-includes/comment-template.php

Notes: if your wordpress is under a root /sub directory, then you need to navigate yourself to this directory. Nevertheless, its not that different from the above…

…/blog/wp-includes/comment-template.php

See the difference? I think you so…

2.] Open your “comment – template” file and scroll down, in – between line: 138 ~ 150.
Then you’ll see something that looks similar to this (it depends on your WordPress Version).

function get_comment_author_link() {
	/** @todo Only call these functions when they are needed. Include in if... else blocks */
	$url    = get_comment_author_url();
	$author = get_comment_author();

	if ( empty( $url ) || 'http://' == $url )
		$return = $author;
	else
		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
	return apply_filters('get_comment_author_link', $return);
}

3.] Now, you’ll need to alter the codes. It should look like this…

function get_comment_author_link() {
	/** @todo Only call these functions when they are needed. Include in if... else blocks */
	$url    = get_comment_author_url();
	$author = get_comment_author();

	if ( empty( $url ) || 'http://' == $url )
		$return = $author;
	else
		$return = "<a href='$url' rel='external nofollow' target='_blank' class='url'>$author</a>";
	return apply_filters('get_comment_author_link', $return);
}

See any difference from the original and the modified version? It looks very easy, right?
If you cannot identify the difference, you can skim each lines, as it should help you identify the similarity.

That is all for today!

Copyrighted By Lair360 – 2009

Comments are closed.