I’ve just finished my very first WordPress Plugin! It’s called External Link Icons,. It expands upon the idea in my earlier post, applying styles to external links. Instead of just changing colors and setting a target, this time around I use javascript to alter all external links to include the wikipedia external link icon.
It should be very easy to install (unarchive it in your plugins directory, and enable the plugin in wp-admin). See the readme.txt for more info.
If you use it, and like it, let me know.
Get the latest here:
.zip
.tar.gz
.tar.bz2
browse old releases
Revision history
Version 1.2
This fixes a couple of minor bugs, and adds a user-customizable url target in the admin. Release now includes .tar.bz2, .tar.gz, and .zip.
Version 1.1
Some folks were having problems with php warnings. I’ve modified everything to be “good code” that doesn’t generate any warnings — at least on PHP5. Since the javascript and css are actually output by PHP, a warning being output in the middle of a javascript can be disasterous to the script.
You might consider, if you have the control, to disable warning and error messages on production systems — send them to a file or syslog instead. You can do this through the php.ini, or through your .htaccess file.
Version 1.0
Why the big version jump? Well, it now includes an admin page allowing you to easily change the class that gets applied to the links, the containers to which the automatic css gets applied, and best of all, it lets you set the unique identifier that’s used to to exclude your local site from being linked. The ability to easily define multiple images (like changing colors on mouseover), as well as easily changing images, will be coming in Version 2.0. It also no longer overrides your specified link colors and decorations.
Version 0.3
- fixed javascript to be compatible with other onload scripts.
Version 0.2
- fixed internal anchor url’s (they’re local now).
- added styles for .entrytext
Version 0.1
- first release.
24 Comments
[...] Plugin WordPress: CA-Weton Plugin WordPress: External Link Icons External Link Icons usa javascript per modificare tutti i link esterni al blog aggiu [...]
i am getting a error
Warning: Missing argument 1 for eli_get_localhost() in [...]/wp-content/plugins/elicons/elicons.php on line 30
Warning: Missing argument 1 for eli_get_linkclass() in [...]/wp-content/plugins/elicons/elicons.php on line 41
And i don’t understand what went wrong
same problem
Warning: Missing argument 1 for eli_get_localhost() in [...]/wp-content/plugins/elicons/elicons.php on line 30
Warning: Missing argument 1 for eli_get_linkclass() in [...]/wp-content/plugins/elicons/elicons.php on line 41
Does it happen under both firefox and ie?
Safari and Tiger
And my server :
OS: Linux m
PHP: 4.3.11
MySQL: 4.0.24
It happen on opera / IE / firefox……..
Using WinXP Sp2.
I was thinking it had something to do with server setup. But i am on a Shared Webhost….
Apache version 1.3.33 (Unix)
MySQL version 4.1.11-standard
PHP version 4.3.11
And i have got a PHPH info… but i think it will be too large to copy and paste?
Same here. Both Firefox and IE. Running XP SP2. I have made everything read/write (just in case) and still get the error.
Ok, thanks for all the debugging info — turns out it’s a PHP issue.
What you’re seeing is warnings about possibly invalid code. The code runs just fine, but the php engine thinks there might be a problem.
However, since the code is outputting javascript and css, a warning message popping up in the middle of the javascript being output pretty much ruins everything. I’ve updated the code to not produce any warnings (v1.1) — by making it more correct.
I still highly recommend that you change your php setup to log errors to a file/syslog instead of displaying them, for security reasons.
i don’t think this log error doesn’t do any good for shared hosting. In this case at least i know i have a error shown. :p
Anyway i have always been wondering why your script didn’t include Icons picture. So how is the picture outputed?
Ignore what i said above about icon picture.
1.1 work ok. However i discover a little bug?
If i have a link which is very long like
xxxx jfh kfg kjgg what ever MSN Space
The icon doesn’t line up very well for some reason. However if i use a shorter verssion like simply “MSN space” then the spacing is fine.
Forgot to mention..( Is their any plug in that allow comment edit.. very irratiting to post a new comment everytime )
How do you update a plug in in WP? I simply upload the file and overwirte the orginal one. However the Admin page is still showing i am using version 1.0 (Even though everything is working ok. )
Depending on your hosts setup, if you have access to .htaccess you might be able to change the php settings regarding logging. Sorry, I don’t use Apache, so you’d have to check the php docs or with your webhost’s technical support on this.
About the admin portion — I forgot to update the version in the comments. Not a big deal, you have the correct version, not going to re-release for that.
Do you have a location where I can look at the spacing problem?
I’ve found that if your link is going span across lines you may have a slight issue with text-decorations getting cut off at the end of the first line.
Also, a trailing space inside the link text might present an issue throwing spacing off — you should never have extra whitespace at the beginning or ending of text inside an <a></a> tag.
um……. example here
http://edwardchick.solidinternet.com/?page_id=12
This is auto generated through My Plug in list. so i can’t do anything about it
2nd
http://edwardchick.solidinternet.com/?p=7
There is no space at start or end of a tag.
You have a javascript error on your page — document.getElementById(”commentform”) has no properties.
You must resolve any javascript issues before the external links will work, as javascript stops processing on the first error.
Thx for telling me that is a javascript error. Although it has nothing to do with why it didnt work. But in the process of that you helped me to find out 2 bugs in 2 other plug in
http://edwardchick.solidinternet.com/?page_id=12
I am wondering under what condition will it have this output problem. I have a quick scan through My Plug in code and it seems nothing that would change that. And the output on Opera 8 and Firefox is different.
I would think it is the “Usedplugin” plugin problem. Although i can not see how the same input in the file for URI and Name could generate different output. Thx anyway
Thanks for updating your plugin. I don’t have any problems other than the fact that it doesn’t seem to work in Firefox. Any ideas?
You can view my blog at http://www.tracyphillips.com.
Have a great day!
–Tracy
Hi, I’ve installed your plugin and it works very well! The only thing is I’ve noticed that all external links are now opened in a new window. I’m wondering if it’s possible to open the external links in the same window?
It would be nice to supply a zip archive… What program do you use to open that archive?
I have one little prorblem with your plugin: No picture is shown anywhere. I use the Dynamix Text Replace and the links created by this plugin do not have any external link icon next to them. ANy suggestion or idea how I can fix this?
@tracy
I found a solution for your problem. We just have to check, if there is a href-property. Named anchors do not have such a property. That’s the reason why the script fails on Firefox.
Open js.php
add this line:
if (typeof href == “string”){
after line 7:
href = atags[i].getAttribute(”href”);
add one additiional curly brace “}” after
else {atags[i].target = “”;}
@moliu
Open js.php
and delete the following line:
atags[i].target = “_” + href;
Hope it helps, greetings from Switzerland.
Hey everyone. Sorry there hasn’t been any activity lately. I’m on my lunch break right now, wanted to let everyone know that when I get home tonight I’ll be packaging up and releasing elicons 1.2. It fixes the firefox bug (thanks Hey!), adds user-customizable target to the admin, and makes sure your href=”" actually has some content too. It will be released in .zip, .tar.gz, and .tar.bz2.
There is one issue I haven’t figured out a good solution too, and I’m open to suggestions. If you look at iwod’s page http://edwardchick.solidinternet.com/?page_id=12 , you’ll see that the position on many elements is messed up.
This is because of links being formatted like this:
<a href=”" rel=”nofollow”>blah
</a>
There really should not be ’s or even newlines inside an <a>, but is especially harmfull in this case because it’s at the end. I could fix this by automatically stripping any html out of your links, but I don’t think that’s a really good idea.
iwod, I suggest you contact the plugin’s author and explain the situation to him. See if his plugin can handle stripping out the ’s and \n’s that are causing the problem.
Any other thoughts/ideas/opinions on this issue are most welcome.
In other news,
I’ll be releasing the next iteration of the niftycorners plugin sometime next week most likely, and the theme by the end of the month. I’ll also be making a new, large posting this weekend about what’s been going on with me lately.
Well, 1.2 is officially released. Enjoy!
I accidentally broke the permalink for this entry by updating the timestamp. Boyhowdy, I won’t be doing that again!
[...] Se o seu tema não incorpora esse pequeno detalhe, você pode adicioná-lo como plugin, é o External Link Icons. [...]
Leave a reply