395 394
396 395
397 396
398 397
399 398
400 399
401 400
402 401
403 402
404 403
405 404
406 405
407 406
408 407
409 408
410 409
411 410
412 411
413 412
414 413
415 414
416 415
417 416
418 417
419 418
420 419
421 420
422 421
423 422
424 423
425 424
426 425
427 426
428 427
429 428
430 429
431 430
432 431
433 432
434 433
435 434
436 435
437 436
438 437
439 438
440 439
441 440
442 441
443 442
444 443
445 444
446 445
447 446
448 vi
449 vii
450 ix
451 xi
452 447
PROFESSIONAL WORDPRESS® PLUGIN DEVELOPMENT
Second Edition
Brad Williams
Justin Tadlock
John James Jacoby
FOREWORD
This book will teach you how to develop for WordPress. WordPress has, over the past two decades, grown into the CMS that powers more than one‐third of all websites. If you're proficient at WordPress development, you'll never be out of a job again.
Starting out as a simple blogging system, over the last few years WordPress has morphed into a fully featured and widely used content management system. It offers individuals and companies worldwide a free and open source alternative to closed source and often very expensive systems.
When I say fully featured, that's really only true because of the ability to add any functionality needed in the form of a plugin. The core of WordPress is simple: you add in functionality with plugins as you need it. Developing plugins allows you to stand on the shoulders of a giant: you can showcase your specific area of expertise and help users benefit while not having to deal with parts of WordPress you don't care or know about.
When I wrote the foreword of this book's first edition, nine years ago, I'd just started my own company. That company has since grown to consist of 100+ people, and our plugins are used on more than 10 million sites—all through the power of open source and plugins.
I wished that when I started developing plugins for WordPress as a hobby, almost 15 years back, this book had been around. I used it as a reference countless times since, and I still regularly hand this book to new colleagues.
The authors of this book have always been a source of good information and wonderful forces in the WordPress community. Each of them is an expert in his own right; together they are one of the best teams that could have been gathered to write this book, and I'm glad they're here for a second edition.
WordPress makes it easy for people to have their say through words, sound, and visuals. For those who write code, WordPress allows you to express yourself in code. And it's simple. Anyone can write a WordPress plugin. With this guide in hand, you can write a plugin that is true to WordPress’ original vision: code is poetry.
Happy coding!
Joost de Valk
Yoast.com
INTRODUCTION
Dear reader, thank you for picking up this book! You have probably heard about WordPress already, the most popular self‐hosted content management system (CMS) and blogging software in use today. WordPress powers literally millions of websites on the Internet, including high‐profile sites such as TechCrunch and multiple Microsoft websites. What makes WordPress so popular is that it's free, open source, and extendable beyond limits. Thanks to a powerful, architecturally sound, and easy‐to‐use plugin system, you can customize how WordPress works and extend its functionalities. There are already more than 55,000 plugins freely available in the official plugin repository, but they won't suit all your needs or client requests. That's where this book comes in handy!
As of this writing, we (Brad, Justin, and John) have publicly released more than 100 plugins, which have been downloaded millions of times, and that's not counting private client work. This is a precious combined experience that we are going to leverage to teach you how to code your own plugins for WordPress by taking a hands‐on approach with practical examples and real‐life situations you will encounter with your clients.
The primary reason we wanted to write this book is to create a preeminent resource for WordPress plugin developers. When creating plugins for WordPress, it can be a challenge to find the resources needed in a single place. Many of the online tutorials and guides are outdated and recommend incorrect methods for plugin development. This book is one of the most extensive collections of plugin development information to date and should be considered required reading