Monthly Archives: April 2014

How to find out which user ID belongs to which domain in Plesk

Plesk-LogoThe other day I found that one of the domains on a busy server was sending unsolicited spam mail thousands of times a day. It happens: the nature of open source scripts is that they will get hacked if they’re not updated regularly.

The clue was a full-up mail queue and Gmail no longer accepting mails from the IP in question.

When I examined one of the spam mails I found a line like this:

Good to know the spam was sent from a PHP script… but from which domain? All we have here is the user ID of the domain in question (10040) but that doesn’t mean much to the average human administrator.

Here’s how to translate that Plesk User ID into the domain it’s coming from:

Replace the user ID with your own, and the result is the user name, as well as the domain path in question.

Creating a Searchable Table View in iOS

Xcode_iconIn this 6-part series I’ll show you how to create a searchable UITableView in an iOS App. We’ll start with a standard single view application template in Xcode, create a table view with dummy data, and finally make it searchable.

This course demonstrates how to do this with Xcode 5.1 and iOS 7.1. We’ll also make the app compatible to for in iOS 6.

These are the first two parts which are available for free. The rest of the course is only viewable by members of my iOS Dev Diary at

You can get the source code and follow along here:



How to style captions in Twentythirteen

I love the Twentythirteen theme – except for the captions that appear underneath images. If you’ve ever seen them they look so out of place as if someone forgot to style them altogether. Here’s what they look like by default:

Screen Shot 2014-04-14 at 10.47.48

Notice how the captions are actually larger than the post text. I wanted to drop this size a bit, but at the same time integrate the text better with images I post over at, adding a bit of padding, some rounded corners and perhaps tint the background colour ever so slightly.

Here’s what I came up with:

Screen Shot 2014-04-14 at 10.47.08

And here’s how I did it:

Add this to your theme’s style.css file or override your stylesheet with an appropriate option. Here’s what this code does:

First we’ll reduce the 18 point caption size and bring it in line with the rest of the post text (1em). Then we’ll tint the background colour to a very light hint of grey. We’ll also add a bit of padding around all edges of the text, it looked a bit cramped in there before.

The second larger block is creating rounded corners at the bottom of the caption, but not at the top so it looks like an attachment. There’s a remarkable tool that lets you visually set this and return some code at – go check it out and have a play.

Moving WordPress with Plesk 11.5

Plesk-LogoIn this screencast I will show you how to move a WordPress website from one Plesk server to another without the Migration Manager.

We’ll extract the files on the source server and export the database. Then we’ll create a new WordPress instance on the destination server and upload the files and import the database. All that remains is to point the domain to the new IP.

I’m doing this without the Migration Manager because the source server is an Amazon EC2 instance and does not allow root access with a password (which the Migration Manager needs – and Plesk doesn’t yet have a feature that allows me to use a keyfile instead).

The workflow is entirely web-based and you won’t need anything other than your favourite web browser.



How to remove buttons from Distraction Free Writing Mode (Full Screen Editor) in WordPress

wordpress-iconNow that we’ve learnt how to add buttons to the Full Screen Writing Mode in WordPress, let’s see how we can remove them too.

Just in case Zen Mode isn’t zen enough for you.

Imagine that you have never in your life blockquoted anything, and rather not start anytime soon, there’s how to remove the block quote button.

Just like before, we’re taking an array of buttons and remove the objects we don’t want. Since they were addressed with an index title (blockquote in our case), you must unset them in the same way. Once gone we return the array, and WordPress does not display said button anymore.

To figure out what that index text is, refer to this table and try to figure it out:

Kudos to Renji from Sumtips for his helpful article on this topic:

How to add buttons to Distraction Free Writing Mode (Full Screen Editor) in WordPress

wordpress-iconI really like the Distraction Free Writing Mode that WordPress offers. I mean the one you can access when you write a new post, then hit that big X and go into full screen mode.

It’s Zen at large.

But just in case there’s a single function you’d like to see up there as a button, because you’re using it all the time, there is a way to do it.

Bear with me. These are the buttons I mean:

Default Buttons in Full Screen Mode
Default Buttons in Full Screen Mode

Just in case you didn’t know: there are A LOT OF OTHER FUNCTIONS you get in this mode, much of which are hidden by the power of keyboard shortcuts. See that little question mark up there? Press it and see what else you can access at the speed of thought:


Seriously, this is dynamite stuff! Chances are that if you’re looking for something, it’s already there – and at the ready with a keystroke.

Anyway, let’s get back to that toolbar and see how we can tweak it.

Adding Buttons in DFW Mode

All that beautiful functionality is provided by an open source library called TinyMCE, a JavaScript WYSIWYG editor. That’s the tool that lets you see a word become bold while you’re typing it in your web browser. It’s powerful stuff, and WordPress relies on it a great deal.

So really, all those buttons and their respective functionality is not coming from WordPress. Here’s a list of other functions that could potentially be up there as buttons:

In this example I’m adding the three justifications to the editor: left, centre and right. Add this code to your theme’s functions.php file, or if you’re writing a plugin add it to your main plugin file:

I know it looks a lot, but it’s relatively simple. Let’s go through this:

  1. First we’re adding a function that gets called via the wp_fullscreen_buttons action. As you may imagine, this is called when the entire toolbar is displayed in fullscreen mode.
  2. Our function takes a parameter ($buttons), which is an array of button objects that will show up there. We take it and add to the array with our own buttons.
  3. The first item we’re adding to the array is a separator, just so that our own buttons appear with a little distance. Take it out of you don’t like it.
  4. Next up are three button objects. We’ll talk about those more in a moment
  5. Finally we return the amended array and WordPress can display it.

Each Button is made up of three ingredients: a Title (Left, Right, Center) which is displayed on hover. It also needs a TinyMCE function, which is the JavaScript onClick function that will make the selected text do what it does (i.e. justify it to the right). You’ll find the possible values in the link I mentioned earlier. And there’s a boolean TRUE/FALSE type value. This determines if the button shows up in the visual editor only, or if it also shows in the code editor.

The result looks like this:


Not only does it look swish, it also works out of the box! Is that cool or what?

Thanks to the following links for helping me figure this out:

How to use FTP from the Linux Command Line

folder_downloadsYou can use the ftp command to talk to an FTP server from the Linux Command Line. Type ftp to see if the tool is installed. If you get a “command not found” message then go ahead and type yum install ftp to make it available on your system.

Using it is very straightforward – but I keep forgetting how because I only do it once in a blue moon. So here’s a handy cheat sheet:

Logging in to your FTP Server

Assuming our site is, simply type this:

This will connect you, but the system wants to know the username and password at the prompt. Provide those and if your login was successful you’ll see something like this:

Note that you’re now at the FTP command line and no longer on the Linux command line (you can tell by the ftp> in front of the cursor). Therefore only FTP commands are now accepted, until you type “exit” or “bye” to go back to Linux.

To see a list of available commands type help and you’ll see a list much like this:

No need to panic: The good news is that we don’t really use a plethora of new commands, and some (like ls and mkdir) are working the same way, just the output may look a bit different.

Let’s go through a few common scenarios now: listing and creating directories, uploading, downloading, and deleting files. Classic CRUD – FTP Style.

If you ever need to come out of a running command, CMD-D (or CTRL-D) will do the trick.

Listing and Switching Directories

Your usual Linux favourites will work fine to list and switch directories:

ls (list directory, same as dir)
cd (change into directory, for example “cd mydir”)
cd .. (move one directory up in the tree)

Excellent: nothing new to learn here. Result!

Creating and Deleting Directories

Another nice thing is that mkdir is still working to create a directory. Here’s how we create a directory called test:

Likewise, rmdir does a good job at deleting (empty) directories:

To delete a directory that contains files you must first remove all files (see below under Deleting Files) and then use this command.

Downloading Files

To download a single file we can use the get command (or recv if you can remember it better). You must type out the entire file name for this to work, and you won’t get a progress report while your file downloads:

This will save testfile.tar in the Linux directory that you were before you initiated the FTP session.

To save files in a directory other than the current one, I’m afraid you’re going to have to log out, cd into the directory you want those files to go, then re-connect. I know, ultra lame – but if there is another way then it’s kept so secret that no Google search will ever unveil it.

Sadly wildcards are no working in this operation, so you’ll always have to type out the exact file name. Lucky for us you CAN use wildcards to download multiple files with mget, like this:

Now all files starting with “test” are downloaded and you’ll be prompted one by one. This will work for single files too and saves you having to type out cryptic long names. Human 1 – FTP 0. Ha!

Uploading Files

put and mput work just like get, but they upload local files to the current FTP directory. You can specify a local Linux path when doing this, but put and mput expect a local path to also exist on the FTP remote (and fail if they don’t). Read: messy. There probably is a way to deal with this, but life’s just too short.

Just like get, put also needs the whole file name and cannot deal with wildcards – but mput does:

Deleting Files

There’s also a delete and mdelete command which – you guessed it – removes unwanted files from the server. Same as before: no wildcards on delete, but they work fine on mdelete:


FTP transfers all files and passwords “in the clear” and does not work with encryption. Checkout the sftp command which will do all of this and more while using encryption on all transfers.

Note that there is a difference between SFTP and FTPS: the latter (FTPS) is the same as FTP but with encryption added to it. SFTP isn’t really FTP at all, it’s an SSH connection that works much like rsync and scp, and uses similar syntax.

Further Reading

How to use P2 (screencast)

In this video I will show you how to get the most out of the revolutionary P2 WordPress theme. It allows front-page posting and is an ideal solution for jotting down notes or communicating with others.

I will explain how to create lists with simple shortcuts, add links, how to embed YouTube videos by simply pasting the URL and some simple customisation options.

Catch this episode on my WP Guru Podcast:

How to add your own widget to the WordPress Dashboard

wordpress-iconNow that we’ve removed a few widgets, perhaps it’s time we add our own simple info box to the WordPress Dashboard.

For example, we could provide a direct link to our support services. It’s handy for clients to know help is just a click away.

Here’s how to add a simple box like that:

Add this code to your theme’s functions.php file. Note that if you (or your client) activates a different theme the widget will disappear.

Here’s what the code does: first we create a function that simply writes out the text that’s displayed inside our widget (contact_help). Next in register_widgets we register our widget in the WordPress Dashboard. This won’t do anything yet, as the register_widgets function is not called. We do that in the next step when we hook it into the wp_dashboard_setup action.

Remember this is sample code – you probably want to prefix your own functions with something unique.

You can find out more in the WordPress Widget API.

Best Practices to Extend Plesk using the SDK

Apple_Podcast_logoThis is a presentation Andrey Kugaevskiy and I gave at Parallels Summit 2014 in New Orleans. We’ll show you what the SDK is and what it can do for you.

If you would like to change the way Plesk behaves, or you want to integrate your application or service deep into the Plesk interface, then this session is for you. We’ll discuss the best practices for creating extensions that can be used to differentiate your services from everyone else or to promote your service to all Plesk instances online today.

Links from the video:

You can also check out my previous article on how to create an Extension in Plesk.