Chapter 1: WordPress As a Professional Web Development Tool
WordPress was originally established as a tool for bloggers, aimed at the growing community of people writing personal, technical, or business blogs, and providing them with a platform they could use to host that blog on their own server. But WordPress has evolvedâsignificantly. It is no longer simply a blogging tool, but a fully fledged content management system (CMS), with a myriad of features that enable developers to experiment with the structure and functionality of a site, customize the dashboard and admin screens for users, and install plugins to enable whatever additional capabilities the site needs.
WordPress, to put it simply, is now a professional web development tool, used by thousands of web professionals to build sites for themselves, their clients, and other users. It's a tool on which you can build a business.
This chapter looks at the WordPress features you can harness as a professional web developer, and identifies how your working practices may need to change if you're scaling up your WordPress practice. You'll learn some techniques for improving your working and coding practices when collaborating as part of a larger team, and find out how to manage large web design and development projects, including the skills you'll need and the people you can expect to work with. You'll also look at the implications of building and possibly selling WordPress themes and plugins for release to other users and developers.
What It Means to Be a Professional WordPress Developer
If you're reading this book, there's a good chance that you already use WordPress on a professional or semi-professional basis. Maybe you work for an agency that builds client sites in WordPress, or for a company with a WordPress site that you maintain. You could be a freelance WordPress developer, or perhaps you're starting out as a fully fledged WordPress professional, setting up your own agency and building WordPress-powered sites for your own clients.
If you're going to do this professionally, you'll have to adapt your working style and practices, as well as your approach to development and coding. As a bare minimum, you'll need to do the following:
⢠Ensure that you understand WordPress well enough to build a diverse range of complex sites with it.
⢠Change the way you code so that people you're working with can understand what you've done and work with your code.
⢠Start thinking imaginatively about WordPress development, and in particular about how you can harness WordPress to solve your clients' real-world problems.
⢠Develop the skills needed to explain to your clients how WordPress, and the site you design and develop using it, can benefit them.
⢠Come to grips with the more commercial aspects of WordPressâusing it to enhance your clients' SEO, seeing the potential to maximize your earning potential from WordPress, and possibly start selling themes or plugins.
As you work through this book you'll see that there is no one-size-fits-all approach to being a WordPress professional, but there are some practices and capabilities all WordPress professionals need, and others that will be more relevant to you depending on exactly how you work with WordPress. We'll be revisiting this theme throughout the book, particularly in Part IV, âPushing the Limits: The Best Tools for Site Development."
Professional Coding Practices
The first thing you need to do if you want to scale up your approach to WordPress is review the way you code. Ask yourself: Who else looks at or works with your code at the moment?
The answer will vary according to where and how you work. If you're not running your own agency, you are probably not the person with ultimate responsibility for the quality and robustness of your code. Conversely, you might be the only person who works with your code.
Professional coding practices are about more than writing valid, standards-compliant code, although that is essentialâand hopefully you already do this. It's about writing code that other developers can happily work with and develop further. If you're developing themes or plugins for other WordPress users to install, then you may need to focus on writing code that is resistant to the kind of hacking a WordPress novice might subject it to.
There are a few aspects to professional coding practices:
⢠Make sure your code is valid and standards-compliant.
⢠Use up-to-date coding methods.
⢠Comply with the WordPress coding standards.
⢠Make your code tidy.
⢠Structure your files well.
⢠Be consistent.
⢠Use comments liberally.
The following sections describe what these guidelines mean in practice.
Valid and Standards-Compliant Code
Yes, I've already said this, but it is absolutely fundamental. If you haven't run the HTML in your themes or plugins through a validator, do it! The most popular method for validating your code is to use the W3C validator at http://validator.w3.org. This is the most widely used approach and the first place to start. However, validating your code involves more than just this. It includes (but is by no means limited to) the following:
⢠Validating against accessibility standards, including WAI, or the Web Accessibility Intitiative
⢠Checking links
⢠Validating feeds
⢠Cross-browser compatibility checking (including handheld and tablet devices)
For a long list of validation tools and techniques, take a look at the guidance on the WordPress codex at http://codex.wordpress.org/Validating_a_Website.
Up-to-Date Coding Methods
If others are going to be working with your code, especially if they're going to be paying for it, it's imperative that you write code that is up to date. For example:
⢠Don't use tables for layout (we really hope you stopped doing this a while back, but it bears repeating).
⢠Use the most recent versions of the main coding languagesâHTML5 and CSS3.
⢠Avoid using deprecated codeâalthough browsers are generally forgiving, your users may not be.
⢠Accept that you can't keep up to date with everything, but make sure you read web development blogs, journals, and magazines so you're not completely out of the loop.
⢠If a project involves something you haven't done for a while (or at all), do some research before startingâor hire a specialist as a freelancer or staff member.
WordPress Coding Standards
The WordPress codex details a set of standard coding practices, designed to help enhance consistency in WordPress code structure. This includes standards for PHP, HTML, and CSS.
Get to know these standards and use them. Even if you come across code that doesn't adhere to them, it's good practice to use them yourself and to expect members of your team to do so. The consistency and clarity that this brings to your code will help others who work with it, including your teamâand your clients if you are selling themes or plugins.
Tidy Code
If other people are going to be working with your code, especially if they aren't advanced developers themselves, your code has to be easy to understand. Adhering to the following best practices will result in code that is easier to work with and harder to break:
⢠Use line breaks and indentation to help others see how your code is structured in one glance.
⢠Avoid empty divs and other elements added purely for stylingâtry to keep your markup lean and use CSS to style it, including the use of CSS pseudo-elements where appropriate.
⢠Rationalize your stylesheets to avoid duplicationâif two or more elements or classes have the same styling, code it once instead of doing it repeatedly for each one.
Well-Structured Files
Files that have a clear structure are much easier for other developers to work with.
Your markup should be written in the order it appears on the page, even where you're using CSS to position it outside that flow. So if your layout shows the header first, then the content and sidebar followed by a footer, code it in that order. This will not only help other developers, but also improve ac...