Tải bản đầy đủ (.pdf) (412 trang)

wrox press professional wordpress, design and development

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (14.56 MB, 412 trang )

Hal Stern, David Damstra, Brad Williams
Wrox Programmer to Programmer™
Join the discussion @ p2p.wrox.com
Design and Development
Professional
WordPress
®
As the most popular self-hosted blogging software in use today,
WordPress is remarkably simple to operate and can be extended
and tailored for a wide variety of applications. This guide focuses
on the internal structure and flow of the core code, as well as the
data model on which that code operates, so that you can harness the
power of WordPress to meet your specific needs. The author team
pulls together developer and deployer expertise, as well as knowledge
of popular open source plugins, themes, and tools for WordPress, to
provide an in-depth guide suitable for all WordPress users, from self-
hosted bloggers to enterprise content management system applications.
Professional WordPress:
• Offers an overview of the WordPress system and describes what happens
when a WordPress-generated web page is displayed
• Discusses the core of WordPress, describing internal code flow and
data structures
• Demonstrates extending WordPress through plugins and customizing
it via themes
• Combines a developer view of user experience and optimization with
the deployer requirements for performance, security, and measurement
• Provides practical examples of integrating WordPress with enterprise
and social networking tools
Hal Stern is a vice president at a technology company and uses WordPress to blog
about his adventures in golf, ice hockey, and food.
David Damstra is the Manager of Web Services for CU*Answers, a credit union


service organization, where he manages a team of developers to create web sites
and web applications for the financial industry.
Brad Williams is the CEO and Co-Founder of WebDevStudios.com. He is also a
co-host on the SitePoint Podcast and an advisor on SitePoint Forums.
Wrox Professional guides are planned and written by working programmers
to meet the real-world needs of programmers, developers, and IT professionals.
Focused and relevant, they address the issues technology professionals face every
day. They provide examples, practical solutions, and expert education in new
technologies, all designed to help programmers do a better job.
Web Page Design
Explore the power and possibilities
of WordPress from the inside out
wrox.com
Programmer
Forums
Join our Programmer to
Programmer forums to ask
and answer programming
questions about this book,
join discussions on the
hottest topics in the industry,
and connect with fellow
programmers from around
the world.
Code Downloads
Take advantage of free code
samples from this book, as
well as code samples from
hundreds of other books, all
ready to use.

Read More
Find articles, ebooks, sample
chapters and tables of contents
for hundreds of books, and
more reference resources on
programming topics that matter
to you.
$44.99 USA
$53.99 CAN
Stern, Damstra,
Williams
WordPress
®
Professional
Related Wrox Books
Beginning Joomla! Web Site Development
ISBN: 978-0-470-43853-4
Written with an approachable and informative writing style, this hands-on book introduces you to Joomla! and gets you started
with using this powerful, versatile tool for developing and managing web sites. You’ll gain a clear understanding of Joomla! and
learn how to get things done within the Joomla! framework. Using this book, you will be able to harness the power of Joomla! to
accomplish the goals you want to achieve with your web site.
Beginning PHP5, Apache, and MySQL Web Development
ISBN: 978-0-7645-7966-0
PHP, Apache, and MySQL are the three key open source technologies that form the basis for most active web servers. This book
guides you through the entire process of setting up your own site and walks you through every step, from the installation of PHP,
Apache, and MySQL to database management, security, and integration with other technologies. The multi-platform approach
addresses installation and usage on both Linux® and Windows®, and two common-themed, reusable web sites are examined. Upon
completion of this book, you’ll be able to create well designed, dynamic web sites using open source tools.
Beginning PHP 5.3
ISBN: 978-0-470-41396-8

As one of the most popular open-source web-programming languages in use today, PHP is an ideal server-side scripting language
that connects HTML-based web pages to a backend database for dynamic content. It allows you to create anything from a simple
form-to-email script to a web forum application, a blogging platform, or a content management system. This guide introduces the
PHP language and shows you how to write powerful web applications using PHP.
Joomla! Start to Finish: How to Plan, Execute, and Maintain Your Web Site
ISBN: 978-0-470-57089-0
This book walks you through the critical steps that must be taken in the planning process prior to establishing a Joomla! site.
Joomla! expert Jen Kramer reviews essential questions that need to be asked of a client, discusses technical solutions to a variety
of challenges, and explains how a site structure should be organized. Once the groundwork has been laid, you’ll discover how to
host and install Joomla!, and upgrade and maintain your Joomla! site.
Professional Joomla!
ISBN: 978-0-470-13394-1
As a major force in the world of affordable, advanced web site deployment, Joomla! has become the most important noncom-
mercial Content Management System (CMS) in the world. Author Dan Rahmel walks you through the process of creating all three
types of Joomla! extensions (modules, components, and plug-ins), explains how best to use Ajax technology, and shows you how
to adopt design patterns and incorporate source code control. You’ll examine the underlying technologies (PHP, Apache, etc.) that
can be tuned to offer the best system performance. You’ll even delve into the internal structure of the Joomla! framework, so that
you can modify and extend Joomla! to meet the needs of you and your customers.
Professional PHP Design Patterns
ISBN: 978-0-470-49670-1
This book bridges the gap between the PHP and the older programming language by applying those tried and tested Design
Patterns to native PHP applications. It starts with an introduction to Design Patterns, describes their use and importance, and
details where you’ve seen them already. The book continues through a host of Design Patterns with code examples and expla-
nations. Finally, an in-depth case study shows you how to plan your next application using Design Patterns, how to program
those patterns in PHP, and how to revise and refactor an existing block of code using Design Patterns from the book. The author
approaches the concepts in technical yet usable formats that are familiar to both programmers who are self-taught and those
with more extensive formal education.
WordPress 24-Hour Trainer
ISBN: 978-0-470-55458-6
WordPress is today’s most popular open source blog publishing application, but its powerful features, simple interface, and

easy expansion make it a great content management system for all types of web sites. This unique book-and-video package
provides you with beginner-friendly tutorials for building and maintaining a WordPress web site. You’ll discover how to customize
WordPress to meet your needs and you’ll see how critical—and simple—it is to expand and update content in order to make your
site as effective as possible.
Get more out of
wrox.com
Programmer to Programmer

Interact
Take an active role online by participating in our
P2P forums @ p2p.wrox.com
Wrox Online Library
Hundreds of our books are available online
through Books24x7.com
Wrox Blox
Download short informational pieces and code
to keep you up to date and out of trouble!
Join the Community
Sign up for our free monthly newsletter at
newsletter.wrox.com
Browse
Ready for more Wrox? We have books and
e-books available on .NET, SQL Server, Java,
XML, Visual Basic, C#/ C++, and much more!
Contact Us.
We always like to get feedback from our readers. Have a book idea?
Need community support? Let us know by e-mailing
PROFESSIONAL WORDPRESS
®
INTRODUCTION xxv

CHAPTER 1 First Post . . . . . . . . . . 1
CHAPTER 2 Functional Overview . . . . . . . . 19
CHAPTER 3 Code Overview . . . . . . . . . 49
CHAPTER 4 Tour of the Core . . . . . . . . . . 65
CHAPTER 5 The Loop . . . . . . . . 79
CHAPTER 6 Data Management . . . . . . . . 103
CHAPTER 7 Plugin Development . . . . . . . . 121
CHAPTER 8 Theme Development . . . . . . . . 183
CHAPTER 9 Content Aggregation . . . . . . . . 229
CHAPTER 10 Crafting a User Experience . . . . . . . . 249
CHAPTER 11 Statistics, Scalability, Security, and Spam . . . . . . . 273
CHAPTER 12 WordPress as a Content Management System . . . . . . . . 299
CHAPTER 13 WordPress in the Enterprise . . . . . . . . 317
CHAPTER 14 Migrating To WordPress . . . . . . . . 329
CHAPTER 15 WordPress Developer Community . . . . . . . 351
INDEX . 365
wwww.wowebook.com
www.wowebook.com

PROFESSIONAL
WordPress
®

PROFESSIONAL
WordPress
®
DESIGN AND DEVELOPMENT
Hal Stern, David Damstra, and Brad Williams
Wiley Publishing, Inc.
Professional WordPress

®
: Design and Development
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-56054-9
Manufactured in the United States of America
1098 76 543 21
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, scanning or otherwise, except as permitted under Sections 107 or 108 of the
1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978)
750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department,
John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at
/>.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to
the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation
warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The
advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the
publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the
services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages
arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of
further information does not mean that the author or the publisher endorses the information the organization or Web site may
provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have
changed or disappeared between when this work was written and when it is read.

For general information on our other products and services please contact our Customer Care Department within the United
States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in
electronic books.
Library of Congress Control Number: 2010921230
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks
or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not
be used without written permission. WordPress is a registered trademark of Automattic, Inc. All other trademarks are the
property of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor mentioned in this book.
To Toby, Elana, and Ben, whose support is unequaled.
–Hal Stern
To my beautiful wife Holly and my sons Jackson, Justin, and Jonah for
their love and support.
–David Damstra
In memory of my mother, Royce Jule Williams.
–Brad Williams

ABOUT THE AUTHORS
HAL STERN is a Vice President with a major technology company where he focuses on cloud comput-
ing, security, large-scale data management, and building technical communities. Hal began blogging
about five years ago as a way to share customer interactions and technology observations, and
eventually began using WordPress as an outlet for more personal thoughts on music, food, life in
New Jersey, ice hockey, and the flailings known as his golf game. You can follow Hal online at
porkrollandfriends.com
and
snowmanonfire.com
.
DAVID DAMSTRA is the Manager of Web Services for CU*Answers, a credit union service organiza-
tion. David manages a team of developers to create web sites and web applications for the financial
industry. David’s team uses WordPress as the foundation for many web projects. David is also a

Zend Certified Engineer for PHP5. You can find David online professionally at
ws.cuanswers.com
and personally at
mirmillo.com
.
BRAD WILLIAMS is the CEO and Co-Founder of WebDevStudios.com. He is also a co-host on the
SitePoint Podcast and an Advisor on SitePoint Forums. He was one of the original co-hosts on the
WordPress Weekly Podcast and still joins the show on occasion. Brad has been developing web sites
for over 14 years, including the last four, where he has focused on open-source technologies like
WordPress. You can follow Brad online on his personal blog at
strangework.com
.
ABOUT THE TECHNICAL EDITOR
MIKE LITTLE is the co-founding developer of the WordPress project. He started WordPress in 2003
with Matt Mullenweg (now of Automattic Inc.) and has been developing with and using it ever
since. He now runs
zed1.com
, his web development and consultancy company, which specializes in
WordPress. He recently worked on a number of government WordPress sites, most notably a Law
Commission consultation site, and now develops and supports a site for a large Cabinet Office client.
He is a published author and a member of the Usability Professionals Association.
CREDITS
EXECUTIVE EDITOR
Carol Long
PROJECT EDITOR
Brian MacDonald
TECHNICAL EDITOR
Mike Little
PRODUCTION EDITOR
Daniel Scribner

COPY EDITOR
Kim Cofer
EDITORIAL DIRECTOR
Robyn B. Siesky
EDITORIAL MANAGER
Mary Beth Wakefield
ASSOCIATE DIRECTOR OF MARKETING
David Mayhew
PRODUCTION MANAGER
Tim Tate
VICE PRESIDENT AND EXECUTIVE GROUP
PUBLISHER
Richard Swadley
VICE PRESIDENT AND EXECUTIVE
PUBLISHER
Barry Pruett
ASSOCIATE PUBLISHER
Jim Minatel
PROJECT COORDINATOR, COVER
Lynsey Stanford
PROOFREADER
Publication Services, Inc.
INDEXER
Robert Swanson
COVER DESIGNER
Michael E. Trent
COVER IMAGE
© Karen Phillips/istockphoto
ACKNOWLEDGMENTS
THIS BOOK IDEA STARTED WHEN Jonathan Dingman remembered a conversation we had about this

book idea at WordCamp NYC 2008, and connected me with Carol Long at Wiley. Thanks to Carol
for agreeing to endure another project with me, and to editor Brian MacDonald for turning mean-
dering streams of thought into something powerful. Mike Little’s technical review of the book was
equally insightful and invaluable. Various co-workers in the MySQL and Sun Microsystems com-
munities contributed to my passion for blogging and understanding how things work, among them
Tim Bray, Rich Zippel, Dave Douglas, Brian Aker, Bob Sokol, Jeremy Barnish, Hansjoerg Klimetzki,
and the divas, Candace LoMonaco and Maria Buoy. Co-authors Brad and David have made this
project as much fun as a challenge, and their ability to edit as a group is only one small artifact of
their immense developer talents. Finally, my wife Toby, and children Elana and Ben stopped asking
why my laptop was appearing at odd times like weekends and vacations, and I appreciate the time
and space given to me to finish my scribbles.
—Hal Stern
I’D LIKE TO THANK EVERYONE at Wiley, particularly Carol Long for putting her faith in a first time
author and encouraging me to join this writing team, and editors Brian MacDonald and Mike Little
for their valuable insights, suggestions, and quick responses to our changes. I am also indebted to my
co-authors, Hal Stern and Brad Williams, who were able to turn this book around on such a tight
schedule. Thanks to my family, specifically, Holly, Jack, Justin, and Jonah for their love and support
while I was writing away. I’d also like to thank my parents, family, friends, and coworkers who have
all helped in some way and encouraged me to write this book. Finally, I would like to thank the
entire WordPress community for creating such a robust and powerful application.
—David Damstra
THANK YOU APRIL FOR putting up with my nerdy ways. Thank you Dad for being such an amazing
person and role model. Thank you to my sister Brittany, her husband Alistair, and my niece Indiana
Brooke. Thanks to Hal Stern for guiding me in this endeavor, David Damstra for being a great co-
author, Mike Little for his expertise, Brian MacDonald for his amazing editorial skills, and Carol
Long for believing in me. Thanks to Brian Messenlehner for getting me out to Jersey and helping
make WDS a reality. Thanks to Matt Martz, Michael Torbert, and Scott Basgaard for reviewing
the plugin development chapter. Thanks to Jeff (Fizzypop) Chandler for letting me be a part of the
WordPress Weekly Podcast. Thanks to Margaret Roach for her mentoring and friendship. Thanks
to all of my WordPress friends, including Lisa Sabin-Wilson, Brian Gardner, Craig Tuller (oohrah!),

Travis Ballard, Corey Miller, Jonathan Dingman, Dre Armeda, Andy Peatling, Matt Mullenweg,
Mark Jaquith, Jane Wells, Andrea and Ron, Aaron Brazell, Carl Hancock, Dan Milward, Ryan Imel,
Shane (margarita) F., Daisy Olsen, Jeremy Clarke, Steve Bruner, Michael Myers, and many more.
Thanks to Jeff Abshire and Jeff Gray for being awesome friends. Thanks to my podcast buddies
Patrick O’Keefe, Stephan Segraves, and Kevin Yank. Last but not least thank you to my zoo: Lecter,
Clarice, and Squeaks the Cat for your endless love and ridiculous ways.
—Brad Williams

CONTENTS
INTRODUCTION xxv
CHAPTER 1: FIRST POST 1
What Is WordPress? 1
A Short History: WordPress and Friends 2
Current State 2
Intersecting the Community 3
WordPress and the GPL 4
Content and Conversation 5
WordPress as a Content Management System 5
Creating Conversation 6
Getting Started 7
Hosting Options 7
Do It Yourself Installation 9
Installing WordPress Files 9
Database Configuration 12
Finishing Up 16
First-Time Administration 16
First Post 17
CHAPTER 2: FUNCTIONAL OVERVIEW 19
The Dashboard 19
Dashboard Widgets 20

Customizing the Dashboard 21
Screen Options 21
Admin Menu 22
Creating and Managing Content 22
Creating Posts 22
Managing Posts 24
Creating Pages 25
Managing Pages 25
Links 25
Trash 26
Categorizing Your Content 26
Categories versus Tags 26
Post Categories 27
CONTENTS
Tagging Posts 27
Categorizing Links 28
Working with Media 28
Media Library 28
Uploading Media 28
Inserting Media 29
Managing Media 30
Edit Media 30
Comments and Discussion 31
Managing Comments 31
Moderating Comments 32
Handling Comment Spam 32
Working with Users 33
Creating New Users 33
Managing Users 33
User Roles and Permissions 34

User Images 34
Extending User Profiles 35
Extending WordPress 35
Themes 35
Managing Themes 35
Adding New Themes 36
Upgrading a Theme 36
Using the Theme Editor 37
Working with Widgets 37
Plugins 38
Managing Plugins 38
Adding New Plugins 38
Upgrading a Plugin 38
Using the Plugin Editor 39
Content Tools 39
Importing Content 39
Exporting Content 40
Turbo 40
Upgrading WordPress 40
Configuring WordPress 41
General Settings 41
Writing and Reading 42
Discussion 44
Media 44
xiv
CONTENTS
Privacy 45
Permalinks 45
Miscellaneous 46
CHAPTER 3: CODE OVERVIEW 49

Downloading 49
Download Locations 49
Available Formats 50
Release Archive 50
Exploring the Code 50
Configuring Key Files 51
wp-config.php file 52
Advanced wp-config Options 53
.htaccess 58
Enabling Permalinks 58
.htaccess Rewriting Rules 59
Configuration Control Through .htaccess 60
The .maintenance File 61
WP-Content User Playground 61
Plugins 61
Themes 62
Uploads and Media Directory 62
Upgrade Directory 63
Custom Directories 63
CHAPTER 4: TOUR OF THE CORE 65
What’s in the Core? 65
Using the Core as a Reference 66
Inline Documentation 67
Finding Functions 67
Exploring the Code 70
Functions.php 70
Formatting.php 70
Pluggable.php 70
Plugin.php 71
Post.php 71

Category.php 71
WordPress Codex and Resources 72
What Is the Codex? 72
Using the Codex 72
xv
CONTENTS
Function Reference 73
WordPress APIs 74
Codex Controversy 75
Don’t Hack Core! 76
Why Not? 76
Alternatives to Hacking Core 76
CHAPTER 5: THE LOOP 79
Understanding the Loop 80
Putting the Loop in Context 81
Flow of the Loop 81
Template Tags 84
Commonly Used Template Tags 84
Tag Parameters 85
Customizing the Loop 86
Using the WP_Query Object 86
Building A Custom Query 87
Post Parameters 87
Page Parameters 88
Category, Tag, and Author Parameters 88
Time, Date, Ordering, and Custom Parameters 88
Putting It Together 89
Adding Paging To A Loop 89
Using query_posts() 90
Using get_posts() 92

Resetting a Query 93
More Than One Loop 94
Nested Loops 94
Multi-Pass Loops 95
Global Variables 95
Post Data 95
Author Data 96
User Data 96
Environmental Data 97
Global Variables or Template Tags? 98
Working Outside the Loop 98
CHAPTER 6: DATA MANAGEMENT 103
Database Schema 103
Table Structure 104
xvi
CONTENTS
Table Details 105
WordPress Database Class 107
Simple Database Queries 107
Complex Database Operations 108
Dealing With Errors 110
Direct Database Manipulation 111
WordPress Taxonomy 114
Default Taxonomies 114
Taxonomy Table Structure 115
Understanding Taxonomy Relationships 115
Building Your Own Taxonomies 116
Custom Taxonomy Overview 116
Building Custom Taxonomies 116
Using Your Custom Taxonomy 119

CHAPTER 7: PLUGIN DEVELOPMENT 121
Plugin Packaging 121
Create a Plugin File 122
Creating the Plugin Header 122
Plugin License 123
Activate and Deactivate Functions 123
Internationalization 124
Directory Constants 126
Know Your Hooks: Actions and Filters 127
Actions and Filters 127
Popular Filter Hooks 129
Popular Action Hooks 130
Plugin Settings 132
Saving Plugin Options 132
Array of Options 133
Create a Menu and Submenus 134
Creating a Top-Level Menu 134
Adding To An Existing Menu 135
Create an Options Page 136
WordPress Integration 143
Create a Meta Box 143
Shortcodes 147
Create a Widget 148
Create a Dashboard Widget 152
xvii
CONTENTS
Creating Custom Tables 153
Uninstall Your Plugin 155
Plugin Security 157
Nonces 157

Data Validation 158
Creating a Plugin Example 160
Publish to the Plugin Directory 175
Restrictions 175
Submit Your Plugin 175
Create a readme.txt File 176
Setup SVN 179
Publish to the Plugin Directory 180
Releasing a New Version 181
CHAPTER 8: THEME DEVELOPMENT 183
Why Use a Theme? 183
Installing a Theme 184
FTP Installation 184
Theme Installer 185
What Is a Theme? 185
Template Files 185
CSS 186
Images and Assets 186
Plugins 186
Creating Your Own Theme 187
Starting from a Working Theme 187
Starting with the Sandbox Theme 187
Creating Your Own Theme: Getting Started 189
Essential File: Style.css 190
Showing Your Content: Index.php 191
Showing Your Content in Different Ways: Index.php 193
Creating Your Own Theme: DRY 193
Header.php 194
Footer.php 195
Sidebar.php 195

Deviations from the Norm: Conditional Tags 196
xviii
CONTENTS
Creating Your Own Theme: Content Display 197
Customizing Your Homepage: home.php 197
Show Your Older Posts by Date: Archive.php 200
Showing Only One Category: Category.php 201
Show Posts of a Specific Tag: Tag.php 202
Howto ShowaSingle Post:single.php 203
Display a Page: Page.php 204
Display an Image from Your Gallery: Image.php 206
Template Hierarchy 206
Creating Your Own Theme: Additional Files 208
Handle 404 Errors: 404.php 208
Attachment.php 209
Author.php 210
Comments.php 210
Add Functionality to Your Templates: Functions.php 211
Search.php 214
SearchForm.php 215
Other Files 215
Custom Page Templates 216
When to Use Custom Page Templates 216
How to Use Custom Page Templates 217
Stock Sandbox Page Templates 218
Theme Hierarchy and Child Themes 219
Premium Themes and Other Theme Frameworks 224
Revolution Theme 225
Hybrid Theme 225
Thematic Theme 226

Thesis Theme 226
Sandbox Theme 226
Partial Themes 226
CHAPTER 9: CONTENT AGGREGATION 229
What is a Lifestream? 229
Getting Noticed 230
Social Media Buttons 231
Simple Social Networking Badges 232
xix
CONTENTS
Collecting External Content 233
Generic XML Feed 233
Integrating Twitter 236
Google Maps 238
Integrating RSS and ATOM Feeds 239
Pushing Content from WordPress to Other Sites 240
Feeding RSS into Other Sites 240
Feeding WordPress into Facebook 241
Advertising 242
Monetizing Your Site 242
Setting Up Advertising 243
Using Advertising Plugins 243
Manual Advertising Placement 245
Dealing With Conflict 246
Privacy and History 247
CHAPTER 10: CRAFTING A USER EXPERIENCE 249
User Experience Principles 249
Consistent Navigation 250
Visual Design Elements 251
Making Content Easy to Find 253

Site Load Times 254
Using JavaScript 255
Usability and Usability Testing 256
Structuring Your Information 257
Getting Your Site Found 259
Duplicate Content 261
Trackbacks and Pings 263
Tags and Content Sharing Sites 264
How Web Standards Get Your Data Discovered 264
Semantic HTML 264
Valid HTML 266
Microformats 267
Searching Your Own Site 269
Weaknesses of the Default Search 269
Alternatives and Plugins to Help 270
Mobile Access 271
xx
CONTENTS
CHAPTER 11: STATISTICS, SCALABILITY, SECURITY, AND SPAM 273
Statistics Counters 273
AWStats 274
Statcounter 275
Mint 276
Google Analytics 276
Cache Management 278
WordPress System Complexity 279
Web Server Caching and Optimization 281
WordPress Object Caching 283
MySQL Query Cache 284
Load Balancing Your WordPress Site 284

Dealing With Spam 286
Comment Moderation and CAPTCHAs 286
Automating Spam Detection 287
Securing Your WordPress Site 288
Stay Up-to-Date 288
Hiding WordPress Version Information 289
Don’t Use the Admin Account 289
Change Your Table Prefix 290
Move Your Configuration File 290
Move Your Content Directory 290
Use the Secret Key Feature 291
Force SSL on Login and Admin 291
Apache Permissions 291
MySQL Credentials 292
Recommended Security Plugins 292
WP Security Scan 292
WordPress Exploit Scanner 292
WordPress File Monitor 293
Using WordPress Roles 294
Subscriber Role 295
Contributor Role 295
Author Role 295
Editor Role 295
Administrator Role 296
xxi
CONTENTS
Role Overview 296
Extending Roles 297
CHAPTER 12: WORDPRESS AS A CONTENT MANAGEMENT SYSTEM 299
Defining Content Management 299

Workflow and Delegation 301
User Roles and Delegation 301
Workflow 302
Content Organization 303
Theme and Widget Support 304
Homepages 305
Featured Content Pages 306
Content Hierarchy 308
Interactivity Features 312
Forums 312
Forms 313
E-Commerce 313
Other Content Management Systems 313
WordPress Integration 314
Where Not to Use WordPress 314
CHAPTER 13: WORDPRESS IN THE ENTERPRISE 317
Is WordPress Right for Your Enterprise? 317
When WordPress Isn’t Right for You 319
Scalability 319
Performance Tuning 320
Caching 321
Regular Maintenance 322
Hardware Scaling 322
Integration with Enterprise Identity Management 324
LDAP and Active Directory 324
OpenID 325
Content Integration via Feeds 326
CHAPTER 14: MIGRATING TO WORDPRESS 329
Planning a Migration 330
Content Sources 330

Migration Checklist 331
Site Preparation 332
xxii
CONTENTS
Content Identification 332
Migrating Text Documents 333
Built-In WordPress Import Tools 333
Blog Conversion 333
Using WordPress eXtended RSS Files 334
Building a Custom Import Script 335
Media Migration 344
Moving Metadata 345
Moving Authors and Users 345
Theme and Presentation 346
Unique Functionality 346
Cleaning Up 346
Manual Fine-Tuning 347
Import Limitations 347
Updating URLs 347
Redirection 348
Launching 349
CHAPTER 15: WORDPRESS DEVELOPER COMMUNITY 351
Contributing to WordPress 351
Understanding Trac 351
Bug Reporting 352
Trac Keywords 353
View and Search Tickets 353
Trac Timeline 354
Browsing Source 354
Working on the Core 355

Understanding Subversion (SVN) 355
Hook into WordPress Core 355
Create a patch/diff File 355
Submitting Plugins and Themes 356
Documentation 356
Sister Projects 357
WordPress MU 357
BuddyPress 357
bbPress 357
Future Projects 358
Resources 358
Codex 358
Support Forums 358
xxiii

×