Developing plugins for WordPress is the next big thing for you if you are an administrator looking to enhance a personal site with custom functionality for which no plugin exists, a developer looking to enhance the WordPress platform with new ideas for the community, or a website designer building a specific project for a client. Learning how to create WordPress plugins will allow you to unleash the full potential of the most popular web content management system.
As an early WordPress adopter, I started building plugins to add functionality to my personal site. Once I got these new elements in place, I quickly realized that other users could benefit from these extensions, and started distributing them online. To this day, I always love hearing back from users of my creations and finding out how they have put them to use and what new functionality they think would make them even better.
While developing plugins might initially sound a little bit like black magic, this book shows you how easy creating plugins actually is through a series of step-by-step recipes. If you have previously added code to a theme's functions file, you may even be familiar with some of the mechanics explained in this book. With all of the information contained in this book, you will quickly be able to create your own plugins or dissect existing ones to add that extra bit of missing functionality that you require. Before you know, you'll be publishing your own creations to the official WordPress plugin repository!
Let's start learning how to cook up great WordPress plugins!
Chapter 1, Preparing a Local Development Environment, shows plugin developers how to install and configure an efficient development environment.
Chapter 2, Plugin Framework Basics, explains the basic mechanics of registering user functions with WordPress to be executed at key points when web pages are displayed, forming the basis of plugin creation.
Chapter 3, User Settings and Administration Pages, covers the creation of administration pages that will allow the users to configure the plugins you create.
Chapter 4, The Power of Custom Post Types, empowers developers to add whole new content management sections to the WordPress environment.
Chapter 5, Customizing Post and Page Editors, demonstrates how to alter the default administration post and page editing environment to add new capabilities.
Chapter 6, Accepting User Content Submissions, allows users to submit their own content to new content sections that will be managed by your plugins.
Chapter 7, Creating Custom MySQL Database Tables, leverages the power of MySQL to create custom database tables in a site database to store and retrieve custom data.
Chapter 8, Leveraging JavaScript, jQuery, and AJAX Scripts, makes plugin output very dynamic by using a number of popular script libraries.
Chapter 9, Adding New Widgets to the WordPress Library, indicates how to add new widgets that users will be able to easily drag-and-drop to add content to their web pages.
Chapter 10, Enabling Plugin Internationalization, prepares your plugin to be translated to any language to make it easier to be used by non-English speakers.
Chapter 11, Distributing Your Plugin on wordpress.org, shows you how to prepare your plugin for sharing with the global WordPress community.
Chapter 1, Preparing a Local Development Environment, walks you through all of the tools that are useful to have when developing plugins for WordPress, including XAMPP, TortoiseSVN, and NetBeans.
While this book will always describe all of the steps necessary to perform its recipes, having a good understanding of WordPress will allow you to fully appreciate the information contained in these pages.
This book is for WordPress users, developers, or site integrators with basic knowledge of PHP and an interest in creating new plugins to address their personal needs, client needs, or share new ideas with the WordPress community.
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: "Save and close the httpd.conf
file."
A block of code is set as follows:
add_settings_field( 'Select_List', 'Select List', 'ch3sapi_select_list', 'ch3sapi_settings_section', 'ch3sapi_main_section', array( 'name' => 'Select_List', 'choices' => array( 'First', 'Second', 'Third' ) ) );
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
<h2>My Google Analytics</h2>
<?php if ( !empty( $_GET['message'] ) ) { ?>
<div id="message" class="updated fade"><p><strong>Settings Saved </strong></p></div>
<?php } ?>
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: "Click on the Settings section of the administration menu."
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 through the subject of your message.
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 to our website, or added to any list of existing errata, under the Errata section of that title.
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.