PacktLib: WordPress Plugin Development Cookbook

WordPress Plugin Development Cookbook

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

Preparing a Local Development Environment

Introduction

Installing a web server on your computer

Downloading and configuring a local WordPress installation

Creating a local Subversion repository

Importing initial files to a local Subversion repository

Checking out files from a Subversion repository

Committing changes to a Subversion repository

Reverting uncommitted file changes

Viewing file history and reverting content changes to older revisions

Installing a dedicated code/text editor

Installing and configuring the NetBeans Integrated Development Environment

Interacting with a Subversion repository from the NetBeans interface

Managing a MySQL database server from the NetBeans interface

Plugin Framework Basics

Introduction

Creating a plugin file and header

Adding output content to page headers using plugin actions

Using WordPress path utility functions to load external files and images

Modifying the page title using plugin filters

Adding text after each item's content using plugin filters

Inserting link statistics tracking code in page body using plugin filters

Troubleshooting coding errors and printing variable content

Creating a new simple shortcode

Creating a new shortcode with parameters

Creating a new enclosing shortcode

Loading a stylesheet to format plugin output

Writing plugins using object-oriented PHP

User Settings and Administration Pages

Introduction

Creating default user settings on plugin initialization

Storing user settings using arrays

Removing plugin data on deletion

Creating an administration page menu item in the Settings menu

Creating a multi-level administration menu

Hiding items which users should not access from the default menu

Rendering the admin page contents using HTML

Processing and storing plugin configuration data

Displaying a confirmation message when options are saved

Adding custom help pages

Rendering the admin page contents using the Settings API

Accessing user settings from action and filter hooks

Formatting admin pages using meta boxes

Splitting admin code from the main plugin file to optimize site performance

Storing stylesheet data in user settings

The Power of Custom Post Types

Introduction

Creating a custom post type

Adding a new section to the custom post type editor

Displaying single custom post type items using custom templates

Creating an archive page for custom post types

Displaying custom post type data in shortcodes

Adding custom categories for custom post types

Hiding the category editor from the custom post type editor

Displaying additional columns in the custom post list page

Adding filters for custom categories to the custom post list page

Updating page title to include custom post data using plugin filters

Customizing Post and Page Editors

Introduction

Adding extra fields to the post editor using custom meta boxes

Displaying custom post data in theme templates

Hiding the Custom Field section in the post editor

Extending the post editor to allow users to upload files directly

Accepting User Content Submissions

Introduction

Creating a client-side content submission form

Saving user-submitted content in custom post types

Sending e-mail notifications upon new submissions

Implementing a captcha on user forms

Creating Custom MySQL Database Tables

Introduction

Creating new database tables

Deleting custom tables on plugin removal

Updating custom table structure on plugin upgrade

Displaying custom table data in an admin page

Inserting and updating records in custom tables

Deleting records from custom tables

Displaying custom database table data in shortcodes

Implementing a search function to retrieve custom table data

Importing data from a user file into custom tables

Leveraging JavaScript, jQuery, and AJAX Scripts

Introduction

Safely loading jQuery onto WordPress web pages

Displaying a pop-up dialog using the built-in ThickBox plugin

Controlling pop-up dialog display using shortcodes

Displaying a calendar day selector using the Datepicker plugin

Adding tooltips to admin page form fields using the TipTip plugin

Using AJAX to dynamically update partial page contents

Adding New Widgets to the WordPress Library

Introduction

Creating a new widget in WordPress

Displaying configuration options

Validating configuration options

Implementing the widget display function

Adding a custom dashboard widget

Enabling Plugin Internationalization

Introduction

Changing the WordPress language configuration

Adapting default user settings for translation

Making admin page code ready for translation

Modifying shortcode output for translation

Translating text strings using Poedit

Loading a language file in the plugin initialization

Distributing Your Plugin on wordpress.org

Introduction

Creating a readme file for your plugin

Applying for your plugin to be hosted on wordpress.org

Uploading your plugin using Subversion

Providing a plugin banner image