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 :

    1. Download the .zip file (see below).
    2. Unzip.
    3. Upload the broken-link-checker folder to you /wp-content/plugins directory.
    4. Activate the plugin in the Plugins tab.
    Related posts :

    2,584 Responses to “Broken Link Checker for WordPress”

    1. Mingo says:

      Yes 🙂
      Ok, thank you White Shadow ^^

    2. sajedene says:

      Hi! For some reason, I can’t make the latest version to work. The prior version works fine, but every time I try to upgrade, I get this:

      “Error: The plugin’s database tables are not up to date! (Current version : 4, expected : 5)”

      and a whole string of this :
      [ ] ALTER TABLE `wp_blc_filters` MODIFY COLUMN `name` varchar(100) NOT NULL
      Database error : Access denied for user ‘yscr_bbz7Sx’@’localhost’ to database ‘blog’

    3. White Shadow says:

      Does the DB account associated with WP have the ALTER TABLE privilege? The plugin needs to modify some of it’s tables to complete the upgrade to 0.9.5. (It shouldn’t need to modify that table, though. There might be a bug there.)

    4. sajedene says:

      Not sure. I would think it does since I can run the prior version. There is about 13 lines of that alter table thing for filters, `wp_blc_instances“wp_blc_links` and `wp_blc_synch` trying to add columns to those and not being able to.

    5. White Shadow says:

      Could you send me the full message list? If you don’t want to post it publicly, you can email me at whiteshadow [at] w-shadow (dot) com.

    6. sajedene says:

      I sent you the e-mail. Hopefully this can be resolved, as the plug-in was great when I was able to run it before the upgrade.

    7. How do I force it to use curl? I’m not checking internal links and have over 900 broken links as timeouts (and I have the timeout set to 120 seconds). It seems it’s not detecting/using curl because my other plugin that uses curl is snappy as can be.

    8. White Shadow says:

      @ sajedene:
      Email received, I’m looking into it.

      @ RT Cunningham:
      Tom Allen (the person who mentioned forcing curl usage) never got back to me, so I still have no idea why the plugin wasn’t detecting curl on his site – and how exactly he managed to fix it.

      Normally, the plugin detects curl by checking if the “curl_init” function exists.

    9. Ricardo says:

      Is it possible to set plugin BOT to check links once in a while? Set the time for searching, like twice a day?

    10. Ricardo says:

      As I meant – “New links will usually be checked ASAP. ” What as soon as possible means? Hours? Daily? Is there anywhere inside the code I ca change this frequency? It’s important for another project I’m creating.
      Thanks

    11. White Shadow says:

      If you have the “Run continuously while the Dashboard is open” option enabled, the plugin makes periodic AJAX requests that invoke the link searching & checking routines. This means that links in new links are usually detected and checked in 5-10 minutes. You can indirectly affect the frequency of the AJAX requests by changing the “Max. execution time” setting.

      If the aforementioned option is unchecked or none of the Dashboard pages are open, the plugin scans new and modified content (e.g. posts) for links once per hour. This is not configurable. However, if you’re familiar with plugin development, you can change this by tweaking the wp_schedule_event() call made on line 3103 of /core/core.php.

    12. I couldn’t figure out why curl wasn’t being selected automatically and then I checked function_exists and saw this note in the comments:

      “If you are trying to use this for testing a “function” within a class, then you need to use method_exists(). A “function” within an object is a method, not a function.”

      Other notes I’ve found suggest that the function will return false if used within a class. Anyway, what I did comment out what was there and copied the part for the curl_init without the file_exists function and it works perfectly. The link checker is faster, my internal links aren’t showing up as broken and external links aren’t timing out.

    13. White Shadow says:

      I read that comment too, but I didn’t think it would apply to curl_init as it’s not a “function within a class”. Interesting.

      Could you, as a test, try replacing function_exists with is_callable? I still need some way to detect if curl is available, and is_callable() looks like one possible alternative.

    14. That’s odd because line 18 of http.php says class ….

      Anyway, I changed it to is_callable for a different blog and I’m waiting to see what happens.

    15. I think you misunderstood that comment. It was talking about function_exists(), not curl_init(). I agree that it doesn’t seem to be a function within a class, but PHP is quirky in some areas.

      Anyway… the is_callable replacement seems to work, but I’ll need to wait for it go through 1253 links. I’ll let you know the result – it may take a day or two.

    16. I spoke too soon, way too soon. BLC isn’t working at all now. What I initially saw was just what the queue was attempting to process. I recently set up nginx as a reverse proxy to Apache and I just checked the logs. Nothing originating from the server. Looking at the curl code, I’m assuming I need to provide the proxy information or it won’t work. I’ll have to do some more digging…

    17. Well, I just tested curl from the command line and it works fine with no changes. I have no idea why it’s doing nothing in the plugin.

    18. White Shadow says:

      I’m not familiar with ngingx, so no clue about that. However, if the queue is not processing at all then that probably indicates that the plugin is crashing somewhere. Check your PHP error logs.

      Also, the plugin doesn’t use the command line client. It uses the libcurl bindings for PHP.

    19. Mr. White Shadow,

      I apologize. I didn’t do the one thing that solved all the problems. I didn’t delete the older version of the plugin and reinstall. In the process of doing that, I found that I didn’t have the proxy_read_timeout for nginx to Apache long enough (it was set to 60 and I doubled it because one of the post listing pages on a blog gave me a gateway timeout).

      It is now moving at warp speed. 200 links checked in like 10 minutes, 3 broken and 1 redirect (all are comments, by the way).

      Check you inbox for a message from PayPal in a few minutes.

    20. White Shadow says:

      Thank you for the donation, and I’m glad you got it fixed 🙂

      So was the curl thing relevant, or just a distraction?

    Leave a Reply