Try not to write clever code

Here is a thing I wrote yesterday:

The purpose is to remove the topic and reply forms from bbPress conditionally ( that add_filter is actually used in an if statement). However, it turns out there is a little simpler way to do this. Look:

That’s it. Nothing else is required. Remove the rights to publish posts and replies and the code above is absolutely unnecessary.

The lesson I keep learning

Whenever you think you’re doing something clever, make sure you aren’t writing useless code for the sake of writing code. Write the code to achieve a result, not to increase line count in your files. Sure – both approaches above achieve the result, but if I had given it enough thought yesterday, I wouldn’t have to write this blog post today. That’s my exactly my point – give it some thought. Don’t rush to write moar code.

Get the moderator role in bbPress

I don’t work with bbPress that much, but when I do – every time I spend most of my time hunting for functions. I wish there was some sort of documentation developed over the years, but it hasn’t, and I know, I know – I haven’t helped much either. So at the very least, I decided to write down some of the common things I do with bbPress, starting with getting the moderator role.

It is really that simple:

That’s it.


Turns out there is a function called


Ooh! Caps short for capabilities! I get it. That’s cool….when you know it.


I would never, ever, ever have discovered that by guessing function names. I had to search files for the word “moderator” to eventually land on this piece of information.

Anyway. Now you know, and so do I. Caps are capabilities, and checking a moderator is as easy as current_user_can('moderate').


It’s time to drop old PHP Versions

Dear fellow developers,
I think every year Matt receives a question at WordCamp US – “When will WordPress stop supporting PHP 5.2.17”, and every year the answer is the same – “we’re still thinking about it”.

I think the main reason for not forcing a PHP Upgrade is obvious – outdated hosting providers and outdated servers are holding us back. I think it’s time to stop that. More

Named CSS Grid areas with Stylus

I recently started learning the new CSS Grids, and I love it! If you don’t know what CSS Grids are yet, you have to watch this talk by Morten Rand Hendriksen and this one by Rachel Andrew. They’re great, and I found them to be enough to start experimenting with grids.

Adding header video in custom pages

Twenty Seventeen WordPress theme has video support for headers. By default, the video header is only allowed on the front page, but there is an easy way to customize that using hooks by tapping into twentyseventeen_custom_header_args More

Calculate downloads floor

I wanted to calculate the ratio of active theme installs versus theme downloads, but the calculation often seemed very unfair, for example when a theme has been downloaded 999 times, the “active_installs” number would reflect that as 900  on the WordPress API because it lists theme and plugin count in very round numbers ( 10s, 100s, 1000s, etc. ). More

Managing z-index without loosing your hair

I’ve run into issues time and time again managing z-index. Sure, most of the time, z-index related issues are far from complex.

However, I’ve come to a passionate dislike of magic values and numbers. What is 58 or 3000 after all? It’s an arbitrary number. Wouldn’t it be a lot nicer to have layers in CSS, just like in Photoshop or Illustrator ? More

Easier way to make sure all strings are escaped in WordPress themes

We all know we should escape all the strings in a theme. WordPress theme review guidelines require it, and so does Themeforest.

After working on a theme for a longer period of time, it’s quite possible that you’ve slipped somewhere with unescaped echoes. If you’re going commando on your own – you still need to escape every little thing and be twice as careful if there are no additional set of eyes on your code. More