Broken Link Checker for WordPress
Notice: This plugin has been transferred to ManageWP. I am no longer working on it. Please direct any feedback to the new developer. See the plugin homepage for more information.
Sometimes, links get broken. A page is deleted, a subdirectory forgotten, a site moved to a different domain. Most likely many of your blog posts contain links. It is almost inevitable that over time some of them will lead to a “404 Not Found” error page. Obviously you don’t want your readers to be annoyed by clicking a link that leads nowhere. You can check the links yourself but that might be quite a task if you have a lot of posts. You could use your webserver’s stats but that only works for local links.
So I’ve made a plugin for WordPress that will check your posts (and pages), looking for broken links, and let you know if any are found.
Features
- Detects links that don’t work, missing images, deleted YouTube videos and other problems.
- Periodically checks links in posts, pages, comments, custom fields and the blogroll.
- New and modified entries are checked ASAP.
- Notifies you on the Dashboard if any problems are found.
- Lets you edit all instances of a specific link at once.
- Gives you a list of all links ever posted on your site, with the ability to search and filter it.
- Lets you apply custom CSS styles to broken and removed links.
- Highly configurable.
The broken links show up in the Tools -> Broken Links tab along. If any invalid URLs are found a notification will also show up on the Dashboard widget. To save screen real-estate, the widget can be configured to stay closed most of the time and automatically expand when broken links are detected.
Download
broken-link-checker.zip (412 KB)
Requirements
- WordPress 3.0 or later
- MySQL 4.1 or later
The current version of this plugin is only compatible with WordPress 3.0 and up. If you have an older version of WP, try one of the older releases. Specifically, version 0.8.1 is the last one that’s still compatible with the WP 2.8 branch, and version 0.4.14 is the last one compatible with WP 2.1 – 2.6.x.
Installation
Install “Broken Link Checker” just like any other WordPress plugin :
- Download the .zip file (see below).
- Unzip.
- Upload the
broken-link-checker
folder to you/wp-content/plugins
directory. - Activate the plugin in the Plugins tab.
All of the options are found under Options -> Link Checker (or Settings -> Link checker if you have WP 2.5).
The “time period” option is on that same page and is called “Check Every Post Every [X] hours”. To get the strikethrough effect you need to enable the “Broken Link CSS” option, too (I think it should be on by default) and, if you have any caching plugins, make sure the cache is refreshed.
That should do it π
I get Error: Couldn’t update the post (DB error)
on almost every second thing I want to “unlink”.
besides, great plugin!
jez, I don’t see anything in the code that could cause this. In fact, you should never see that error message, except when the post containing the link no longer exists at the moment you click “Unlink”.
I’ll make the error reporting a bit more verbose in the next version, but that’s all I can do for now.
I do now get “Error: Couldn’t update the post” (with the brand new version)
If you really have the new version there should be a more detailed error message in parentheses after the basic message. Or just empty parentheses if the error was that there is no error π
Eh, I don’t know.
Hi, Great plugin. But it seems not to be working with wikipedia links.
The following link is detected broken
http://fr.wikipedia.org/wiki/Jackson_Richardson
Hi
I spoke to my host and figured why i was getting error500 with this plugi. they say they do not support AJAX at moment ???? Thing is the plugin did use to work, can i revert back to an old version. Is AJAX for recent versions? I am puzzelled. All i know is it used to work and the host are saying that they have never allowed AJAX so they dont know why it did? Can you advise pelase ?
Thanks
@Abi : The plugin has always used AJAX, since the very first version. I also find it highly unlikely that your host “doesn’t support AJAX”. After all, AJAX isn’t something that you need to enable or install server-side. Anyway, you could try to install an older version of the plugin and see if that works. You can find the previous versions here.
@Jandry : I’ll check the link on my blog. We’ll see how this goes.
I can confirm the wiki issue.
Right this is strange, i went all the way back to original version and uploaded it and it worked fine. No error 500 so i thought i would test for you all way through to see what version broke. I got all the way to the newest version which is now appearring to work fine so far??? In doing this i completely deleted the borken links directory before uploading the new version? Has this had anything to do with it now working?
To be honest, I don’t know. Maybe some of the plugin files were corrupted and reinstalling fixed it. Or maybe it’s the full moon that makes it work π
@Jez, Jandry : The Wiki link works on my blog. Maybe Wikipedia is blocking automated access from your site (some sites tend to do that).
Hey White Shadow, first of all thanks for the plug in! The only problem is I have 160 broken links (I changed my domain name…heh) and so it becomes a hassle having to click ‘Edit Post’ for each broken link and search for the link within the post. I’m sure the majority of the people if not everyone using your plugin have around the same amount of broken links if not more, after all if it weren’t that many they wouldn’t have a use for this plugin in the first place.
For this reason I’m wondering how feasible it would be to implement a feature with AJAX where, within the broken link list, one can click the broken link URL or something and it becomes a text box, and then once someone clicks outside of the box or a button, it changes the link that way. It would be tremendously helpful. I would do it myself but I’ve no AJAX experience let alone Javascript experience (I just occasionally hack away with my knowledge of other languages). However if you do (And I really hope you do) choose to try to implement this, I would be glad to test this it for you if you need testers. Just wondering if you’ve ever thought about that, I’m positive everyone using this plug in would benefit from this.
My AJAX experience is a bit limited, but the idea seems doable and useful. I’ll add it to my “idea file” (aptly named arrgh.txt), though I make no promises as to when it’ll be implemented.
You see, if I immediately went after every suggestion I get for my programs, scripts and plugins, I would never get anything new done (well, I do usually fix reported bugs ASAP). So it might take a while for me to get around to it. I’m sure you understand π
Yeah I do, maybe in that time I’d have learned AJAX and done it myself π But I’m glad you think it’s a good idea anyways and have added it to your todo list, though I’m curious as to how you couldn’t have thought of it before π Really though, it’s obvious that it would make your plugin truly complete. Thanks for the consideration!
Complete, you say? Ah no, not even close. To be “complete” it would need to do at least the following :
* Also check for missing CSS files.
* And missing JavaScript.
* Check blogroll links.
* Check links in comments.
* Actually, check all links.
* Have a link checking function that doesn’t trigger any bot detectors.
* Gracefully handle “soft” 404 – when a site doesn’t send the expected 404 Not Found HTTP response, but displays a search page or something like that instead.
* Work without CURL (for compatibility).
* And so on (ad infinitum?).
There are always more ideas than there is time (or enthusiasm, or skill) π
”
* Also check for missing CSS files.
* And missing JavaScript.”
I understand your enthusiasm but this doesn’t necessarily have to be in a broken LINK checker, as broken link checker implies hyperlinks, nevertheless it would be a great feature.
Really though, not trying to nag you or anything, but wouldn’t this be a simple thing to do? Just take a look at the code in 2.5 that handles the following: when you go to write a post, it automatically generates a post slug under the post title. You can click on this slug and it’ll turn into a box with which you can change the post slug. Just use this same code to do the box thing. Then in the manner that you found the link within the post (Regex? Or did you hook onto a WP function? I’ll look at the plugin code later), change the link within the post.
I might try and hack something together later, I’ll give you whatever I could come up with, if anything.
It’s regexps + some hooks to know when a post if modified. You’d probably need to access the DB directly to modify a post (there’s probably an internal function for that, but I’ve found the documentation pretty spares in this regard).
I have a general idea of how to do the box thing at the moment… And sure, feel free to send me any code you might come up with.
Thank you very much!
This is a great plugin and made possible to for me to check and fix more than 3000 pages with 9000 links.
Is there a possibility to start it as cron job?
Not in the current version, but if you know PHP, it should be pretty easy to modify wsblc_ajax.php to work with cron. You’d need to slightly modify it so that wsblc_ajax.php?action=run_check doesn’t require the user to be logged in.
I’m not going to add official cron support to the plugin because many users don’t have the option to use cron.
Thank you a lot! I will do it with wsblc_ajax.php. Have a nice weekend!