Introduction
WHO IS THIS BOOK FOR?
It was the dichotomy between the almost trivial effort required to create a WordPress-based blog and publish a ‘‘first post’’ to the world and the much more detailed, broad understanding required to effect mass customization that led us to write this book. Many books on the market provide guidance to beginning bloggers by walking you through the typical functions of creating, configuring, and caring for your WordPress site. Our goal was to bridge the gap between an expert PHP developer who is comfortable reading the WordPress Codex in lieu of a manual and the casual WordPress user creating a public persona integrated with social networking sites and advertising services, with a tailored look and feel.
It was the dichotomy between the almost trivial effort required to create a WordPress-based blog and publish a ‘‘first post’’ to the world and the much more detailed, broad understanding required to effect mass customization that led us to write this book. Many books on the market provide guidance to beginning bloggers by walking you through the typical functions of creating, configuring, and caring for your WordPress site. Our goal was to bridge the gap between an expert PHP developer who is comfortable reading the WordPress Codex in lieu of a manual and the casual WordPress user creating a public persona integrated with social networking sites and advertising services, with a tailored look and feel.
In short, we hope to appeal to a range of developers, from the person looking to fine-tune a WordPress
theme to a more advanced developer with a plugin concept or who is using WordPress in a large
enterprise integrated into a content management system. We do this by exploring WordPress from
the inside out. Our goal for this book is to describe the basic operation of a function, and then offer guidance and examples that highlight how to take it apart and reassemble that function to fit a number
of needs. WordPress users who are not hardened PHP developers may want to skim through the
developer-centric section, whereas coders looking for specific patterns to implement new WordPress
functionality can start in the middle and work toward the end
HOW THIS BOOK IS STRUCTURED
This book is divided into three major sections: Chapters 1 through 4 are an overview of the WordPress
system, its major functional elements, and a top-level description of what happens when a WordPressgenerated
web page is displayed. Chapters 5 through 8 build on this foundation and dive into the
core of WordPress, describing internal code flow and data structures. This middle section is strongly
developer-oriented, and describes how to extend WordPress through plug-ins and customize it via
themes. The last section, Chapters 9 through 15, combines a developer view of user experience and
optimization with the deployer requirements for performance, security, and enterprise integration.
The following is a detailed chapter-by-chapter overview of what you can expect to find in this book.
Chapter 1, ‘‘First Post,’’ contains a brief summary of the history of the WordPress software core,
explores some popular hosting options, why community matters in a content-centric world, and concludes
with the basics of do-it-yourself WordPress installation and debugging.
Chapter 2, ‘‘Functional Overview,’’ examines each of the major sections of the WordPress system as
seen by a typical user in the course of writing, editing, and managing a blog. This chapter covers the
basic mechanics of the WordPress Dashboard, plugins, settings, permissions and users, and content
management features, laying the foundation for dissecting their internals in later chapters. If you’re
a beginning WordPress user, you should find this overview sufficient to develop proficiency in basic
WordPress authoring and management tasks.
Chapter 3, ‘‘Code Overview,’’ starts with the mechanics of downloading the WordPress distribution
and describes its basic contents and filesystem layout. A top-to-bottom code flow walks you from an
index or specific post URL, through the process of selecting posts, assembling content, and generating
the displayed HTML. This chapter is a map for the more detailed code tours in the developer-focused
section.
Chapter 4, ‘‘Tour of the Core,’’ examines the essential PHP functions comprising the basic WordPress
engine. It serves as an introduction to the developer-focused middle section of the book and also lays
the foundation for the deployment-, integration-, and experience-focused chapters in the last section.
This chapter also covers using the core as a reference guide, and why it is best not to hack the core code
to achieve desired customizations.
Chapter 5, ‘‘The Loop,’’ is the basis for the developer-centric core of this book. The WordPress main
loop drives the functions of creating and storing content in the MySQL database, as well as extracting
appropriate chunks of it to be sorted, decorated, and nested under banners or next to sidebars,
in both cases generating something a web browser consumes. This chapter disassembles those processes
of creating, saving, and publishing a new post as well as displaying content that has been stored
in the WordPress MySQL databases. The underlying database functions and the management of
content metadata are covered in more detail to complete a thorough view of WordPress’s internal
operation.
Chapter 6, ‘‘Data Management,’’ is the MySQL-based counterpart to Chapter 5. The core functions
create, update, and manipulate entries in multiple MySQL database tables, and this chapter covers
the database schema, data and metadata taxonomies used, and the basic relations that exist between
WordPress elements. It also includes an overview of the basic query functions used to select and extract
content from MySQL, forming a basis for extensions and custom code that needs to be able to examine
the individual data underlying a blog.
Chapter 7, ‘‘Plugin Development,’’ starts with the basic plugin architecture and then explores the hook,
action, and filter interfaces that integrate new functionality around the WordPress core. This chapter
demonstrates the interposition of functions into the page composition or content management streams
and how to save plugin data. Examples of building a plugin using a simple framework outline the
necessary functionality of any plugin. This chapter also covers creation of widgets, simpler-to-use
plugins that typically add decoration, additional images, or content to a blog sidebar; many plugins
also have a widget for easier management. Publishing a plugin to the WordPress repository and pitfalls
of plugin conflict round out the discussion of WordPress’s functional extensions.
Chapter 8, ‘‘Theme Development,’’ is the display and rendering counterpart to Chapter 7. Plugins
add new features and functions to the core, whereas themes and CSS page templates change the way
that content is shown to readers. Starting with the basic Sandbox theme, this chapter covers writing a
theme, building custom page templates, theme installation, and how thematic elements are used by the
functions described in previous chapters. This chapter ends the deep developer-focused middle section
of the book.
Chapter 9, ‘‘Content Aggregation,’’ looks at WordPress from a services point of view. If a blog represents
your public persona or online presence, it has to pull content from a variety of tools and content
sources. This chapter delves into web services interfaces, WordPress APIs, feeds into and out of WordPress,
and making WordPress entries show up in Facebook pages.
Chapter 10, ‘‘Crafting the User Experience,’’ looks at a WordPress installation from the perspective of
a regular or potential reader. Usability, testing, and the ease of finding information within a WordPress
blog form the basics, with added emphasis on web standards for metadata and search engine optimization
so a blog, or a specific blog post, can be found through an appropriate Google search. Whereas
Chapter 9 covers pulling external content into your WordPress instance, this chapter shows how to get
your content to show up elsewhere on the Web. Alternatives for adding search functionality, one of
WordPress’s weaknesses, are discussed, along with content accessibility and delivery to mobile devices.
Chapter 11, ‘‘Scalability, Statistics, Security, and Spam,’’ deals with good and bad popularity. Keeping
a WordPress installation safe from inevitable comment spammers as well as malicious attackers is a
key part of configuration and management, and this chapter covers the more popular security and antispam
plugins and features. Traffic analysis tools indicate how well certain content types, functions, ad
campaigns, promotions, or links are driving readership and how this informs traffic management.
Chapter 12, ‘‘WordPress as a Content Management System,’’ goes beyond blogging to examples of
WordPress as a system for managing the life cycle, integration, and distribution of networked content.
Integration with other open source content management systems including Drupal and Joomla rounds
out this chapter.
Chapter 13, ‘‘WordPress in the Enterprise,’’ tackles issues of scale and integration. WordPress may
address deficiencies in ‘‘enterprise scale’’ content management tools, and building on the mechanisms covered in Chapter 12, this chapter shows how to use WordPress with a variety of enterprise facilities
ranging from identity management to Microsoft ASP/.NET services.
Chapter 14, ‘‘Migrating to WordPress,’’ provides an overview of moving content from an existing
blog or content management system into WordPress, and examines issues of importing media such as
images, video, or formatted data. This chapter also covers mechanisms for redirecting existing sites to
a WordPress installation.
Chapter 15, ‘‘WordPress Developer Community,’’ is an introduction to contributing to the WordPress
ecosystem by working on the core, submitting plugins or themes, adding to the documentation canon,
and assisting other developers. An overview of WordPress sister projects such as bbPress for forums is
provided along with a brief summary of other developer resources and a glossary of WordPress-context
sensitive terms