Join the discussion @ p2p.wrox.com Wrox Programmer to Programmer™ProfessionalWordPress®Design and Development Hal Stern, David Damstra, Brad Williams
Programmer to Programmer™Get more out of wrox.comInteract Join the CommunityTake an active role online by participating in our Sign up for our free monthly newsletter atP2P forums @ p2p.wrox.com newsletter.wrox.comWrox Online Library BrowseHundreds of our books are available online Ready for more Wrox? We have books andthrough Books24x7.com e-books available on .NET, SQL Server, Java, XML, Visual Basic, C#/ C++, and much more!Wrox BloxDownload short informational pieces and codeto keep you up to date and out of trouble!Contact Us.We always like to get feedback from our readers. Have a book idea?Need community support? Let us know by e-mailing [email protected]
PROFESSIONAL WORDPRESS®INTRODUCTION ................................................................ xxvCHAPTER 1 First Post .............................................................................................. . . . . . . . . . . 1CHAPTER 2 Functional Overview ........................................................................ . . . . . . . . 19CHAPTER 3 Code Overview . ................................................................................. . . . . . . . . 49CHAPTER 4 Tour of the Core . . ............................................................................. . . . . . . . . 65CHAPTER 5 The Loop .............................................................................................. . . . . . . . . 79CHAPTER 6 Data Management . ........................................................................... . . . . . . . 103CHAPTER 7 Plugin Development ........................................................................ . . . . . . . . 121CHAPTER 8 Theme Development . ...................................................................... . . . . . . . 183CHAPTER 9 Content Aggregation . ...................................................................... . . . . . . . 229CHAPTER 10 Crafting a User Experience . ........................................................... . . . . . . . 249CHAPTER 11 Statistics, Scalability, Security, and Spam . .................................. . . . . . . . 273CHAPTER 12 WordPress as a Content Management System . ....................... . . . . . . . 299CHAPTER 13 WordPress in the Enterprise . ......................................................... . . . . . . . 317CHAPTER 14 Migrating To WordPress . ................................................................ . . . . . . . 329CHAPTER 15 WordPress Developer Community . ............................................. . . . . . . . 351INDEX . ........................................................................ 365 wwwwww.wwo.wwoewbeobooko.kc.ocmom
PROFESSIONALWordPress®
PROFESSIONAL WordPress® DESIGN AND DEVELOPMENTHal Stern, David Damstra, and Brad Williams Wiley Publishing, Inc.
Professional WordPress®: Design and DevelopmentPublished byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.comCopyright © 2010 by Wiley Publishing, Inc., Indianapolis, IndianaPublished by Wiley Publishing, Inc., Indianapolis, IndianaPublished simultaneously in CanadaISBN: 978-0-470-56054-9Manufactured in the United States of America10 9 8 7 6 5 4 3 2 1No 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 the1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization throughpayment 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 athttp://www.wiley.com/go/permissions.Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect tothe accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitationwarranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. Theadvice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that thepublisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, theservices of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damagesarising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source offurther information does not mean that the author or the publisher endorses the information the organization or Web site mayprovide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may havechanged 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 UnitedStates 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 inelectronic books.Library of Congress Control Number: 2010921230Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarksor registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may notbe used without written permission. WordPress is a registered trademark of Automattic, Inc. All other trademarks are theproperty 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 SternTo 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.
CREDITSEXECUTIVE EDITOR VICE PRESIDENT AND EXECUTIVE GROUP PUBLISHERCarol Long Richard SwadleyPROJECT EDITOR VICE PRESIDENT AND EXECUTIVEBrian MacDonald PUBLISHERTECHNICAL EDITOR Barry PruettMike Little ASSOCIATE PUBLISHERPRODUCTION EDITOR Jim MinatelDaniel Scribner PROJECT COORDINATOR, COVERCOPY EDITOR Lynsey StanfordKim Cofer PROOFREADEREDITORIAL DIRECTOR Publication Services, Inc.Robyn B. Siesky INDEXEREDITORIAL MANAGER Robert SwansonMary Beth Wakefield COVER DESIGNERASSOCIATE DIRECTOR OF MARKETING Michael E. TrentDavid Mayhew COVER IMAGEPRODUCTION MANAGER © Karen Phillips/istockphotoTim Tate
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
Search
Read the Text Version
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
- 313
- 314
- 315
- 316
- 317
- 318
- 319
- 320
- 321
- 322
- 323
- 324
- 325
- 326
- 327
- 328
- 329
- 330
- 331
- 332
- 333
- 334
- 335
- 336
- 337
- 338
- 339
- 340
- 341
- 342
- 343
- 344
- 345
- 346
- 347
- 348
- 349
- 350
- 351
- 352
- 353
- 354
- 355
- 356
- 357
- 358
- 359
- 360
- 361
- 362
- 363
- 364
- 365
- 366
- 367
- 368
- 369
- 370
- 371
- 372
- 373
- 374
- 375
- 376
- 377
- 378
- 379
- 380
- 381
- 382
- 383
- 384
- 385
- 386
- 387
- 388
- 389
- 390
- 391
- 392
- 393
- 394
- 395
- 396
- 397
- 398
- 399
- 400
- 401
- 402
- 403
- 404
- 405
- 406
- 407
- 408
- 409
- 410
- 411
- 412