Monthly Archives: November 2015

How to turn plain URLs into clickable links in WordPress

The marvellous P2 Theme has an interesting feature: write out a plain link, and it magically becomes clickable without explicitly adding the a href tag.

This may not be a big deal if you’re writing posts in the visual WordPress editor rather than HTML, but for those of us who like to write in HTML, it’s just one less thing to worry about.

I was investigating this feature recently, and it turns out WordPress has a built-in function that can do this: they call it make_clickable(), and it works with URIs, FTP, Email addresses and anything starting with www. The function is really easy to use too: it only takes one parameter (a string), and returns the clickable HTML code.

Let’s see how to use it in context, using the TwentyThirteen theme.

Continue reading How to turn plain URLs into clickable links in WordPress

How to display Jetpack stats per post in WordPress

Some websites employ this or similar technologies to show how many views a single post has had. I was wondering how they did that without starting to count stats that have already been counted for several years, either by Google or by Jetpack.

Yesterday I came across this post by a WordPress dev named Topher about how to render Jetpack Stats: http://wpgr.org/2013/03/02/rendering-jetpack-stats/

I decided to test this in TwentyThirteen, and it works a treat – here’s how to do it. The principle will of course work with any theme.

Continue reading How to display Jetpack stats per post in WordPress

Zen Dash – Version 1.5 released

banner-1544x500

I’ve just released an update to my Zen Dash plugin. Besides adding funky zen-bamboo artwork to the WordPress.org page, I’ve made the following minor amendments:

  • the option to hide the Jetpack menu now only shows up when Jetpack is activated, otherwise it’s hidden
  • I’ve verified compatibility with the immanent release of WordPress 4.4
  • added funky zen-artwork (see above, courtesy of GraphicStock)

I’ve you’re one of the 70+ active lucky users, you can upgrade the plugin from within WordPress as usual, or you can download a copy from GitHub or the WordPress.org plugin repository:

  • https://github.com/versluis/Zen-Dash
  • https://wordpress.org/plugins/zen-dash/

Questions, suggestions, translations and pull requests are always welcome!

What is Zen Dash again?

Zen Dash is a magical plugin that lets you get rid of the myriad of options in the WordPress admin area. I’ve created it because sometimes less is indeed more, and new users can get overwhelmed by the sheer volume of menu items, dashboard widgets and upgrade notifications.

While it is possible to let casual users have privileges less than administrators (and therefore see less items), I found this ineffective. With Zen Dash you simply flick a switch and make things disappear that you don’t want to see everyday. You can just as easily bring them back if you need them.

You can read more about Zen Dash in my release post, which even includes a video on how to use the plugin.

How to see which users are logged in on OS X and Linux

There are two funky commands that can help us see who’s currently logged in, and what operations were performed last. Those two commands are who and last.

Let me show you how to use them.

The who command

Type who at the command prompt and you’ll see a list of currently logged-in users:

This system has two users logged in: versluis, via TTY, and root via PTS. We also get to see which IP addresses these users are logged in from (:0 is localhost).

On this note, TTY is the local text based terminal at the machine, while PTS is a pseudo-terminal. This is most likely an SSH session or similar, anything that’s happening remotely.

who can also show us who we are, in case you’re ever logged in on a system and don’t know which user you are:

You can also concatenate who am i into whoami.

The last command

The last command can take a moment to execute and will show a list similar to this:

You can see who has logged in to the system recently, from which IP address, and when each session started and finished. You can also see when the system was last restarted (and in Linux, which Kernel was used to do so).

The last line (on Linux, beginning with wtmp) shows since when the command was able to display results. last and who both read a file called wtmp (in /var/log/wtmp), which logs all login attempts over time.

last accepts several filtering options too. For example, to query when a particular user has logged on and off, type last followed by the username:

Or if you’re only interested in restarts:

On OS X the output is somewhat more limited due to the absence of kernels, but it works just the same. For more information on each command, checkout the man pages with man last and man who.

  • http://osxdaily.com/2014/03/25/see-users-who-connected-to-mac/
  • http://unix.stackexchange.com/questions/21280/difference-between-pts-and-tty
  • http://www.linuxnix.com/read-view-utmp-wtmp-btmp-file-linuxunix/

How to burn an ISO image with OS X El Capitan

El-Capitan

Sometimes it’s important that things change for no apparent reason. You know, the way they move things around in supermarkets just to drive you crazy.

If you’ve tried burning an ISO image to disk in El Capitan recently, you know what I’m talking about:

because the option to burn an ISO has been removed from Disk Utility.

Yeah, I get it: plastic disks are out, no one should be using them anymore, there are no more Macs with SuperDrives in production as of 2016, so it’s time to remove this option from the built-in utility that had it for the last ten years. Think different. It keeps you sharp.

Lucky for us plastic spinners, there are two (not so obvious) solutions: the command line and the good old Finder that can still burn disks for us. Here’s how to do it.

Using Finder

Apparently Finder always had the option to burn a disk image. I never knew that! All we have to do is:

  • insert a new blank disk
  • navigate to our ISO image
  • select it (single-click)
  • head over to File – Burn Disk Image “xxx” to Disk

Screen Shot 2015-11-16 at 18.00.40

Using the Command Line

It’s for hackers really, but it’s very simple:

  • insert a blank disk
  • open Utilities – Terminal
  • navigate to the folder that holds your ISO image
  • issue the following command:

El Capitan. There’s just more to love with every click.

  • http://forums.macrumors.com/threads/where-is-the-burn-option-in-the-new-disk-utility.1891792/
  • https://discussions.apple.com/thread/7266979?start=0&tstart=0

Child Theme Wizard – Version 1.1 released

wizard

I’ve released a new version of my popular Child Theme Wizard plugin today. Everything remains the same, except for one thing: the parent theme is no longer loaded via CSS, it’s now being loaded via PHP. Let me explain why.

When I wrote this little tool in 2014, the best practice to create a child theme was to load the parent’s style sheet via CSS. This was done with an @import statement, like this:

While this approach works just fine, this is no longer regarded as the best approach to the puzzle. That’s because the parent theme’s full path is hard coded into your child theme, and should the parent theme ever change it’s folder name, your child theme would stop working.

There’s a better way to get the same thing done by loading the parent style sheet via PHP in the functions.php file. Here’s how it’s done:

So that’s what the update does: switch from the older way of loading the parent theme to the new one. There. Keeping up with the times and all 🙂

Download Child Theme Wizard

You can download the plugin from the official WordPress Plugin repository, or take a look at the source code on GitHub. Enjoy!

  • https://wordpress.org/plugins/child-theme-wizard/
  • https://github.com/versluis/Child-Theme-Wizard

How to open WordPress Custom Menu links in a new tab

My wife is currently attending a blogging course at The Daily Post’s Blogging University.

One thing that was bugging her (and me) was that Custom Links in the WordPress Menu do not open in new browser tabs. The default behaviour is to open links in the same tab, which is useful for internal site navigation.

I explained to her that in plain HTML, we would just use a target such as “_blank” in our link tag, but I didn’t see how to apply my old fashioned knowledge to something so sophisticated and elegant as the WordPress Menu Manager.

Thanks to the wonderful Kathryn Presner, my wife just told me the solution to this puzzle: enable the link targets in your WordPress Screen Options!

Screen Options is this little menu at the top left in the WordPress admin interface we often forget to look at. Its content changes dynamically for every part of WordPress, and it includes a wonderful help system too – in case we ever get stuck.

So how do we do this new tab thing?

Head over to Appearance – Menus and select Screen Options at the top right. It will open a menu similar to this:

Link-Target

See the tick box that reads Link Target? Click it and close the menu again.

Now open one of your links (or create a new one) and find another magic tick box labelled Open link in a new window/tab.

Screen Shot 2015-11-10 at 12.04.21

Tick it and save your menu. Head over to the front page and see your link open in a new tab from now on. #result

Thanks to Julia and Kathryn for bringing this to my attention 😉

  • http://travellingbanana.com
  • http://kpresner.com

How to remove an IP from the CBL (Composite Blocking List)

Today I was introduced to something called the CBL, or the Composite Blocking List. This is one of several Spamhaus projects that’s there to make sure IP’s are blacklisted when they’re sending spam.

You can check if your IP’s are OK at http://www.spamhaus.org/lookup/

The CBL is a separate website in which you can also lookup IPs. Spamhaus will tell you if that’s the case and direct you to the CBL here: http://www.abuseat.org/lookup.cgi

Even though my IP was otherwise fine, it was listed in the CBL, and Yahoo kindly made me aware of this as part of an error message I’ve received when trying to send an email. If ever there is an email problem in CentOS, the first place to look is /var/log/maillog. Here’s Yahoo’s very helpful explanation: https://help.yahoo.com/kb/postmaster/SLN5070.html

Turns out that the hostname was not setup yet, so the box would respond as localhost.localdomain. That’s a big fat no-no as far as the CBL people are concerned. Here’s CBL’s explanation:

This IP address is HELO’ing as “localhost.localdomain” which violates the relevant standards (specifically: RFC5321).

The CBL does not list for RFC violations per-se. This _particular_ behaviour, however, correlates strongly to spambot infections. In other words, out of thousands upon thousands of IP addresses HELO’ing this way, all but a handful are infected and spewing junk. Even if it isn’t an infection, it’s a misconfiguration that should be fixed, because many spam filtering mechanisms operate with the same rules, and it’s best to fix it regardless of whether the CBL notices it or not.

Continue reading How to remove an IP from the CBL (Composite Blocking List)

How to set the hostname on CentOS 7

CentOS 7 has a nice command called hostnamectl. With it we can display the current hostname, and set any of the three types of hostname:

  • static hostname (something like example.com)
  • transient hostname (anything you like, assigned when using DHCP)
  • pretty hostname (something like Jay’s MacBook Pro)

By default, a CentOS installation comes back with localhost.localdomain – but that’s not meaningful if you see lots of localhosts on the same network.

If the IP of the box does not change, we can set the static hostname like this:

No feedback means good news. Likewise, we can set a hostname if were using DHCP to get an IP address, even though it may change every time we connect. To make sure we retain the same name no matter what IP we get, let’s set the transient hostname like so:

Note that we can’t use spaces or special characters with static or transient hostnames as far as I know.

Lucky for us there’s also the pretty hostname, which does support special characters. It doesn’t usually appear anywhere on the command line, but GUIs like to display the pretty name of a machine when available:

There’s no need to restart anything, the changes are in effect as soon as we hit return after either command.

To see the current hostnames, we can use the status switch:

Thanks to Vivek Gite for this wonderful explanation!

  • http://www.cyberciti.biz/faq/rhel-redhat-centos-7-change-hostname-command/

How to change fonts in TwentyFifteen by Automattic

TwentyFifteen uses the Noto Serif font. It looks swish and comes with an Apache license, and it can be pulled from Google Fonts too. It’s a fine font indeed – but individuals that we are, it may not be for everybody.

It’s easy to change it to something else though, and in this article I’ll show you how.

By default, TwentyFifteen and Noto Serif looks like this:

Screen Shot 2015-11-05 at 11.58.15

If we want to change this to something else, we must first import said font into our style sheet, and then declare it for a couple of classes. In this example I’m going to use Lato, another fabulous font that’s featured in the TwentyFourteen theme:

Now TwentyFifteen will look like this:

Screen Shot 2015-11-05 at 11.59.27

If for some reason Lato cannot be downloaded, the browser will try to display text in the next font we declared (Georgia – and if that fails, it’ll try Times New Roman… you get the picture).