Edit the ‘Link’ Button in Wordpress

by Mike Haydon on 27 April 2008

I’m sick of having to put rel=”nofollow” and target=”_blank” into every tag when I’m posting (I am currently using Wordpress 2.5.1 on my own host). I thought “there’s gotta be an easier way”. There must be a way I can edit the “link” button to add those html attributes automatically… There is.

This is how to edit a button on the Wordpress composition panel:

Open the file wp-includes/js/quicktags.js in Wordpad (I don’t know the Mac equivalent). Notepad won’t let you see the file properly because it doesn’t read the line-breaks correctly.

Scroll down to the code where it says:

function edInsertLink(myField, i, defaultValue) {
if (!defaultValue) {
defaultValue = ‘http://’;
}
if (!edCheckOpenTags(i)) {
var URL = prompt(quicktagsL10n.enterURL, defaultValue);
if (URL) {
edButtons[i].tagStart = ‘<a href=”‘ + URL + ‘”>’;
edInsertTag(myField, i);
}
}
else {
edInsertTag(myField, i);
}
}

change the line:

edButtons[i].tagStart = ‘<a href=”‘ + URL + ‘”>’;

to read:

edButtons[i].tagStart = ‘<a href=”‘ + URL + ‘ rel=”nofollow” target=”_blank”>’;

save the file (ftp to your site) and you’re done! It’s that simple :razz:

PS. If you want to edit any of the other buttons, or add your own, such as a <h1> button, there is an excellent tutorial on editing wordpress buttons.

Popularity: 24%

[Post to Twitter]  [Post to Yahoo Buzz]  [Post to Delicious]  [Post to Digg]  [Post to Reddit]  [Post to StumbleUpon] 

Previous post: Why You NEED to Use Squidoo in Marketing

Next post: Photo Dropper – Wordpress Plugin Review