How to use Bedrock with Pantheon

Disclaimer: I wasn’t paid by Pantheon or CircleCI to write this. I am, however, part of the Pantheon heroes program. I just like Bedrock, CircleCI and Pantheon a lot so I wanted to write about them.

Working on large projects with WordPress is often a challenging endeavour. You have a lot of plugins to manage as well as the custom code that you’ve written for your client. All this code often exists in a single git repository. This makes the whole thing complicated to maintain.

Lucky for us, there’s Bedrock. Bedrock is a custom WordPress project structure based on the Twelve-Factor App methodology. Using such a project structure lets you work using modern web development methodologies.

Without a doubt, the foundation of modern web development is the dependency manager. For example, it’s impossible to do modern JavaScript without using npm. This is the dependency management tool used by the JavaScript ecosystem.

In PHP, that dependency management tool is Composer. While WordPress has no current plans to support Composer, Bedrock has it as its central feature. This is great for WordPress developers who want to use modern web development methodologies.

Now, the problem with using a project structure like Bedrock is that a lot of hosts don’t have support for Composer. There’s a guide on how to use Bedrock with Trellis on Kinsta. But besides that, there isn’t much out there to help you setup Bedrock with a host. Since I have experience with the Pantheon platform, I figured I’d write about how to get Bedrock on it.

Continue reading How to use Bedrock with Pantheon

Improving a system: Different types of WordPress admin pages

In a previous article, we saw how to design a system for WordPress admin pages. The article was an excellent resource for anyone looking for a system to solve that specific type of problem. But it was only a starting point. (That said, you should take the time to read it before reading this article.)

All that we did was convert code from another article into the WordPress admin page system. We didn’t look at any other use cases besides the ones covered in that article already. But the reality is that there are a lot of them.

For example, the article only looked at how to add submenu pages. But there are other types of admin pages besides that one. The admin page system should be able to handle them all.

This is one of several advanced use cases that you might encounter with the WordPress admin page system. That’s why the system as we saw it so far is a great place to start. But handing these uses cases like different types of admin pages might be necessary depending on the kind of project that you’re working on.

Continue reading Improving a system: Different types of WordPress admin pages

How I marketed and published a niche WordPress book

A few weeks ago, I released my first book “Discover object-oriented programming using WordPress“. The book had $11,040 in sales during its launch week. This went above and beyond the expectations that I had for how well the book would do. (I would’ve been ecstatic if it’d made even half of that.)

But before I go any further, I want to do a small preface. What I am going to talk about isn’t anything that I really figured out myself. All that I did was read a lot of what others had done and then tried to do it myself in my own authentic way. (That last part is super important though!)

I’m especially thankful to Nathan Barry and his book “Authority“. (Sadly, he doesn’t sell just the book anymore.) I’m also super grateful to Paul Jarvis who’s inspired me to have my own quirky voice through his newsletter. He and Justin Jackson (not the basketball player!) taught me that marketing didn’t have to be this slimy thing if you were authentic about it. (Justin has a course on marketing for developers.)

That’s also why I’m taking the time to write down all my thoughts about this experience while everything is still fresh. (Much like my year in reviews.) I was only successful because other people shared how they approached marketing and self-publishing a book. I want to do the same by sharing as much information as I can for anyone interested in marketing and publishing their own book.

Continue reading How I marketed and published a niche WordPress book

How to approach object-oriented programming with WordPress

I gave a talk on object-oriented programming with WordPress at WordCamp Miami 2019. This is the companion article that I wrote for it. If you’re just looking for the slides, click here.

You’re a WordPress developer who wants to use object-oriented programming in their next project. You’re already familiar with concepts like inheritance. The issue is that you’re not sure how to apply those concepts to design classes that feel useful.

This isn’t something to feel ashamed about! In fact, it’s a common problem when trying to use object-oriented programming with WordPress. It’s hard to know how to design classes that work well with WordPress. (That’s why this site has so many articles dedicated to that topic.)

But why is this so hard to do? Well, there are a few things going on. And together they create this situation that makes using object-oriented programming with WordPress complicated.

Continue reading How to approach object-oriented programming with WordPress

Designing a system: WordPress admin pages

In a previous article, we saw how to design a class to represent a WordPress admin page. The article was an excellent resource for anyone looking to design a class to solve that specific type of problem. But it was only a starting point.

For example, we used the settings API to handle forms. But the settings API doesn’t quite do the job for every use cases. For those other cases, you’re going to need to manage the submission of a form yourself.

But to handle these different use cases, we’re going to need a more solid foundation. So we’re going to take the work that we did to design our admin page class, and we’re going to take it one step further. We’re going to design a whole system for WordPress admin pages.

Continue reading Designing a system: WordPress admin pages

2018 in review: A challenging year

We’re almost at the end of 2018 and, like everyone else, I l do a review of my year. It’s been a few years that I do it now. My first review was for 2012-2015. I’ve done one for 2016 and 2017 since then.

As usual, I’d like to open up by talking about why I do these years in review. If this is the first time that you read one of them, you should know that I write them mostly for myself. I find it useful to have a historical record of what I was thinking during the year. So it’s important to write it while it’s still relatively fresh.

I also do this so that I can be transparent with you. I live a pretty non-standard life. I don’t want people to think that it’s just all sunshine and rainbows. It’s useful to see that there are always tradeoffs and that it’s not for everyone.

And finally, it’s a way for me to also keep track of my progress. Progress towards what? As I’ll talk about later, the answer to this question isn’t as clear to me as it was the previous years.

But again, that’s the goal of doing these reviews. I love documentaries where you can see how someone’s experiences shaped their path through life. It’s always my hope that these reviews also help you reflect on your own as well.

Continue reading 2018 in review: A challenging year

Introduction to WordPress acceptance testing

As a WordPress developer, the topic of testing isn’t something that we hear about that often. And, if we do hear about it, it’s more often than not just one specific type of testing: unit testing. (That’s even the one that I’ve thought first!) In fact, it’s not uncommon to associate testing with unit testing because of this.

But software testing is an enormous field. There are a lot of different types of testing. While they might not all be as useful as unit testing, they still all serve a specific purpose.

That said, there are other types of testing that are as useful (or almost as useful!) as unit testing. Acceptance testing is one of them. It’s especially useful if you’re a plugin or theme developer.

Continue reading Introduction to WordPress acceptance testing

Introduction to the command-line interface

Someone once asked me, “What’s the thing that used to scare you the most as a developer?” And, without even hesitating, I answered, “Linux and the command-line interface.” We both laughed at the answer.

That’s because I’m hardly the only one to think this. There are few things early in your career as a developer that you’ll dread touching more than a command-line interface. And, even later in your career, you might still try to avoid it at all costs.

That’s why there are so many developer tools that are nothing more than abstractions over the command-line. We’d rather pay and use these tools than have to deal with a command-line interface. This isn’t a bad thing per say either.

If you get the job done faster with those tools and are more comfortable with them, you should use them. But, that doesn’t mean that you shouldn’t be comfortable with a command-line interface either. There are situations (like when you’re connecting to a server) where you won’t have access to your favourite tool, but you’ll have access to a command-line interface.

Continue reading Introduction to the command-line interface

How do you start unit testing existing WordPress code?

A lot of us have heard about unit testing. Out of all the different types of testing (and there are a few!), it’s probably the better-known one. It’s also the most common form of testing used with WordPress.

In the past, we’ve looked at how unit testing works with WordPress. That said, knowing how unit testing works is one thing. This knowledge doesn’t necessarily make it any easier to get started with it in your projects.

Some of us work with existing code bases. It could be a plugin, a theme or a whole WordPress site. How do you take the fundamentals of unit testing and apply them in that context?

This is a tricky question to answer, but it’s also an important one. Most of us will not start using unit testing in a vacuum. We’re going to start using it with one of those existing code bases.

This brings with it its own unique sets of challenges. It also means that you need to have a strategy for them. This will help make this transition smoother for you.

Continue reading How do you start unit testing existing WordPress code?

Continuous deployment to the WordPress directory with CircleCI

Note: This article focuses on how to continuously deploy a plugin using CircleCI. But you can also use everything discussed here with a theme as well.

As developers, we all have our preferred tools and distinct way of working. That’s why it’s not uncommon for us to write about it or create scripts to set up our work computers. But the one tool that most of us tend to agree on is using git for version control.

That said, if you’ve ever had a plugin or theme on the WordPress directory, you know that it doesn’t use git. It uses subversion. That’s a problem for a lot of us because we don’t want to have to deal with both.

While there are a lot of resources out there to deal with this problem, it also presents us with an opportunity. We can use this problem to build a continuous deployment workflow for the WordPress directory. This will allow us to not worry about this aspect of WordPress plugin development anymore.

Continue reading Continuous deployment to the WordPress directory with CircleCI