Stray random quotes plugin refresh fix


Back in the day, I decided to use the stray random quotes plugin to place a random quote at the bottom of each page. It worked, and still does. Only, if you clicked on a quote it didn’t refresh – instead it said ‘Loading…’ and then placed an error in my web server log like this (not that it looked like you could even click on a quote anyway – the mouse cursor didn’t change to the ‘pointy-finger’):

PHP Fatal error:  Call to undefined function get_stray_quotes() in <path>/stray_ajax.php

I’ve known it didn’t work for ages, but not especially cared, and then this morning I’m putting off doing actual work, so I fixed it.

The Fix

The problem was that like many people, I’ve moved the file wp-config.php outside of the web-facing folder, so instead of living in /var/www/ it actually lives in /var/. Stray_random_quotes tells you that if you’ve moved your wp-config.php then you need to provide the modified path in stray_ajax.php itself, right near the top – so do so!

The first two lines of stray_ajax.php should now read:

// If your 'wp-content' directory is not in the default location you have to enter the path to your blog here. Example: '/home/www/public_html/wp'
$changedDir = '/var/';

That should do ‘er – now, stray_ajax.php should be able to call wp-config, which will allow it to call get_stray_quotes().


When monkeying with wp-config, I saw that it was calling wp-settings, but the call was failing because they expect to be in the same folder, only as mentioned – wp-config.php is up a level from wp-settings.php (which holds no credentials), so, to fix this:

– Edit /var/wp-settings.php and right at the bottom, change the path to the wp-config.php file to be:

/** WordPress absolute path to the Wordpress directory. */
if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . '/www/');   <------ changed this from '/' to '/www/' 
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

How To: Disable All WordPress Plugins from the Database

I added a couple of WordPress plugins the other day to tack on a little bit of extended functionality to the site, but things went badly, and some bizarre interactions between plugins meant that I couldn’t log in to the WordPress administration interface – it would just throw me back to the main site without even having the option to log in… As such, I couldn’t disable the plugins (because you need to be in the administration interface to do that!), so what the heck to do?

You might think to ssh in to the box and remove the plugins from the …/wp-content/plugins/ folder to disable them (as I did) – only this won’t work. What we really need to do is disable the plugins directly from the database – and luckily for us it’s a pretty simple process as long as we can ssh into the box!

Note: If you dont’ have ssh access to your server, you could always take the phpMyAdmin route to achieve the same goal through a web interface, but if the problem you have is related to being redirected all the time (like mine was) then the direct DB access way is really the only way to go!

Gaining SSH Access

If you’re running linux you’ve already got a ssh client built in, if you’re on Windows then you’ll probably want to get yourself a copy of PuTTY or such.

Assuming the IP address of your server is, then you can ssh to the box with:


In the above command the switch is “minus lower-case-L”, not “minus pipe-symbol” or anything, and if you’ve changed your ssh port away from the default of 22, then you can just add the switch -p , so if my ssh daemon was running on port 2233, and I wanted to log in as the user bob, I’d use:

ssh -l bob -p 2233

Connect to MySQL

Once you’ve got a ssh connection to the server, the next thing you’ll want to do is connect to your database, with the following command:

mysql -u <MYSQL-USER-NAME> -p

So if I had a MySQL administrator called dbAdmin I’d use:

mysql -u dbAdmin -p

The -p switch on the end will prompt you to enter the password for your MySQL admin user account – don’t worry if you’ve forgotten the credentials you should use – they’ll be in your WordPress wp-config.php file, which is usually located in your www or htdocs root folder (on Linux this is usually /var/www).

Quick Tip: By placing your wp-config.php file in the web root it’s possible for it to be accessed by malicious types, but you don’t have to place it here! You can, in fact, move the file one level up so that it’s outside of the web-root and WordPress will still be able to find it, but scoundrels won’t! So if you’re running WordPress with all your files in /var/www/ just move the wp-config.php file up to /var/ and it’ll still work and be safer! You can do this from the ssh terminal with:

cd /var/www
mv wp-config.php ..

Manipulate the Database

Once you’ve got administrator access to MySQL you need to connect to your database (again, the database name will be in your wp-config.php file), so if we’d called our database myWebDB then we could connect to it through the MySQL command line interface with:


Once this has connected successfully, all you have to do to disable all plugins is issue the following command:

UPDATE wp_options SET option_value = 'a:0:{}' WHERE option_name = 'active_plugins';

That’s it! Attempt to access your site! Any plugins which were causing mayhem will now be disabled, and you can then add them back one-by-one until you find the combination that’s stuffing things up!


Props: Many thanks to Jeff Star of PerishablePress for his article Quickly Disable or Enable All WordPress Plugins via the Database which saved my bacon, and prompted me to write this quick guide.
Flattr this

How To: Assign WordPress Posts to Specific Pages

WordPress is a really nice WCMS and I’ve been really happy with it ever since I first migrated over back in February ’09, but it definitely has some limitations with regard to how you can structure your site.

Let’s take an example: Joe Blow has a site on hunting, camping and fishing – he writes regular articles on each of these specific categories, and he wants these posts to turn up either just in the specific Hunting/Camping/Fishing pages he’s created, or he wants them to turn up on the home page and also in the category specific pages.

I came up against this problem when I wanted to import a bunch of articles from back when I ran on PHP-Nuke – I didn’t want the “new” (i.e. imported from Nuke) posts cluttering up the home page of the site, I wasn’t going to run the old Nuke portal because it’s full of deprecated code & security flaws – but I wanted the old posts added and available from an “Old Site” page which I could put in the header – so how do we go about this? Easily – via a couple of useful plugins!


Before we continue, it’s worth spelling out exactly how WordPress defines Posts, Pages and Categories so we don’t get our terminology all mixed up and make things harder than they have to be:

  • A Post is a single article entry, with at least one category (even if that category is the “uncategorised” category!) and may optionally contain some some tags which are keywords for the article.
  • A Page is a static, single post which can be easily be linked into the header of your site. It does not contain other posts – it is simply a single post with a special tag that makes it easy to link in the header, and is commonly used to put information about the website author, FAQs, contact pages etc.
  • A Category is a database field associated with an article to categorise it, such “Hunting”, “Fishing”, “Humour”, “Politics” etc. You usually set up a bunch of categories, and then select one or more of them to categorise your article, so for a funny joke about fishing, you might have the post categorised with both the “Fishing” and “Humour” categories, and you can then select to view all posts which are classified as this category or that category in a single page (or all posts of some category, showing 5/10/20 posts at a time etc.).

The Fix

This is all well and good – but it’s this static, single post nature of Pages that what’s so unintuitive and can easily trip us up – we can’t link to categories from a page (well, you can, but you have to link from inside the static page, and then you just get a list of article links – which sucks), so we need something to be able to do that for us – and this is where the plugins come in. Specifically we’re going to be using:

  • Mark Jaquith’s Page Links To plugin, and
  • The RYO Category Visibility plugin [optional – get the beta version from the bottom of the post to use with WordPress 3.01 and higher!]

In combination these two plugins will set a page (i.e. header link) so that instead of it going to a single static “Page”, it instead links to a category list of posts of a given category, and (if you want to) additionally stop posts assigned to specific category from turning up on the main “home” page…

Installing and Configuring

  1. Go to both of the above links and download the WordPress plugin .zip file from each (you don’t need the category visibility plugin if you don’t want to hide posts from the main “home” page)
  2. Log in to your WordPress dashboard and click on the Plugins link in the left administration bar, then click the Add New button at the top and point it at a plugin .zip file and click upload. Once it’s uploaded and installed, don’t forget to activate each plugin. Do both plugins if you want them…
  3. To use the Page Links To plugin you just create a new page (or edit an existing one) and right at the bottom of the WordPress page where you enter the “Page” details, you’ll see this section:

    WordPress Page Links To plugin

    You can fill in the URL to be anything you like, so in my case I’m linking to a list of all posts in the “Old-Site” category – you can link any category or specific post on your site, or link to or – it’s entirely up to you!

  4. Next, if you want to hide posts from the main page, go back to the Dashboard and look for the RYO Plugins button right at the bottom on the left (underneath Settings) and click it!

    WordPress Category Visibility Plugin

    From here you can see the list of categories along with their numeric IDs, and you can see that I’ve unticked the boxes on the Old-Site category for the Front and Feed options – which will ensure that any posts I put under the category Old-Site don’t appear on my home page or in the RSS Feed!


WordPress can be a little counter-intuitive and inflexible on its own, but because of its fantastic plugin architecture, and due to the great work of so many plugin authors, you have an incredible range of tools and techniques at your disposal to make your site work the way you want it to! So if you want to put posts about Gaming or Music or Films or anything into its own page, you can work around the architecture and get it done with just a couple of clicks. Good stuff :)

How To: Seamlessly Remove Things from an Image in GIMP

Photoshop CS5 has a content-aware fill filter which will try to seamlessly remove objects from an image – and that’s great. But GIMP has the same functionality, right now – for free. And it’s a doddle to use…

I posted about a cleverly designed glass which spells out what you’re drinking through linking dots on the glass with the liquid colour the other day, but to get that image, I needed to do a little bit of manipulation first. For this example we’re going to be using GIMP with the Resynthesizer plugin (package name: gimp-resynthesizer):

1.) Get an Image to Work With

I wanted to use a picture of the glasses, but the bar across the top was too close to them for it to be a nice shot with enough white-space around it, so the first thing I did was just stab the Print-Screen key to get a screengrab:


Remember that to fill in the missing details, you need as much as possible of what should be there – that is, a very high background to selection ratio! If you have a picture of someone’s face taking up a large section of the image and you try to remove the face – where can the plug-in get data from to know what to replace it with? It can’t! So it’ll make a guess, and it’ll fail badly. On the other hand, if you have a large swathe of grass with a football on it, and you’re removing the football, the plug-in has all the surrounding image to consider when doing the replacement!

In this case, I kept as much of the background as possible in the image while I was replacing the section I wanted removed so the plug-in could use that data for replacing content.

2.) Select the Section to Remove

Because the bar is rectangular in shape, the rectangular selection tool was the easiest option to select it – if you’ve got a more ragged section then use the lassoo selection tool, or a quick-mask or whatever to get your selection; just make sure it’s pretty tight to what you want to remove…


3.) Run the Resynthesizer Plugin

Once you’ve got your selection (i.e. what you want to remove selected), just pick Filters | Map | Resynthesizer from the GIMP menu and use the checkboxes as ticked below:



4.) Admire Your Handiwork

The Resynthesizer plugin is a little bit curious, in that running it, then undoing it, then running it again will produce different results. The first two times I ran it on the exact same selection on the exact same image ended up with some artifacts of text being dragged in, but the third time did the entire thing cleanly.

If you end up with stray artifacts from other parts of the image, you can either re-run the resynthesizing process, or just select the artifacts and re-run resynthesizer on them to remove them (remembering to keep the selections tight to what you want removed).

And voila…


That’s pretty awesome… Kudos to Paul Harrison for the plug-in – that’s some killer code – what a guy! =D

How To: Use Hotmail through Thunderbird without the WebMail Plugin

The WebMail plugin has been a trusty, appreciated boon to everyone wanting to get their hotmail/yahoo/gmail through a proper email client for years.

But due to the way providers re-jig their login mechanisms now and then, it just breaks. And breaks. Then breaks again. Not a bad word to the plugin authors – there’s nothing they can do about it, and it’s the prerogative of the email provider to setup their login and authentication mechanisms however they damn well see fit. But FFS – it’s email, you know? Can it just work, and stay working?

Following on from gmail offering POP and SMTP access for the last year or two, Hotmail now offers its own POP and SMTP servers – which means the WebMail plugin is no longer needed for Thunderbird, or personally by any webmail I use.

To modify your accounts in Thunderbird / Eudora etc – just set your hotmail accounts to the following details and you’re all set:

* Type: POP
* Server Name:
* User Name: Your FULL email address
* Port: 995 (this should be automatically set when you select SSL)
* Use secure connection: SSL
* Use secure authentication: leave unchecked

If you want to use their SMTP server select “Outgoing Server (SMTP)” and press the Add button.

* Server Name:
* Port: 587 (you could also use port 25 if your ISP doesn’t block it)
* Use name and password: Check it
* Username: Your FULL email address
* Use secure connection: TLS