Tag Archive for 'wordpress'

Page 2 of 4

Fix users with no role – data migration plugin

So you’ve migrated a bunch of users over from another system and then, horror, you discover that they don’t have roles in WordPress. The WP Users admin screen doesn’t cope with this issue (why should it), so the only option would be to go through and manually select the roles for each user with no role… fine, right? Except I just migrated 8,000 ish users and there’s no way my meta carpels will take that abuse. This plugin finds any users on your system with no role and gives them the role of ‘subscriber’, it does this in batches of 1,000 users per page load and once it has finished it replaces your entire blog with a message saying it’s finished… so don’t leave it running unattended kids, eh? (I know that’s rude, but coding “echo ‘blah; exit;’ is SO much quicker and it’s only a dirty data migration tool.

You can download the source here: Fix Users with No Role – Data Migration tool as WordPress plugin

Editing many posts at once in WordPress

Need to edit many posts at once in WordPress? Is the standard limit of 15 posts on the Posts Edit screen just not enough for you? Well, there is a hack you might be interested in. This involves editing the core WP files, so is not recommended as a permanent solution or for production sites… it works for me, but it might kill your cat and devastate the area around your home. You have been warned. Continue reading ‘Editing many posts at once in WordPress’

Page load hooks in the WordPress admin area

There are a number of really handy hooks, each of which are specific to a page in the WordPress admin area. You can use these action hooks to enqueue scripts on particular pages, to process form requests, etc, etc.

Despite these hooks being so handy, and despite using them a great deal, every time I want to use one I have to dig through the code to try and work out how they work and what they’re called… so for my own benefit, here’s what I think is a complete list: Continue reading ‘Page load hooks in the WordPress admin area’

Custom taxonomies in WordPress

I’ve spent quite a bit of time over the last week getting to grips with custom taxonomies in WordPress, and I’m really pleased with what I’ve found. A taxonomy is a classification, and WordPress already has two taxonomies buil in: tags and categories. Categories lean towards a more formal taxonomy, which you might setup with forethought and some planning, whereas tags lean more towards a more casual folksonomy, which you might construct “on the wing” in a less formal and more ad hoc style. WordPress uses a generic taxonomy setup to create the tag and category taxonomies, and you can use the same functions to create your own taxonomies.

I’m going to take you through the process of creating a basic taxonomy, creating some terms in it and relating those terms to some posts. There’s some demonstration code in the form of a proof of concept WordPress plugin, which you may find helpful.

Continue reading ‘Custom taxonomies in WordPress’

Experiments with WP Cron

I’ve got a couple of projects coming up which are going to require scheduling tasks in WordPress either to go off and get stuff, or to check whether posts displayed are still accurate, etc. Luckily, WordPress has a pseudo-Cron implementation which I plan to use to .

Let’s take a step back first and remember what Cron is: Cron is the scheduling service for UNIX-like systems which can set tasks occur at specific times or to recur at specific intervals. So you can use Cron to tell your system to do something at 12:47 on the 14th April, 2009 or to perform a task at 12 minutes past midnight every Monday, it’s a very useful service.

WordPress is not naturally a proactive beast, so unfortunately your WP site will not spend it’s day checking the time and seeing if it’s got anything to do. This is where the pseudo come in, with the WordPress pseudo-Cron we’re relying on a constant flow of visitors to trigger WordPress into checking for scheduled tasks. The upshot of this is that we cannot rely on WordPress to precisely schedule events, but the system is good enough for most things. (We can always increase the frequency of visitors artificially by targetting the site with five minute checks by Pingdom or similar, with the added benefit that the site is now monitored for downtime.)

So let’s get into the details of how all this stuff works, shall we? Continue reading ‘Experiments with WP Cron’

WordPress and basic authentication, problems with WP Cron and file uploads

I have a Google ego search on my name, so I can keep track of what the Internets is saying about me behind my back. The other day the ego search summary email arrived and included was one of my development sites. Which was annoying because I don’t want people browsing around my development, it might be broken or confuse people by looking like a live site (but not contain proper content). So I did what I should have done from the beginning and enabled Basic Authentication on my development sites. (Basic Authentication protection provides those “popup passwords” you see around the place where a little, usually grey, dialog pops up asking for a username and password before you can go any further.)

Basic Authentication is as old as the hills in internet terms, and while it’s not the most sophisticated protection it’s a reliable and simple way to prevent any old Tom, Dick or Harriet poking around where you don’t want them. I’ve used it before for client sites which are hosted on the open internet, but where we only want a small selection of people to see it… add Basic Authentication and bosh, job done. Continue reading ‘WordPress and basic authentication, problems with WP Cron and file uploads’

Adding GET params to a URL in WordPress with add_query_arg

I am finding myself using this function a lot now, and I constantly forget the function name:

add_query_arg();

It allows you to pass in some additional parameters, and a URL, and receive back the URL with the query string params added. For example:

$some_url = "http://simonwheatley.co.uk/?stuff=whatever";
$params = array( 'wp_siteurl' => "http://www.example.com" );
$some_url = add_query_arg( $params, $some_url );

This will result in a url something like this:

http://simonwheatley.co.uk/?stuff=whatever&wp_siteurl=http%3A%2F%2Fwww.example.com

Pretty cool, huh? So now you don’t need to worry about what parameters are already in the URL, you can just hand all that hassle to add_query_arg.

Update: See also remove_query_arg.

Plugins in the DFID site

I’m chuffed to see Puffbox and the Department for International Development (DFID) launch the new DFID group blog. Naturally it’s always nice to see our government open up to us, the people of Britain, but I’m particularly gratified that they’re using some of my WordPress plugins to do it.

Continue reading ‘Plugins in the DFID site’

The first WordCamp UK was a cracker

I spent the weekend in the company of 50 or so other WordPress users, designers, developers, the odd Aussie Automattician, and a WordPress lead developer at the first WordCamp UK. It was great to meet a such a varied and interesting group of bloggers and blog makers, many of whom I’m going to have to wait until next year to properly talk to… a weekend is just too short!

Continue reading ‘The first WordCamp UK was a cracker’

WordPress plugin development presentation

My presentation for WordCamp UK on WordPress Plugin Development (although I will update this soon with better slide notes): PDF version.