Book Image

WordPress Plugin Development: Beginner's Guide

Book Image

WordPress Plugin Development: Beginner's Guide

Overview of this book

If you can write WordPress plug-ins, you can make WordPress do just about anything. From making the site easier to administer, to adding the odd tweak or new feature, to completely changing the way your blog works, plug-ins are the method WordPress offers to customize and extend its functionality. This book will show you how to build all sorts of WordPress plug-ins: admin plug-ins, Widgets, plug-ins that alter your post output, present custom "views" of your blog, and more. WordPress Plug-in Development (Beginner's Guide) focuses on teaching you all aspects of modern WordPress development. The book uses real and published WordPress plug-ins and follows their creation from the idea to the finishing touches, in a series of carefully picked, easy-to-follow tutorials. You will discover how to use the WordPress API in all typical situations, from displaying output on the site in the beginning to turning WordPress into a CMS in the last chapter. In Chapters 2 to 7 you will develop six concrete plug-ins and conquer all aspects of WordPress development. Each new chapter and each new plug-in introduces different features of WordPress and how to put them to good use, allowing you to gradually advance your knowledge. This book is written as a guide to take your WordPress skills from the very beginning to the level where you are able to completely understand how WordPress works and how you can use it to your advantage.
Table of Contents (14 chapters)
WordPress Plugin Development
Credits
About the Author
About the Reviewer
Preface
Index

Preface

If you can write WordPress plugins, you can make WordPress do just about anything. From making the site easier to administer, to adding the odd tweak or new feature, to completely changing the way your blog works; plugins are the method WordPress offers to customize and extend its functionality. This book will show you how to build all sorts of WordPress plugins: admin plugins, Widgets, plugins that alter your post output, present custom "views" of your blog, and more.

This book focuses on teaching you all aspects of modern WordPress development and usage. The book uses real and published WordPress plugins and follows their creation from the idea to the finishing touches, in a series of carefully picked, easy-to-follow tutorials. You will discover how to use the WordPress API in all typical situations, from displaying output on the site in the beginning to turning WordPress into a CMS in the last chapter. In Chapters 2 to 7, you will develop six concrete plugins and conquer all aspects of WordPress plugin development.

Each new chapter and each new plugin introduces different features of WordPress and how to put them to good use, allowing you to gradually advance your knowledge. This book is written as a guide to take your WordPress skills from the very beginning to the level where you are able to completely understand how WordPress works and how you can use it to your advantage.

This is a Packt Beginners Guide, which means it focuses on practical examples and has a fast-paced but friendly approach, with the opportunity to learn by experimentation and play. Each chapter builds a practical plugin from the ground up using step-by-step instructions. Individual sections show you how to code some functionality into your plugin and follow up with a discussion of concepts.

What This Book Covers

Chapter 1 teaches the advantages of WordPress development, and what WordPress has to offer to plugin authors.

Chapter 2 creates a working, useful, and attractive WordPress plugin from scratch. It shows how to extract information using the WordPress API and how to use CSS to improve the look of our plugin.

Chapter 3 explores more cool things we can do with WordPress by livening up the default WordPress blogroll. The purpose of the plugin is to display the most recent posts from the sites listed in the blogroll using a nice pop-up window.

Chapter 4 uses the mixed approach, by taking advantage of creative WordPress and JavaScript techniques, in order to create an Ajax powered 'Wall’ for your blog’s sidebar. It introduces quite a few interesting techniques such as Widgets, interacting with the WordPress Database, and Ajax form submission.

Chapter 5 covers the creation of a very sleek and stylish looking WordPress enhancement. The purpose of the Snazzy Archives plugin will be to present your site archives in a unique visual way. It shows how to manipulate the layout of the template using shortcodes and custom templates.

Chapter 6 is all about digging a little deeper into WordPress and hacking the Write Post screen. It shows how to create custom panels in the various sections of the Write Post screen. It teaches how to access the current WordPress rich text editor, tinyMCE, and create a button on its toolbar.

Chapter 7 explores the possibilities of turning WordPress into a Content Management System (CMS), using methods provided to us by WordPress. It shows how to modify the Manage Posts panel to display the information we want. It also covers managing who can use your plugin by looking at the logged in user capabilities.

Chapter 8 covers the additional steps involved in localizing, documenting, publishing, and promoting your plugin. It also covers useful tips and ideas to improve your general WordPress knowledge further.

Who is This Book For

This book is for programmers working with WordPress, who want to develop custom plugins and to hack the code base. You need to be familiar with the basics of WordPress and PHP programming and believe that code is poetry; this book will handle the rest.

Conventions

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: "Edit the insights.js file and add the functionality to insert the HTML directly into tinyMCE."

A block of code will be set as follows:

/* Add Digg link to the end of the post */
function WPDiggThis_ContentFilter($content)
{
return $content.WPDiggThis_Link();
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be made bold:

<?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>’); ?>
<?php if (function_exists(WPDiggThis_Link)) echo WPDiggThis_Link(); ?>

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this:

"Go to your WordPress Plugins admin panel."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader Feedback

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 drop an email to , making sure to mention the book title in 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 email .

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.

Customer Support

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.

Downloading the Example Code for the Book

Visit http://www.packtpub.com/files/code/3599_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata are added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

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 the location address or website name immediately so we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address it.