WordPress - Rachel McCollin - E-Book

WordPress E-Book

Rachel McCollin

0,0
28,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Take WordPress beyond its comfort zone

As the most popular open source blogging tool, WordPress is being used to power increasingly advanced sites, pushing it beyond its original purpose. In this unique book, the authors share their experiences and advice for working effectively with clients, manage a project team, develop with WordPress for larger projects, and push WordPress beyond its limits so that clients have the customized site they need in order to succeed in a competitive marketplace.

  • Explains that there is more than one approach to a WordPress challenge and shows you how to choose the one that is best for you, your client, and your team
  • Walks you through hosting and developing environments, theme building, and contingency planning
  • Addresses working with HTML, PHP, JavaScript, and CSS

WordPress: Pushing the Limits encourages you to benefit from the experiences of seasoned WordPress programmers so that your client's site can succeed.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 656

Veröffentlichungsjahr: 2013

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



This edition first published 2013

© 2013 John Wiley & Sons, Ltd.

Registered office

John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom

For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com.

The right of the author to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.

Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought.

Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/ or its affiliates in the United States and/or other countries, and may not be used without written permission. WordPress is a registered trademark of WordPress Foundation. All other trademarks are the property of their respective owners. John Wiley & Sons, Ltd. is not associated with any product or vendor mentioned in the book.

A catalogue record for this book is available from the British Library.

ISBN 978-1-118-59719-4 (paperback); ISBN 978-1-118-59717-0 (ebook); 978-1-118-59718-7 (ebook); 978-1-118-59715-6 (ebook)

Set in 9.5 Myriad Pro by Wiley Indianapolis Composition Services

Printed in United States by Bind-Rite

Publisher's Acknowledgements

Some of the people who helped bring this book to market include the following:

Editorial and Production

VP Consumer and Technology Publishing Director: Michelle Leete

Associate Director–Book Content Management: Martin Tribe

Associate Publisher: Chris Webb

Associate Commissioning Editor: Ellie Scott

Project Editor: Tom Dinse

Copy Editor: Luann Rouff

Technical Editor: Mike Little

Editorial Manager: Jodi Jensen

Senior Project Editor: Sara Shlaer

Editorial Assistant: Annie Sullivan

Marketing

Associate Marketing Director: Louise Breinholt

Marketing Manager: Lorna Mein

Senior Marketing Executive: Kate Parrett

Marketing Assistant: Tash Lee

Composition Services

Compositor: Jennifer Goldsmith

Proofreader: Wordsmith Editorial

Indexer: Potomac Indexing, LLC

About the Author

Rachel McCollin is a keen (if sometimes slow) cyclist, amateur photographer, and mother of two budding boy geeks.

She first discovered WordPress in 2010 when a client asked for a CMS to manage their site, and hasn't looked back since. She attended her first WordCamp a few months later and is now a regular fixture at WordCamp UK, having been declared “‘the best speaker wearing red shoes” in 2012.

She contributes to Smashing Magazine and wptutsplus and is the author of two WordPress-related Beginners Guides for Packt Publishing. She also runs Compass Design, a WordPress web development agency in Birmingham, UK.

About the Technical Editor

Mike Little is the co-founder of WordPress and founder and CEO of zed1.com ltd, a WordPress specialist web development consultancy.

He is a 100% WordPress specialist providing WordPress development, consultancy, training, and tech editing services.

He has developed many web sites for his clients including a number of UK government web sites and the award-winning I'm a Scientist, Get Me Out of Here (http://imascientist.org.uk) educational science engagement site. All in WordPress, of course. He is a long-term software developer (25+ years), with many programming languages, many disciplines, and many years under his belt, most at senior levels. He is a published author and technical editor.

He runs his local Manchester WordPress User Group, and serves on the WordCamp UK organising committee.

He lives with his family in Stockport, UK.

Acknowledgements

I'd like to thank all those in the WordPress community who have helped me develop my own use of WordPress, in particular the organizers of WordCamp UK, without whom I wouldn't have had the opportunity to meet many of the developers I'm now pleased to call friends.

I'd also like to thank Birgit Gruber (formerly of Wiley) for bringing me on board with this project, and Chris Webb, Tom Dinse, Luann Rouff, Sara Schlaer, and Ellie Scott for their professionalism and support. A huge thanks goes to Mike Little for his enthusiasm and feedback—having a co-founder of WordPress involved with this book is a pleasure and an honor. Members of my team at Compass Design provided feedback on the initial ideas for this book, inspired some of the content and contributed code used in the case studies—thanks to Mark Wilkinson, Tammie Lister, Scott Evans, and Nivi Morales.

My husband, Pete, spent many hours keeping two small boys calm while I disappeared to quiet rooms, libraries, or coffee shops to write, and I thank him for his continuing and unwavering support and patience.

Finally, I'd like to thank Jonny Allbut, whose input in planning this book made it much better than it would have been without him—I hope we manage to work on another writing project together sometime.

WordPress®: Pushing the Limits

Table of Contents

Introduction

Who This Book Is For

What This Book Covers

How This Book Is Structured

Part I: Professional WordPress Development

Part II: Content and Administration

Part III: Practicalities of Developing and Hosting WordPress Sites

Part IV: Pushing the Limits: The Best Tools for Site Development

What You Need to Use This Book

WordPress Documentation

Source Code

Part I: Professional WordPress Development

Chapter 1: WordPress As a Professional Web Development Tool

What It Means to Be a Professional WordPress Developer

Professional Coding Practices

Approaching Large-Scale Site Design

Developing Your WordPress Skills: It Never Stops

Giving Something Back to the WordPress Community

Testing

Writing Free Plugins and Themes

Contributing to the WordPress Website

Getting Involved in WordPress Groups or WordCamps

The Potential for Professional WordPress Development

Harnessing WordPress As a CMS

WordPress for SEO and Site Conversions

Developing Themes and Plugins You Can Sell

Summary

Further Resources

Professional WordPress Development

Coding Practices

Giving Something Back to the WordPress Community

Developing Your WordPress Skills

WordPress for SEO

Developing Themes and Plugins You Can Sell

Chapter 2: Kicking Off a WordPress Project

Setting Up Development Hosting and Domains

Selecting the Best Hosting and Domain Setup for Your Project

Agreeing What to Put in Place During Development

SEO During Site Development

Content Planning and Structure

Identifying How to Structure Content: Questions for Clients

Planning Content Generation

Matching Content to the Best WordPress Page or Post Type

Planning Content Display

Writing a Technical Brief

Configuring WordPress for the Team and the Client

Planning Access and User Capabilities

Summary

Further Resources

SEO and Teaser Pages

Project Collaboration: Themes and Plugins

Site Development Plugins

Part II: Content and Administration

Chapter 3: Content Organization and Relationships

Rationalizing Your Content

Considering a Site's Layout and Structure

Identifying Editing Requirements

Displaying Device-Specific Content

Examining How WordPress Stores Content

The Core Database Structure

The WordPress Options Table

Building Custom Post Types

Manipulating Post Type Parameters

Building Relationships Between Content

Adding Extra Data to Content

Working with Taxonomies

Custom Fields and Post Metadata

Adding Media to Content

How Post Attachments Work

Featured Images

Summary

Further Resources

Device-Specific Content

How WordPress Stores Content

Custom Post Types

Taxonomies

Custom Fields and Post Metadata

Chapter 4: Customizing the WordPress Admin

When to Customize the WordPress Admin

Client Sites

Themes and Plugins

WordPress Roles and Capabilities

Custom Roles and Capabilities

Creating Admin Screens

Customizing the Dashboard

Creating Admin Sections and Screens

The Theme Customizer

Content and Editing

Customizing Listing Screens

Providing Help for Editors

Sanitizing Data

Callback Functions to Sanitize Data

Summary

Further Resources

Roles and Capabilities

Admin Screens and the Settings API

The Theme Customizer

Listings Screens

Adding Meta Boxes

Data Sanitization

Part III: Practicalities of Developing and Hosting WordPress Sites

Chapter 5: Development and Hosting Environments

Creating a Robust Development Environment

The Advantages of Local Development

Working Collaboratively on Large Projects

Virtual Machines and Browser Testing

Testing on Other Devices

Development Software and Tools

Creating a Client Approval Site

The Approval Process

Controlling Access and Search Engine Visibility

Client Approval Access and Privileges

Tracking and Responding to Amendments

Migrating a Site for Launch

Preparing to Go Live

Going Live Site Checklist

Moving WordPress Sites

Hosting Options for Clients

What You Need to Know

Finding and Getting the Most from a Hosting Provider

Summary

Further Resources

Setting Up a Local Development Environment

Tools for Collaborative Working

Browser Testing Tools

Browser Support Tools

Mobile Testing Tools

Moodboard and Color Palette Tools

Bug Tracking Tools

Moving a WordPress Site

Hosting

Chapter 6: Avoiding and Dealing with Disaster

What Could Go Wrong and the Consequences

Avoiding Problems

Site Performance Problems

Avoiding Data Loss

Updating WordPress and Installed Plugins Safely

Improving Security

Planning for the Future

WordPress Upgrades Overview

Using the WordPress Trac Site

Testing with Pre-release WordPress Versions

Testing and Debugging Plugins and Themes

Detecting and Supporting Multiple Versions of WordPress

When Disaster Strikes

Communicating with Clients or Users

Identifying the Problem

Fixing the Problem

Summary

Further Resources

Server Monitoring

Backing Up

WordPress Upgrades and Planning for the Future

WordPress Security

Dealing with Disaster

Part IV: Pushing the Limits: The Best Tools for Site Development

Chapter 7: Theme Building: Frameworks, Standalone Themes, or Child Themes?

Theme-Building Principles

Approaches to Theme Building

Rapid Theme Development for Teams

Building Themes from Scratch

Making It Work

Customizing an Existing Theme

Making It Work

Using Child Themes

The Parent/Child Theme Relationship

Choosing Your Parent Theme

Developing with Theme Frameworks

So Many Frameworks!

Getting More from Frameworks

Building Your Own Theme Framework

Theme Building for Networks

Differences Between Single and Multisite

Planning How to Use Network Themes

BuddyPress and Beyond

BuddyPress and Themes

Summary

Further Resources

Theme Building

Adapting an Existing Theme

Parent and Child Themes

Theme Frameworks

Framework Functions

Framework Action Hooks

Framework Filter Hooks

Building Your Own Framework

Action Hooks

Filter Hooks

Widgets

Menus

WordPress Multisite

BuddyPress

Chapter 8: Conditional Display: Functions, Template Files, and Styling

Conditional Content: When It Applies

Using Conditional Tags

Theme Files for Conditional Content

Conditional Styling

Conditional Content in Action: Case Study

Summary

Further Resources

Conditional Tags

Template Files and Includes

Conditional Styling

Chapter 9: Custom Functionality in Theme Functions and Plugins

Theme Functions vs. Plugins

Working with the Theme Functions File

Uses for the Functions File

Coding a Robust Functions File

Adding Include Files for Functions

Functions Files and Child Themes

Building Functionality into a Plugin

Plugins Overview

Coding Robust Plugins

Plugin Security

Hooking Your Plugin to WordPress

Creating Settings, Parameters, and Controls

Summary

Further Resources

Plugins vs. Themes

Theme Functions File

Plugins Overview

WordPress APIs

Plugin Security

Building Widgets

Creating Shortcodes

Plugin Styling

Chapter 10: Making Your Site Soar: HTML, JavaScript, and CSS

Choosing Your Approach

Optimizing Your Code

HTML

Optimizing Stylesheets and Scripts

Working with JQuery

Practical Applications

Creating Forms

Media and Galleries

Approaches to Animations

Improving Navigation

Summary

Further Resources

Optimizing Performance

HTML5

Web Standards

Accessibility

Stylesheets and Scripts

Forms

Media and Galleries

CSS Animations

JQuery Animations

Navigation

Chapter 11: Device Compatibility: Responsive and Mobile Development

WordPress As a Responsive Platform: Trends and Advances

WordPress Makes Responsive Design Easier

Identifying the Best Approach for Your Clients

Developing a Responsive Theme Using CSS

Fluid Layout and Media Queries for Layout

Mobile-First Themes

Child Themes and Responsive Design

Responsive Navigation

Conditional Content for Devices

When to Send Different Content to Different Devices

Techniques for Identifying Device Types

Using Responsive Images

Conditional Navigation

Mobile-Only Themes

Uses for a Mobile Theme

Displaying a Different Theme Based on Device

Building Your Mobile Theme

Exploring the Possibilities: WordPress Web Apps

Summary

Further Resources

Responsive Design

Conditional Content for Mobile

Responsive Images

WordPress Web Apps

Chapter 12: Releasing Your Code to the Public

Sharing Your Code

Filling a Gap in the Market

Free vs. Premium Themes and Plugins

Releasing Your Code on wordpress.org

The Theme Review Guidelines

Plugin Submission Guidelines

Preparing Your Code for Release

Maintenance and Support

Supporting Your Theme or Plugin

Updates and Maintenance

Selling Premium Themes and Plugins

Commercial Development Expectations

The Practicalities

Preparing for Translation

Why Translate Your Code?

Internationalization and Localization

WordPress Translation Functions

Summary

Further Resources

Theme and Plugin Guidelines

Theme Unit Testing

Preparing Your Code for Release

Documentation

Support and Maintenance

Premium Themes and Plugins

Translation

Introduction

WordPress is the world's most popular content management system (CMS), and it continues to grow in popularity. There's an increasing trend for owners of websites of all descriptions to move to WordPress as their needs scale, along with their frustration with other customized or unintuitive CMSs that they may be using. As Matt Mullenweg said in 2012:

“We might not always be the platform people start with, but we want to be what the best graduate to.”

WordPress is now far more than a blogging platform. Enhancements such as custom post types and taxonomies, as well as improvements to the Dashboard such as the Menus screen added in version 3.0, and the new Media Manager enhancements in version 3.5, mean that developers can push WordPress further and users can quickly create beautiful, customized websites. If you're prepared to write custom functions and hook into the WordPress APIs, then there's very little you can't do.

WordPress is free and open source, with a large and dedicated community of users and developers, which is one of its strengths. It's also a platform on which you can build a career and a business. As a WordPress developer you may be considering setting up your own agency building WordPress-powered sites, or you may have already done this and want to take your skills to the next level so you can meet the needs of larger clients with more complex requirements.

This book will help you advance your WordPress skills so you can become a sought-after WordPress professional—working with teams and clients to create unique and powerful projects.

Who This Book Is For

This book is for WordPress developers. It won't teach you how to set up a WordPress installation and add themes, plugins, and content to create a basic site. You can find many other books out there that do that.

The book is aimed at people who have experience with web development and developing with WordPress. You might be an experienced plugin or theme developer, or you may have built sites for a handful of clients. You could be working as part of an agency team using WordPress, or in the web department of an organization whose own site is powered by WordPress. Or you could simply be an enthusiastic WordPress developer who wants to take things further.

Most of the examples in this book will teach you how to code custom PHP to make WordPress do what you want—you won't learn how to use the WordPress admin screens here. Although some screenshots of the admin are included, you won't learn which button to click or which menu to select—it is assumed that you already know this.

To get the most from this book, then, you should have a solid understanding of HTML, some CSS experience, and be capable of writing your own PHP. All the PHP in the examples is explained in detail but the book does not provide an introduction to PHP (again, there are other books that do that).

What This Book Covers

As WordPress becomes more popular and more widely accepted as a serious CMS, there is an increasing need for skilled developers who can use it to build custom websites that are much more than a blog or simple “brochureware.”

In addition, as large organizations switch over to WordPress, there is a need for WordPress developers who can manage large-scale web development projects, understand client needs, lead teams of developers, and develop robust, future-proof sites.

This book focuses on both of these. In the first part you will learn about WordPress as a professional tool, and about the skills you need to manage WordPress projects. You won't get a complete primer on business or management, but you will be prompted to think about how your WordPress skills need to be complemented by project management, planning, and team management skills. In the subsequent parts you will learn techniques for pushing WordPress to create powerful, customized sites. You will learn how to customize the admin and enhance security, as well as how to build mobile or responsive sites and make the best use of JavaScript and CSS alongside PHP. You'll learn when to add functionality via themes and when to use plugins, and make use of conditional tags for styling and content. Finally, you'll learn about releasing your code to the public, so you can test, submit, and market your themes and/or plugins and prepare them for translation.

How This Book Is Structured

This book isn't designed to be read from cover to cover (although please feel free to do so!). You can dip into chapters relevant to your expertise and learning needs, as each chapter stands alone. However, the book is divided into four related parts.

Part I: Professional WordPress Development

If you're an experienced WordPress developer but have little experience using WordPress professionally or managing WordPress projects, this part of the book will introduce you to the relevant considerations and skills.

• Chapter 1: “WordPress As a Professional Web Development Tool”—Why WordPress is great tool for professional web development and for building a career. Learn about the potential for professional WordPress development—it isn't just about client work.

• Chapter 2: “Kicking Off a WordPress Project”—How to begin WordPress projects in a way that gives you the best chance of success, including planning, writing a technical brief, and setting up your development environment.

Part II: Content and Administration

This part explains how WordPress manages content and data, and it will provide the skills you need to customize the WordPress admin for your clients.

• Chapter 3: “Content Organization and Relationships”—An analysis of how WordPress uses tables to store different kinds of content and the relationships between these tables, and what it means for development.

• Chapter 4: “Customizing the WordPress Admin for Client Sites”— How to customize the admin screens to make things easier for your clients and give them access to settings and options. This chapter also covers the Settings API.

Part III: Practicalities of Developing and Hosting WordPress Sites

As covered in this part, ensuring that you have robust hosting and development environments and can protect your code from security attacks or other problems enhances your reputation as a developer and saves you a lot of time.

• Chapter 5: “Development and Hosting Environments”—How to identify the most appropriate development and hosting environments for your projects, set them up, and configure them.

• Chapter 6: “Avoiding and Dealing with Disaster”— Everyone dreads a site being hacked or breaking after a WordPress update. This chapter shows you how to anticipate potential problems and avoid them, as well as how to deal with disaster if it does strike.

Part IV: Pushing the Limits: The Best Tools for Site Development

One of WordPress' many strengths is that you often have more than one way to accomplish a task. Using specific areas of development, this part of the book looks at the different options you have to achieve your objectives. Sometimes there is a “better” approach, but on other occasions it comes down to the specifics of the project or to your own, your client's, or your team's experience and preferences.

• Chapter 7: “Theme Building: Frameworks, Standalone Themes, or Child Themes?”—There are a few valid approaches to developing themes, and none of them is necessarily the “best” one. In this chapter you'll learn about the different approaches and when each might be most useful; how to interact with the popular theme frameworks; and how to build your own framework using custom action hooks and filter hooks.

• Chapter 8: “Conditional Content: Functions, Template Files, and Styling”—Different sections within a site may need to work in very different ways, either functionally or visually. In this chapter you'll learn how to use a variety of methods to achieve this.

• Chapter 9: “Custom Functionality in Theme Functions and Plugins”—Sometimes it's appropriate to add functionality to your theme's functions file, but in many cases writing a plugin will be better. In this chapter you'll learn how to identify which approach to use and how to build plugins to add commonly required functionality.

• Chapter 10: “Making a Site Soar: HTML, JavaScript, and CSS”— WordPress sites don't run on PHP alone. To build interactivity, styling, and media into your projects you'll need to work with CSS and JavaScript, and no theme will function without HTML. In this chapter you'll learn how to use these languages within WordPress and how to add animations, enhance the use of media, and customize navigation menus.

• Chapter 11: “Device Compatibility: Responsive and Mobile Development”— Responsive design has now entered the mainstream. In this chapter you'll learn how to add a responsive layout to your themes, how to work mobile first, and when to use a separate mobile theme for custom mobile sites.

• Chapter 12: “Releasing Your Code to the Public”—There are many opportunities for developers to share their code, either free or for payment. This chapter explores requirements for themes and plugins in the WordPress repository and how to submit them, and looks at the practicalities of selling your code for money, including how to identify a need and how to market and distribute your code. Finally, you'll learn how to prepare your code for translation.

What You Need to Use This Book

All examples in this book have been developed using WordPress version 3.5. In some cases the Twenty Twelve theme (http://wordpress.org/extend/themes/twentytwelve) has been used to power sites used in the examples.

In order to follow along, you'll need the following:

• A local or remote installation of WordPress 3.5 or later (preferably the latest version)

• A text editor (with FTP access if you're working remotely)

• A modern browser

You'll have your own preferred text editor and browser, so I won't make recommendations.

WordPress Documentation

The best source of documentation on WordPress is the codex at http://codex.wordpress.org/. Each chapter also contains a “Further Reading” section at the end, and in many cases the links quoted are to pages in the Codex. Codex pages are continually edited and added to, so if you can't find any of the resources listed, a search of the Codex is your best bet.

Source Code

As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All of the source code used in this book is available for download at www.wiley.com/go/ptl/wordpress. For example, you will find the following sample code online in the Chapter 10 folder, in the Example project, and the example.php file.

Example.php

<?php

function wpptl_call_scripts3() {

wp_enqueue_script( ‘example_script', plugins_url(‘/js/example-script.js', __FILE__), , , true );     

}     

add_action(‘wp_enqueue_scripts', ‘wpptl_call_scripts3' );

?>

Some source code snippets shown in the book are not comprehensive, as they are meant to help you understand a particular concept in the chapter. For these instances, you can refer to the files available on the website for the complete source code.

Part I: Professional WordPress Development

Chapter 1WordPress As a Professional Web Development Tool

Chapter 2Kicking Off a WordPress Project

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 accessibility, as screen readers read the code in the order in which it's written.

Structure your stylesheets in sections, with a summary of the structure at the beginning. For example, the Twenty Eleven theme (http://wordpress.org/extend/themes/twentyeleven) is split into no less than 21 sections, which include the following:

• CSS reset (this should always come first)

• Structure (for overall page layout)

• Global (for global elements such as fonts, list styling, and colors)

• Header (specific styling for the header layout)

• Menu (for the navigation menu)

• Content (for page or post content)

• Link (for links, including links in text and page titles)

• Image (for images within the content)

• Widgets

• Footer

• Media queries

Your themes may not need so many sections, but if you are developing themes for others to download and use, you'll need to cover all the bases.

Consistency

People who need to work with your code don't want any surprises, so consistency is essential.

For example, when coding HTML within PHP files, use a consistent method.

Some developers prefer to write opening and closing PHP tags every time they need to add markup, as shown in the following very simplified extract from the WordPress loop:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

  <article>

    <?php the_content(); ?>

  </article>

<?php endwhile; ?>

Other developers prefer to stay in PHP, and use echo instead:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

  echo “<article>";

    the_content();

  echo “</article>";

endwhile; ?>

The first approach is probably the most commonly used, and it is preferable if the people who will be working with your code are more familiar with HTML than they are with PHP. Whichever you choose, make sure you stick with it.

You should also use and format comments consistently. For example, you might prefer to add comments to your PHP on the same line as the code:

<?php the_content(); ?> // this is a comment

Conversely, you might prefer adding comments on separate lines:

<?php

/* this is a multiline comment

which spans more than one line */

?>

Again, whichever you do, be consistent and use the correct syntax.

CSS styles comments in the same way. HTML, however, uses only one kind of commenting syntax:

<article><!-- comments here --></article>

You already know how you prefer to code, and don't need us to tell you how to do it—but it's important to consider your preferences when other people will be working with that code, to ensure consistency and ease of understanding. You may also want to specify some coding practices and habits for other members of your team so you're all working in the same way.

Avoiding Duplication of Function and File Names

Whenever you write a new function, it's essential that you give that function a unique name to void any conflicts with WordPress functions or functions in other plugins or the active theme. It's normal practice to add a prefix to each function that corresponds to the name of your theme or plugin.

A function such as the following runs the risk of not being unique:

<?php

function name_of_function(){

// function contents

}

?>

Instead, it should have a prefix, as follows:

<?php

function prefix_name_of_function(){

// function contents

}

?>

In this book I prefix all functions with wpptl_:

<?php

function wpptl_name_of_function(){

// function contents

}

?>

This also applies to any the names of any hooks you register and of files you create in plugins. It doesn't apply to theme template files—these need to adopt the standard filenames for template files if they're going to work.

Liberal Use of Comments

Still on the topic of comments, it's worth stressing how important they are when working with other developers. Try to anticipate any places in your code where a comment could be useful to someone unfamiliar with it. This will help other developers understand at a glance what your code is designed to achieve.

As I discuss later in this book, there is almost always more than one way to achieve something in WordPress, and in code. The next person to work on your files may have a different way they prefer to code something, so what you've done may not make sense to them. By adding a comment, you're telling them what your code does and where it applies.

Commenting liberally will also help you when you revisit some code you wrote a year ago on a client site that now needs updating. The chances are good that this will happen at 4:00 p.m. on a Friday when the client's site has hit a problem and you need to edit some offending code fast. Good commenting can mean the difference between finding the problem straightaway, making the edit, and being home in time for the weekend, versus slogging through thousands of lines of code and missing your kid's soccer game.

Following are some tips for good comments:

• Use comments at the beginning of your file to explain what the file does. For example, in template files include a note about what data it displays and any customizations you've made to the loop or other parts of the file; and in plugin files add a note regarding its functionality. For example:

/**

* Template Name:    sidebar-products.php

*

* The include file used for the sidebar on pages using the

  single-product.php template. Displays a gallery of product images

  (omitting the featured image which is displayed in the content).

*

* @package WordPress Pushing the Limits

* @since 1.0

*/

This comment tells users the name of the template file, what it does, the theme it is part of (@package), and which version of the theme it has been in place since (@since). You should use a similar system for plugin files.

• Use comments to demarcate the sections of your code, not only in stylesheets but also in your theme template files and functions file.

• Comment anything that is nonstandard.

• Comment anything that took you a while to work out—use detailed comments so when you come back to it, you don't have to think it through again.

• Comment anything that you know someone else will be working on—for example, if your theme files contain scripts that you'll be asking a JavaScript developer to perfect, add comments explaining where they apply in the site.

• Use wording in your comments that you can find using a search later—so don't abbreviate, and use terms others would understand.

• Whenever you comment out some code, add a comment to yourself containing the reason. That way, if you forget to remove the code after you've finished, or want to add it back in the future, you'll know what's going on.

• When in doubt, add a comment!

Approaching Large-Scale Site Design

So, now that you're running a professional WordPress business (or planning to), you're going to want to attract big clients—clients with exciting, complex requirements for their website, and the budget to match.

The reality, of course, is that not all of your clients will be like this—indeed, if you're new to this game, the chances are good that smaller clients will be your bread and butter in the early years, but it's a good idea to set your sights high and develop working practices in line with this goal.

You may have worked on large, complex sites before, perhaps as an employee in an organization's web team. However, you may not have had overall responsibility for the site, for managing its development, and for working with its stakeholders.

To work with clients and manage the completion of large-scale web design projects, you need some key skills:

• The ability to work with a range of stakeholders

• A balance between technical capability and business sense

• Communication skills

• Planning and project management skills

• Problem-solving skills

The following sections take a look at how each of these skills applies to large-scale site development.

Working with a Range of Stakeholders

When managing large-site builds, you typically work with a range of stakeholders who have hugely varying expectations and different levels of understanding regarding what you're trying to achieve. Some stakeholders you might need to work with include the following:

• The client's project manager or website manager. This may well be the person who commissioned the work (but may not have approved it). He or she will have a sufficient level of technical capability but may know little or nothing about WordPress, especially if the client is moving to WordPress for the first time. This individual is an important ally for you as someone with an interest in the project's successful completion but may not have the authority to make important decisions.

• The client's senior managers or managing director. These people will be less closely involved in the project but have the power to make key decisions, including pulling the plug on your project or drastically changing its direction. Not involving these individuals at key stages in the project can be a big risk—if you complete most of the work before you present the website to them and they don't like it, you may have to start again from scratch.

• The client's technical staff or website editors. The client may have employees whose job it will be to maintain and edit the site once it is launched—unless they require you to do this. If not, you may have to train these employees to use WordPress and/or work collaboratively with them on some of the code. They are unlikely to be decision-makers.

• Your own team. You may have one or more partners in your agency, and a team of developers and designers, either freelance or employed by you. Your role is to ensure that they know their role in any project you're managing, they have the information and resources they need to do the work, they get feedback on that work, and they know what the deadlines are. You also need to oversee the quality of their work and intervene if it is not up to scratch.

As you can see, you could be working with some very different people; therefore, in order to ensure that your projects are successful, you'll likely have to adopt a different approach with each group—something you may never have done before if you're used to spending most of your time on development. You'll need to use the set of skills described in the following sections to make it work.

Balancing Technical Capability and Business Sense

Technical capability is essential. If you weren't already proficient in WordPress, you wouldn't be setting up a WordPress business. But you also need business sense, which comes into play not only when you're dealing with clients, but also when you're managing your own business. Obviously, it's beyond the scope of this book to teach you how to manage your accounts, form a business plan, and so on—you can find hundreds, if not thousands, of resources to help you with that—but it's worth noting that having or developing a business sense will help you choose the right WordPress projects and make a success of them.

When you're talking to a client about their website build, it's important to be able to step back from the details of a project to see the bigger picture—so you can translate technical knowledge into something that has a tangible benefit. For example, you may be great at building responsive sites, but if you can't explain the benefits to your client, they won't pay you to do it.

Communication Skills

“Code is poetry," or so the saying goes, and it is—well-written code can make a website soar, in terms of content, functionality, and performance. However, most clients don't understand code—and they probably don't understand web development or WordPress, at least not as well as you do. They may have some knowledge of web design and some fixed ideas about what their site should look like, and some of these may be good—we would caution against challenging the client on every design decision on the basis of your superior experience. Some of them may not be so good, however, and you'll need the communication skills to explain why—and then work together to find a resolution that will meet the client's needs.

Following are some of the scenarios in which you need to ensure effective communication with clients and your team:

• Client pitches. If you're lucky, all your work will come from referrals and you'll never have to do this, but most agencies need to do a client pitch at some point. Even if you are the only agency in the running, you still have to convince the client to hire you. At these meetings you need to be able to explain what you can offer in terms that the client understands and can identify with—in other words, a combination of business benefits and enough technical background to convince them of your expertise.

• Project and planning meetings. After landing a project, you will be working closely with the client to identify their requirements and determine how to implement them using WordPress. It's important to fully understand the requirements before diving straight into solutions, to avoid going down the wrong track. You need to both be a good listener and ask the right questions in order to extract the relevant information and probe for more detail. You should also be sure you confirm your understanding with the client—preferably in writing after meeting, to avoid any potential disagreements later.

• Dealing with disagreement. If you work well with your client and have a collaborative style, disagreements should be rare, but they do happen to most web designers at some point or other. If your client disagrees with something you've done, try not to get defensive. Remember that the site is theirs, and that they understand their business and its needs better than you do. If you don't think their idea will get the best results for the project or their business, explain it in those terms—“This is what I think will achieve the most conversions for your website and this is why," rather than “I've designed hundreds of websites and I know what works." For a definitive guide to working well with clients and avoiding conflict, you could do a lot worse than reading Paul Boag's Client Centric Web Design, or see his blog at http://boagworld.com.

• Managing your team. If you are working with a team of designers or developers, whether you personally employ them or not, you need to effectively communicate with them. At a minimum they need to know the following:

• What you are hiring them to do

• Your expectations in terms of quality and working style (e.g., how they code, what browsers or devices they should use for testing)

• Deliverables and deadlines

• The consequences of not delivering

It's important to build a solid relationship with your team if you want them to give you their best work—especially when the team is made up of your own employees, who you want to feel a real sense of loyalty toward your agency. Part of your management effort may also include occasions when they don't deliver work on time or to standard, or when they're unavailable.

There is a reason why you can find plenty of resources out there to help you manage and communicate with a team: It's crucial to the success of your agency. We've listed some of these, along with other relevant resources, in the “Additional Resources" section at the end of this chapter.

Planning and Project Management Skills

This is a biggie! If you will be managing large-scale web development projects, and hopefully more than one at a time, you need to plan thoroughly and hone your project management skills.

The strongest technical skills and the smoothest relationships with your clients and your team won't offset a lack of planning and effective project management. Managing large projects with teams of developers means spending a lot of your time doing the following:

• Planning projects. Large-scale web development projects need to have a project plan. Depending on your preferences and experience, you have a few options for creating this: project management software, a simple spreadsheet, or an online project management and collaboration tool. Whatever you choose, you need a plan that at the very least specifies the following:

• What needs to be done

• Who needs to do it

• When it must be completed

In addition, you might include dependencies—stages of a project that can't start until another one is compete (for example, you can't add content to a site until your client has provided it).

Make sure all stakeholders, including everyone with tasks to perform (and their managers if relevant), have provided their input to the plan and are committed to completing their actions within the deadlines agreed upon. Don't just sit down and write a plan yourself and expect everyone to stick to it—check everyone's availability before selecting any deadlines.

• Monitoring progress. As the project progresses, you need to keep on top of things. Check progress against deliverables and milestones on a regular basis—not just your own actions. If a delay seems likely, talk to the people involved to determine what can be done to get back on track. Do this as early as possible to avoid renegotiating deadlines when milestones aren't met because problems were communicated with only a few days left to deal with them.

• Communicating progress to stakeholders. Make sure anyone involved with the project knows what is expected of them next and what they can expect from you. This applies particularly to the client, who is likely to be focused on other things—for example, when sending the client work for review, specify the date by which you expect their feedback.

If you suspect that the client may struggle to complete necessary tasks, make success more likely by scheduling time to work with them on site. For example, schedule meetings to plan the site's content together and agree how it will be structured, rather than expect them to do it in a vacuum. Most clients will appreciate your expertise about planning website content and find that this starting point makes it easier for them to complete the work.

• Dealing with problems or delays. Most large website builds come up against a problem at some point. Try to spot problems early and have the courage to deal with them, rather than hope they'll go away. That way, they'll remain small problems instead of turning into messy, large ones.

• If you think you or your team won't be able to meet a deadline, deal with it early—either find a way to meet it by bringing in more resources, or negotiate the deadline or deliverables with the client well in advance.

• If the client changes their mind about something, use your communication skills to work out the best solution collaboratively. Avoid potential issues related to extra work by including a clause in your contract clearly stating what happens if the project brief changes along the way.

• If you suspect that a senior manager in the client organization is not entirely positive about the project, try to have a conversation about what you're trying to achieve in terms that make sense to him or her. Ask for any objections and concerns, and be able to demonstrate how you're addressing them. Try to ensure that all senior stakeholders have input early on, so they don't have it later by changing everything!

• If the client asks you to do something not outlined in the brief, explain that you can do so but only after the current project is complete. Put the new request on a wish list that you can review with the client later and agree on deadlines and costs.

Problem-Solving Skills

Creating a website for a client is a form of problem-solving. They have a problem (typically, not having as many customers as they'd like), and you are brought in to help them solve it. Any effective website will be an answer to a problem, rather than an end in itself, and the site needs to evolve and grow to continually address that problem throughout its lifetime—a good reason to use WordPress, whose flexibility enables a site to grow after launch.

All the areas we've already discussed involve solving problems—such as dealing with delays or disagreements—but the very process of designing and developing sites, themes, or plugins for clients involves problem-solving skills. If you get into this mindset of viewing your job as solving a problem, you can create solutions that truly benefit your clients, whether they're hiring you to build them a website or buying themes or plugins from you.

Before planning any project, consider what problems it has to address. What are the objectives? What does the client want people to do when they visit the site? What do the visitors expect when they are navigating the site? What does success look like?

This approach applies on both a large scale, when looking at a site's overall objectives, and on a small scale, when deciding exactly how to approach a given part of the site. For example, suppose the client wants to sell something online. Do they need a full-blown e-commerce solution, a subscription-based site, or a simple form linked to PayPal? In order to provide the client with the best solution, you first need to understand the client's problem (goal) and what they need to achieve.

Developing Your WordPress Skills: It Never Stops

You've already learned about some of the ways you can develop your WordPress skills by getting involved in the WordPress community. As someone selling WordPress services to others, be they clients or other WordPress users, you need to remember the following important point: Keep developing—continually. WordPress (like web design and development in general) never stands still—ongoing releases and updates mean you need to keep current with changes to the platform itself. In addition, methods for working with WordPress and extending it are constantly developing, so in order to remain competitive you have to keep up.

Set aside time every day, or at least every week, to learn about WordPress developments or techniques. Some of this time should be spent reading blogs, magazines, and journals to keep abreast of new developments, while some time should be spent expanding the range of WordPress skills in your armory.

Identify any gaps in your skills and the areas you need to improve on in order to win the kind of contracts you want, meet your clients' needs better, expand your services, or simply feel more confident in your own ability. Identify experts in those areas and follow their blogs or articles. Buy, read, and work through the growing library of WordPress books. Follow the blog at http://make.wordpress.org to keep abreast of changes, updates, and issues.

Set aside a budget for your own (and your team's) development. This should include money for books, conferences, and other events. As well as a monetary budget, you'll need a time allocation. When do you learn best—reading RSS feeds and blogs over your cornflakes, poring over a book in the wee small hours, or experimenting with new technologies at a hackday? Identify your own style and then block out some suitable time.

There will inevitably be occasions when personal development has to take a back seat to client work—if your business is successful, you'll struggle to juggle these. Don't let these periods of time last too long. If you get out of the habit of developing your WordPress skills and knowledge, you'll start to lose your edge—and if you lose your expertise, you'll start losing potential clients.

I recommend that every WordPress professional attend at least one WordCamp every year. This is where you'll meet other like-minded developers, pick up new techniques, make contact with potential partners, clients, or staff, and get out from behind your desk and mix with some real people.

Giving Something Back to the WordPress Community

Becoming a WordPress professional isn't just about filthy lucre. Because WordPress is an open-source platform, its continued evolution and success depends on a broad, highly committed community of developers who contribute to WordPress in a variety of ways.

Becoming part of this community helps you develop your WordPress skills, network with other WordPress developers, and raise your profile in the community. It also helps WordPress to evolve so that it continues to meet the needs of users, designers, and developers—including you!

Contributing to the Development of WordPress

WordPress has a team of core developers, but they aren't the only people involved—hundreds of developers contribute code, without whom WordPress couldn't survive. Areas you can contribute to include the following:

• Submitting patches

• Raising tickets

• Contributing to UI and design development

• Translating WordPress

• Reviewing themes

If you are going to be involved in core development, we recommend taking some time to understand what's involved and what's expected. Talk to other WordPress contributors if you can, or ask questions on the Make WordPress site at http://make.wordpress.org. The site also describes how to contribute, including detailed guidelines on submitting patches.

Testing

In addition to needing developers to contribute to WordPress core, WordPress also seeks people to help with testing. This isn't limited to developers. To get started, you need to install the WordPress beta tester plugin and set it up to work with one of two types of build—point release nightlies or bleeding edge nightlies. Point release nightlies tend to be more stable, and are useful for testing your own themes and plugins against beta versions of WordPress, while bleeding edge nightlies represent the very latest code and are what you would use as a WordPress tester.

You can also report bugs you find while testing beta versions of WordPress or already released versions.

Writing Free Plugins and Themes

Writing code for release to the public is a great way to develop your WordPress skills, even if you've never written a plugin or theme in your life. By making your code available free on the WordPress repository, you are helping other developers and giving them the opportunity to contribute to and improve your code, which helps you learn.

If you're a theme developer, why not try releasing a free plugin? Similarly, plugin developers can extend their knowledge by creating a theme. Other developers will help you to improve upon what you've written, and it gives you a chance to work with WordPress from a new angle.

This book has a whole chapter dedicated to releasing your code to the public (both free and paid). If this is something you want to do, take a look at Chapter 12.

Contributing to the WordPress Website

The content of the WordPress site at http://wordpress.org is contributed by developers just like you, and if you're good at answering questions or decsribing how code works, you can help.

Contributing to the Codex

The Codex (http://codex.wordpress.org) is the place most WordPress users and developers go to for information on how WordPress works. You can volunteer to contribute to the WordPress Codex, helping to improve the quality of the documentation. As WordPress evolves, there will always be functions and features that need documenting, or you could improve, add to, or update existing documentation. To find out how to get involved, see http://codex.wordpress.org/Codex:Contributing.

WordPress Support Forums

Open-source communities depend on the active participation of their members. If you know the answer to a question that another user has posted on a forum, please add your reply; it could help many other developers. You can use tags to access forum threads on a specific topic that you have expertise in—for example, if you're a CSS developer, visit http://wordpress.org/tags/css to find questions you might be able to answer.

Getting Involved in WordPress Groups or WordCamps

Local WordPress Groups and WordCamps are an invaluable source of support, informaiotn and advice for WordPress users and developers. Around the world, people meet up to talk about WordPress, to hear about techniques from speakers, and to discuss the work they're doing with WordPress—as well as to make friends!

Helping with Organization

If you've got experience of organizing events, or you'd like to have a go, you can volunteer to help organize your local WordPress group of the WordCamp in your country or region. Taking on this role will introduce you to a broad community of other WordPress users and developers, and you will gain a lot of respect and gratitude from your peers. But most importantly, it could mean an event can take place in your locality that otherwise wouldn't—which will benefit many WordPress developers and users.

You can find out more about becoming a WordCamp organizer at http://central.wordcamp.org/become-an-organizer/.

Contributing as a Speaker