How do I hire a WordPress developer

A WordPress developer reveals his tricks: Part 1

introduction


Who am I?

My name is Michael Damoiseau. I am currently working as a PHP developer at buzzwoo, a digital agency with offices in Stuttgart, Munich (Germany) and Chiang Mai (Thailand). Here in Chiang Mai, I'm the backend team leader, mainly working with Laravel and WordPress frameworks.
What is this about?

Of course, not all of the tools I'll cover in the course of this series of articles are relevant to all types of projects. It is entirely up to the developer's discretion which tools make sense in which situations (for example, do you really need unit tests when using a purchased theme?).

So that things don't get too confusing and difficult to digest, I have divided my content into several, smaller articles:

Part I: What is WordPress and how to use WP-CLI to improve flow (this article)

Part II: Checking WordPress Plugins and Themes with the WordPress Unit Testing (coming soon)

Part III: Continuous Integration and WordPress Development (Coming Soon)

Part IV: How We Improved Our Tools (Coming Soon)

What is WordPress?
WordPress is a PHP and MySQL based CMS framework. It was developed by Matt Mullenweg and Mike Little and published in May 2003 (15 years ago !!).

WordPress itself was a spin-off from the CMS b2 / cafelog. You can imagine how old some parts of the code are!

If you hear negative things about WordPress, the complaints are usually that WordPress is a pure blogging platform that cannot be scaled and is only suitable for small websites and / or blogs.

It is of course true that WordPress was initially intended as a blogging platform and is really useful for managing a blog website. However, it must also be said that since version 3, which was published in June 2010, it has been possible to create your own content types (so-called custom post types).

Since then it's no longer a problem with WordPress to handle a lot more different types of content - in fact, almost everything you could ever need; Ranging from e-commerce platforms that have to store thousands of products, to multi-page platforms that can host hundreds of different websites under one instance.

The latter can be best illustrated with a simple example: The platform on which all WordPress plugins are hosted runs itself on WordPress.

As a conclusion, we can say that WordPress is a powerful platform that can be used for a wide variety of projects. Of course, I don't mean to say that WordPress is the perfect solution for every imaginable project. However, WordPress can be very helpful in many situations - so you shouldn't be unsettled by the many one-sided statements that say that WordPress is completely out of date or annoying for any other random reason.
As always, it is entirely up to the developer's discretion to identify the best tools for the job - and hopefully after reading my articles, more people will see WordPress as a viable option for future projects.

The tools and the development flow

So, we remember: WordPress is a (good) platform that can handle a wide variety of requirements ... That's great, but you can do so much more with WordPress!

Now I have two questions ... By the way, most developers I know would answer both questions with “no”. I would suggest to all people whose answers would now also be “No” to read this article to the end - in the end, one or the other will be surprised. And a few interesting facts about WordPress will most likely be able to take with them.

Let's go:

1. Did you know that there is a command line tool called WP-CLI with which you can do almost anything within WordPress using the command line? For example, downloading and installing a new WordPress instance doesn't take more than 30 seconds if you use the correct flow (more on this below).

2. Did you also know that you can check your plugins and themes with unit tests?

The tools that are used in these two questions are pretty nice from the start. Now, however, we can decide that we want to use these tools in conjunction with a Continuous Integration tool such as Gitlab. Then our nice tools become really powerful tools that developers should use to deliver really good, bug-free code.

What is WP-CLI?

WP-CLI is the command line tool for WordPress. It allows developers to execute any command that one would only execute with the command line in the admin area of ​​a WordPress website. You don't need a web browser, so WP-CLI is the perfect tool for every real developer 😉

How does the installation work?

1. Download the tool with curl (or wget):

2. Make the file executable:

3. Move it to a location that can be accessed from anywhere:

If you follow these steps exactly, WP-CLI should then be available on the computer. We can test this by entering the following command line: wp –info. Information about the respective WP-CLI version should then be displayed.

What can you do with it?

One can:
List all posts:

List all posts of a custom post type (i.e. own content types): the name of the specific content type is.
Delete a post:, where

is the ID of the post to be deleted.
These three commands are all basic commands. The main thing is that you can combine the commands to create even more powerful commands.


For example, let's say we want to delete all posts of any custom post type: is the name of the specific content type.
Perhaps we would also like to delete all posts that are currently in the trash folder:

Download and install WordPress

There are two ways we can download and install WordPress:
The first, more arduous, method is the manual method. So, let's briefly list all the steps necessary to manually download or install WordPress:

  1. First we open the browser
  2. Then we go to https://de.wordpress.com/
  3. and download the file from https://de.wordpress.org/download/
  4. Then we have to unzip the file
  5. And create and configure a database with PHPMyAdmin (which requires a few additional steps)
  6. Then we go to our WordPress url and configure our website:
  7. First we choose the language
  8. and then enter the credentials for the database
  9. Then we perform the installation (title of the website, user credentials of the administrator)
  10. Now we can finally log in with our new admin account

As is easy to see, this method requires several steps to be carried out so that WordPress works smoothly (as already mentioned, I did not count the steps for creating the database here, you have to think about them).
Because we all like to make life easier for ourselves, we will try to shorten this procedure using WP-CLI. So here is the second variant, which we have more or less automated by doing everything from the command line.

1. First we open the terminal

2. and create our database:

In which:
- DB_USER our database user
- DB_PASSWORD the password for the database and
- DB_NAME is the name of our database

3. Now we go to the folder where we want to save our WordPress installation

4. and then download WordPress: wp core download

5. Then we configure the login data for our database:

In which:
- DB_NAME the name of the database
- DB_USER our database user and
-DB_PASSWORD is the password for our database user.

6. Finally we configure the WordPress instance:

That's it! Now we have a WordPress ready to use! Some of you may already be able to guess what I'm going to do next ... Namely ... Deactivate the default themes and plugins. Well, did you guess it?

And this is how we do it:

1.

Wow! This command gave us a clean WordPress that we can use right away!
If you took a closer look at the code, you will probably have noticed the special separator &&. With it we can execute multiple commands in just one line. Let me know if you want to know more about it! 😉

Automate the installation

So, we've found that it's pretty easy to do and configure a new WordPress installation. However, there is one aspect of this procedure that annoys me personally: namely, that I am not particularly gifted at memorizing the commands correctly by heart. That is why it unfortunately often happens to me that I enter wrong parameters, which at some point gets really annoying.

However, there is, thank God, a solution to our code memory weakness: We can automate the process as much as possible. This saves us valuable time every time we do a new WordPress installation.

When I start a new project, I always follow the following template. This makes the entire installation much easier. I use two directories for this: htdocs for the website and development for the developer tools.

The folder structure of my projects looks like this:

So that we can automate the installation process, we need to write a small shell script. Don't panic if you don't have any experience with the associated syntax, because luckily it is quite straightforward. The script is saved in the file development / setup.sh.

Attention Windows users !: In this case you have to create a .BAT file first. However, the BAT format is pretty much unknown territory for me personally, so I'd rather save this topic for a future update of this article, okay?

Go on:

A shell script must always start with the following line:

Let's think about the parameters that have to have different values ​​for each installation. I can think of two different sets of values: the database login data and the website settings.

We can handle this fact in two different ways: We can 1. use the parameters in the command line when executing the script or we can use the variables within the script. Personally, I prefer the second method - simply because you have to remember the names of all parameters with method 1 - and we have already discussed that remembering things is not my great strength ...

So number 2:

The rest of the script is in the development folder, so we need to make sure that we are executing the WP-CLI commands from the correct folder ()

Now create the database:

Finally, we can run the various command lines to download, configure and install the WordPress instance:

A small additional task: Since we don't need the default plugins and themes for WordPress, we can simply remove them directly:

When we're done, we can leave the user a nice message:

Now that our handy script is ready to use, we can put the finishing touches to it (which means we can make it executable). Namely with the following command line:

Finally, we run the setup script

and pray that no error message haunts us now.
For the sake of completeness, here is the entire content of the script:

Conclusion:

I strongly hope that one or the other was able to take away a few useful things from this article.

To recap: We learned more about the WordPress command line tool WP-CLI and noticed how useful it can be. We also looked at how we can automate the installation of a new WordPress instance using WP-CLI and a small shell script.

Using this method, creating a new WordPress website will take no more than 30 seconds. Sure, there are a few extra steps that are necessary, such as the configuration of the Apache / Nginx web server, the installation of WP-CLI, if the binary files are not available on the server, etc.

But we'll deal with these things later in another part of the article.

That's it at this point for the time being. I really hope you enjoyed the article. If you have any suggestions or corrections, let me know! Ciao!