By picking up this book, there's a good chance that you fall into one of two categories: an existing WordPress user / hobbyist programmer who is interested in building your own plugins for the platform, or a seasoned developer who is new to WordPress and need to complete a project for a client.
In either case, this book is designed to help you along the way. If you can code your own plugins, you can make WordPress do just about anything. By learning how to tap into the additional power and functionality that plugins provide, you can make your site easier to administer, add new features, or even alter the very nature of how WordPress works. Written with the WordPress version 3 in mind, this book will show you how to build a variety of plugins that demonstrate the additional power available to you as a plugin author.
Throughout this book, our goal is to teach you all aspects of modern WordPress development. We will build a variety of WordPress plugins and follow their creation from the idea to the finishing touches. You will discover how to deconstruct an existing plugin, use the WordPress API in typical scenarios, hook into the database, version your code with SVN, and deploy your new plugin to the world.
We have plenty of work to do, so let's get started!
Chapter 1, Preparing for WordPress Development, provides an overview of the development process and discusses a number of tools and practices recommended for a successful WordPress development environment.
Chapter 2, Anatomy of a Plugin, breaks an existing plugin down into its component parts to see what makes it work, and what makes it break.
Chapter 3, Social Bookmarking, walks through the development of an initial plugin, including how to tie into the WordPress API, how to trigger functions, and how to include external JavaScript files.
Chapter 4, Ajax Search, covers the construction of a plugin that augments WordPress' built-in search capability. This chapter provides details on how to utilize Ajax and JQuery, as well as how to use the PHP library classes with static functions in our plugins.
Chapter 5, Content Rotator, explores the wonderful world of WordPress widgets. In this chapter we will show you how to build and manipulate a widget, as well as how to construct a personal preference page for your plugin.
Chapter 6, Standardized Custom Content, begins the process of extending WordPress' usage as a content management system. We will cover how to alter and extend custom fields and how to display custom content in your templates.
Chapter 7, Custom Post Types, continues the discussion on extending WordPress as a CMS. We will also discuss working with shortcodes, and how to customize your plugin by creating custom menus and administration panels in the Dashboard.
Chapter 8, Versioning Your Code with Subversion (SVN), shows you how to maintain and manage your plugin code with a version control system.
Chapter 9, Preparing Your Plugin for Distribution, takes the next logical step in making sure your shiny new plugins are ready for the wider world. We will discuss how to avoid certain pitfalls by writing custom tests to check for failure points.
Chapter 10, Publishing Your Plugin, covers the mechanics of officially making your masterpiece available to the public, including the topics of internationalization, using the WordPress SVN repository, and handling the ubiquitous readme.txt
file.
Appendix A, Recommended Resources, lists some of our favorite websites, books, and other resources for seeking additional knowledge or getting help with a specific problem.
Appendix B, WordPress API Reference, provides a compendium of functions, actions, and filters referenced in this book.
To develop plugins for WordPress, all you really need is a text editor, a working installation of WordPress, and your favorite (s)FTP program. Other tools, such as a MySQL editor, can make your life easier, but are optional.
This book is for WordPress users who want to learn how to create their own plugins and for developers who are new to the WordPress platform. Basic knowledge of PHP and HTML is expected, as well as a functional knowledge of how WordPress works from a user standpoint.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "We can include other contexts through the use of the include
directive."
A block of code is set as follows:
<h3 class="widget-title">Built In WordPress Search Widget</h3> <form role="search" method="get" id="searchform" action="http://localhost:8888/" > <div> <label class="screen-reader-text" for="s">Search for:</label> <input type="text" value="" name="s" id="s" /> <input type="submit" id="searchsubmit" value="Search" /> </div>
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
/*
Theme Name: Twenty Ten v2
Theme URI: http://wordpress.org/
Any command-line input or output is written as follows:
svn checkout https://my-unique-project-name.googlecode.com/svn/trunk/ --username mygoogleid
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: " Under the Hello Dolly title, click on the Activate link.".
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>
.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.