Advertisement

Making the Perfect WordPress Theme: The Very Basics

by

This Cyber Monday Tuts+ courses will be reduced to just $3 (usually $15). Don't miss out.

This post is part of a series called Making the Perfect WordPress Theme.
Making the Perfect WordPress Theme: Introduction
Making the Perfect WordPress Theme: How to Code Well

In the first post in this series, we talked about what we're going to be covering over the next few articles. In this article, we're getting started.

Specifically, we'll be covering some basic stuff like the APIs, localization, and licensing.


Learning the APIs by Heart

I think it's safe to say that WordPress is the best platform because of the APIs: The APIs alone give WordPress its speciality of flexibility. Can you imagine an "inelastic" content management system?

I mean it: If WordPress is used by tens of millions of websites today, it's because of its flexible nature all of which is due to its APIs.

Anyway, it's important to know what WordPress APIs are and which ones you need to learn every bit of.

You can check all of the WordPress APIs here. While I suggest you learn and study every single API, I can't say that you'll need APIs like the HTTP API, the Filesystem API or the XML-RPC API regularly. Your themes should not contain hardcore functionality and invade the territory of WordPress plugins.

Here are the ones you'll need the most:

  • Options API - It's the standardized way of storing and retrieving your theme's options. While you don't see too much of it, it works together with the Settings API, so it's important that you learn it well.
  • Settings API - This API is the backbone of your "Theme Options" panel. You can choose to write your own panel or search for options panel frameworks, but you will definitely need to study how the API works. If you don't, you might wonder why there are some weird curly braces inside the option you retrieved, or do it all wrong and save every theme option in another database table row. Learn it! Learn it from a series called "The Complete Guide to the WordPress Settings API" or a Tuts+ Premium course called "Using the WordPress Settings API", both created by Tom McFarlin. If you're interested in the theme options frameworks, you might want check out Kyla Glover's review on WPExplorer about five free options frameworks.
  • Theme Customization API - If you want to give your users the liberty of previewing the theme customizations, this is the API for you. It allows the users to change the look and feel of your theme and see the changes in real-time (or sometimes, with a Preview button).

    There's an excellent series you can check out: "A Guide to the WordPress Theme Customizer". Written by Tom McFarlin, this series will teach you everything about the Theme Customization API.

  • Shortcode API - This is a very helpful API and by far my favorite one! It allows you to create snippets with square brackets that do stuff, basically. There are many articles here on Wptuts+ but if you need a primer on the API, you can check out Rohan Mehta's article, "Getting Started With WordPress Shortcodes".
  • Quicktags API - This relatively simple API allows you to introduce new buttons for the WordPress editor (Text mode) on the writing screen. You can use this to let your users include your theme's shortcodes, for example. Doesn't hurt to learn it, right?
  • Widgets API - This might be one of the most important APIs of WordPress for you, if you plan to enrich your theme with neat widgets in the sidebars (or footers). It's not actually hard to implement if you have a basic understanding of Object-Oriented Programming (OOP) with PHP, but I can personally recommend the "WordPress Widgets: Front to Back" Tuts+ course created by Tom McFarlin.

The Importance of Localization

WordPress is huge. You know why it's huge? Because it's not only in English, it comes with Macedonian, Turkish, Slovenian, Chinese and Persian, too (to name just a few). Looking at the list of translations for WordPress 3.6 at translate.wordpress.org, we see that there are over 80 translations that are finished or more than halfway through.

I don't know if you realized this already, but there's an enormous WordPress market in countries that don't speak English natively. I'm a Turkish web designer, and I promise you that when it comes to web design, WordPress dominates the market almost entirely here in Turkey. There's no national marketplace for digital products, and ThemeForest is generally our first choice to find premium WordPress themes, but local businesses sell extremely well, since their themes are written in Turkish.

I'm pretty sure this is the case for most countries and that's why you must think about making your theme translatable, at the very least. To take it one step further, you can make deals with people to prepare translation files in their languages. You could pay them or let them use your themes freely, it's up to you and the deal you make.

Trust me, if a French web design agency sees a phrase like "Already translated into French!", they will definitely move your theme to the top of their "themes to buy" list.


Licensing Options and Using Licensed Products Inside Your Theme

I can't stress this enough, so here comes a solid warning: If you don't know what licenses are and how they work, your themes will not be accepted in any marketplace.

Luckily, there's a website called TL;DR Legal which helps us understand the legalese language by simply summarizing license types like "If you use this license type, you grant people permission to use your stuff in commercial projects" or "If you're going to use a product licensed with this one, you must give credit to the original author of the work". You can even filter features to find out which license type is the best for you, or list licenses that have the features you seek.

For example; if you're going to use a free slider in your premium theme (meaning that you intend to make money from your theme), you must look for sliders with licenses that allow "commercial use".

If you're going to sell your themes on ThemeForest, you'll need to learn about Envato's licensing options, too. Like TL;DR Legal, Envato's license types for ThemeForest are really easy to understand. The "SimpleLicense" for Creative Market is also very simple to learn.


Wrapping Up

That's it for this article. In the next part, we're going to go over how to .write better code. We'll learn how to develop with WordPress' Coding Standards, how to comment our code and how to validate our code.

If you liked this article, don't forget to share it with your friends, and your comments are always welcome!

Advertisement