WordPress Maintenance Tips and Tricks

 WordPress Maintenance Tips and Tricks

As a WordPress developer who has work on various types of projects, I would like to discuss some of the pain points that I have personally experience when hiring an existing WordPress website to do edits or bug fixes. The tips and suggestions list in this article are intend to minimize or even eliminate these pains.

Why Proper WordPress Maintenance Is Important

Most of the time, websites are not a “set once and leave alone” affair, and this is true for all sites, not just WordPress ones. From time to time, you will have to deal with edits, updates or bug fixes, which your favorite developer will take care of. However, in some cases, you may have to rely on several different developers over the life of your website.

In the latter case, things often don’t go well for the incoming developer, especially if the previous developers did not adhere to best practices in handling their maintenance tasks.

Let’s look at some of the most important points to consider in your future maintenance work on WordPress projects so that you can make life easier for your next developer and make them love working on your site. Obviously making your developer’s job easier will also save a few hours of work and money in the process, which is always a good selling point for your potential customers.

1. Make a backup!

This may seem too obvious, but first things first! You need to back up your WordPress site properly and regularly.

This is one of the most fundamental things to do, even if you are not making any changes to your site at this time. You can do it manually by taking all the files plus the database dump and storing it somewhere safe, or you can use an automate backup option, courtesy of a WordPress backup plugin. There are many free and paid plugins that you can find in the WordPress plugin repository. You can also make good use of the server-level backup option, as most hosting providers offer backup options; this is something you should check with your hosting provider.

With regular backups, you have the peace of mind that your site will be back up and running after a crash or failure. It could also help your new developer troubleshoot without too much hassle, especially if you’re trying to fix a bug that you suspect may have occurr during maintenance in the past. Regular backups should help your new developers identify and address persistent issues that occurr months or years before they took over the project.

2. Install your WordPress site locally

I’m not proud to admit that I made this mistake in my early days, and have since notice that many developers do edits directly on the remote server. Unless you are concern about having sensitive data and all site files at the mercy of its developer, you should avoid this mistake forever. It is very inefficient to go back and forth between the developer’s local machine and the server after each edit.

Even if it is a small change, like a minor edit to change some text on your site, the developer has to navigate to the corresponding file/folder in the FTP client (if you are using FTP to upload files), please wait for the files to upload, and I hope there are no occasional FTP connection failures. Let’s not forget that some WordPress websites have too much data to practically move without wasting too much time and bandwidth. And, after everything has load successfully, they need to go to the browser and refresh the page which again depends on the speed and state of the network / server at the time. It may seem like we are talking about mere minutes and seconds that can be save with each change, but over the course of your project,these minutes could add up to hours of unnecessary work.

Edits are much faster if your developers have the site install on their local machine – they just have to make the edits, refresh the page, and you’re done. Even if they live inside a cave without an internet connection, they can still work and upload their changes at a later time.

What if you have sensitive data that you are concern about, or if there are legal reasons that prevent you from sharing all of your data with developers? In this case, you can prepare dummy data specifically for this purpose. You can also save this data for future maintenance.

3. Go to Git

One of the best things to happen in the world of software development is the beginning of online version control. I bring this point because there are many sites that still run with the traditional cPanel / FTP method of handling files. Either they don’t know how good version control is, or they do, but are hesitant to implement it due to the initial setup effort. However, it’s not really a lot of work and it’s anything but a difficult task.

Version control comes with a number of benefits when it comes to managing files, including tracking multi-author changes, easily reverting edits, the ability to have separate branches for each independent task to make sure that changes from each task do not interfere with others.

You have to set up Git on an external server, which most of the time is pre-install by your hosting provider. You may need someone with some server experience to start the repository and configure the workflow, which I am not going to discuss here because it is beyond the scope of this article.

And not to mention that you’re not really “git’ing” if you don’t use branches! Create at least two branches for development and production so that developers can do all the work in the development branch, test the site, and then if everything is okay, move on to the production branch making sure nothing goes wrong with the site live.

4. Remove unnecessary files, codes and plugins

It is common to leave files and plugins that are no longer need. This becomes a problem once files accumulate over time throughout the life cycle of your website. If your developer didn’t care about removing junk files that were add over time, it’s hard to track where they came from and whether or not it’s currently using anywhere on the site. This causes an additional headache as the site needs to be test one more time to make sure nothing was broken after removing those suspicious items.

This can be remove by deleting the junk files immediately by the corresponding developer who work on them. You can emphasize this practice to all of your developers

Remove unnecessary plugins

In addition to PHP files and plugins, unused media files fill up the  wp-content folder over time, which can be a problem for developers working on media-relate functions. There are plugins that make this job easier. One example is Media Cleaner.

The plugin features an internal trash can, moving files there temporarily for you to make sure the files are not actually in use; once mark, you can permanently delete them. Make sure to follow point number 1 of this article (that is, make a backup copy) before cleaning any of your files.

Remove unnecessary codes

You’re probably familiar with the programming meme that goes something like this: When the code was written, the author who wrote it, co-workers, and God got it. After some time, only the author and God knew what he was doing, and now only God knows what he is doing unless the author adds the appropriate comments!

Some developers may be reluctant or downright lazy when it comes to commenting, but it’s a must practice in a good development environment. It reduces the time for edits and bug fixes that would otherwise be spent by new developers or even the developer himself figuring out what a particular block of code does.

Comments should be added as long as the function, class, or code block is not obvious. Take the following function, for example:

function stripWhiteSapaces(str)  
Return str;

Example of code

The above function name speaks for itself and there is no need for the user to enter the function to see how it works, you are just doing a job, removing the blanks, that’s it! So in this case, comments may not be necessary.

But for example, if there is a function that accepts multiple parameters and returns a filter list of posts, then this is not as obvious as the one above. There should be comments that describe the parameters and their types. It may also be necessary to describe the code blocks within this function.

For a quick check, you can grab a WordPress core file and see how WordPress experts have comment on it. Or, for more detail information, you can check out the official WordPress guide that illustrates this well.

6. Linting

Linting is another cool feature that enforces the rules on the way we write code and sometimes fixes the formatting of the code itself, which is great and useful. Most of the IDEs in use today come with fluff options, which you can further enhance or customize by adding various fluff settings.

For example, when you use Visual Studio Code as your IDE, VS Code uses the official PHP linter ( php -l) for PHP language diagnostics. You can set rules/restrictions for each language separately (i.e. PHP, JavaScript, CSS, etc.). You can take a look at the WordPress Coding Standards for more details.

Once you have a fluff setting, you have to enforce it. All your current and future developers should integrate this linting setup into their IDEs so that their code also adheres to the same rules/restrictions. Otherwise, much of your effort will be waste.

7. Nomenclature of variables and files

Design a standard that deals with how things are name. This includes function/class names, variable names, file names, and even media/image names if it’s part of the template because it will also help you understand what they’re for.

Consider some of the vital points:

  1. Avoid unambiguous names
  2. Be brief when possible
  3. Sometimes it is really useful to add the “type” to the file name. For example, if it’s an icon, it might have something like BlackArrowIcon.png, or if it’s a large background image, it might have something like FrontYellowBG.jpg. Or if it is a code file, sometimes it is very easy to know what that file means when working with multiple files open in multiple IDE tabs. For example, if there is a class with helper functions, it will be helpful if HelperClass.php is call instead of Helper.php.

8. WordPress debugging

Debugging can take a significant amount of time and tends to take a large share of the total amount of development time, especially when it comes to edits or bug fixes. This means that you have to consider whether your developers are doing it as efficiently as possible. Most developers tend to do this manually var_dump‘ing the variables somewhere on the web page which is not the most efficient method. This can also cause headaches for developers joining the project later, as they will end up with garbage lines here and there if the debugging code is not properly clean up after the job is done.

There are a few plugins to help with this debugging task. The following are some examples of popular WordPress debugging plugins.

9. Have better CSS

An example of incorrect CSS.

An example of good CSS.

When it comes to web development, designing with CSS is one of the most basic activities. Unfortunately, that means it is often overlook and paid less attention than JS, PHP, etc. But believe it or not, CSS can cause a great deal of trouble if it’s not configure correctly when you try to add or edit something in the future. Unless your site is basic and small.

Related post