Professional WordPress Plugin Development

Full Table of Content

Chapter 0: Foreword by a very famous WordPress rockstar

Chapter 1: An Introduction to Plugins

What Is a Plugin?

  • How Plugins Interact with WordPress
  • When Are Plugins Loaded?

Available Plugins

  • Official Plugin Directory
  • Popular Plugin Examples
  • Popular Plugin Tags

Advantages of Plugins

  • Not Modifying Core
  • Why Reinvent the Wheel
  • Separating Plugins and Themes
  • Easy Updates
  • Easier to Share and Reuse
  • Plugin Sandbox
  • Plugin Community

Installing and Managing Plugins

  • Installing a Plugin
  • Managing Plugins
  • Editing Plugins
  • Plugin Directories
  • Types of Plugins
  • Testing Plugin Functionality

Summary

Chapter 2: Plugin Foundation

Creating a Plugin File

  • Naming Your Plugin
  • Using a Folder

Sanity Practices

  • Prefix Everything
  • File Organization
  • Folder Structure

Header Requirements

  • Creating the Header
  • Plugin License

Determining Paths

  • Plugin Paths
  • Local Paths
  • URL Paths

Activate/Deactivate Functions

  • Plugin Activation Function
  • Create Default Settings on Activate
  • Plugin Deactivation Function
  • Deactivate Is Not Uninstall

Uninstall Methods

  • Why Uninstall Is Necessary
  • Uninstall.php
  • Uninstall Hook

Coding Standards

  • Document Your Code
  • Naming Variables, Functions, and Files
  • Single and Double Quotes
  • Indentation
  • Brace Style
  • Space Usage
  • Shorthand PHP
  • SQL Statements

Plugin Development Checklist

Summary

Chapter 3: Hooks

Actions

  • What Is an Action?
  • Action Hook Functions
  • Commonly Used Action Hooks

Filters

  • What Is a Filter?
  • Filter Hook Functions
  • Quick Return Functions
  • Commonly Used Filter Hooks

Using Hooks from Within a Class

Creating Custom Hooks

  • Benefits of Creating Custom Hooks
  • Custom Action Hook Example
  • Custom Filter Hook Example

How to Find Hooks

  • Searching for Hooks in the Core Code
  • Variable Hooks
  • Hook Reference Lists

Summary

Chapter 4: Integrating in WordPress

Adding Menus and Submenus

  • Creating a Top-Level Menu
  • Adding a Submenu
  • Adding a Menu Item to an Existing Menu

Creating Widgets

  • Creating a Widget
  • Advanced Widget
  • Creating Dashboard Widgets
  • Creating a Dashboard Widget with Options

Meta Boxes

  • What Is a Meta Box?
  • Adding a Custom Meta Box
  • Saving Meta Box Data
  • Advanced Meta Box

Keeping It Consistent

  • Using the WordPress UI
  • Headings
  • Icons
  • Messages
  • Buttons
  • Links
  • Form Fields
  • Tables
  • Pagination

Summary

Chapter 5: Internationalization

Internationalization and Localization

  • Why Internationalize?
  • Understanding Internationalization in Professional Work
  • Getting Your Plugin Ready for Translation
  • Echoing and Returning Strings
  • Using Placeholders
  • Internationalizing JavaScript

Creating Translation Files

  • The MO and PO Files
  • Translation Tools
  • How to Create a POT File
  • Where to Store Translation Files

Summary

Chapter 6: Plugin Security

Securing Your Plugin

  • What Securing Your Plugin Is
  • What Securing Your Plugin Is Not

User Permissions

  • How to Check current_user_can
  • Do Not Check Too Early

Nonces

  • Authority Versus Intention
  • What Is a Nonce?
  • How to Create and Verify Nonces
  • Nonces in AJAX Scripts

Data Validation and Sanitization

  • The Need for Data Validation and Sanitization
  • Good Practice: Identifying Potentially Tainted Data
  • Validating or Sanitizing Input?
  • Validating and Sanitizing Cookbook

Formatting SQL Statements

  • The $wpdb Object
  • Why wpdb Methods Are Superior
  • All-in-One Methods
  • Common Methods
  • Protecting Queries Against SQL Injections
  • Miscellaneous wpdb Methods and Properties

Security Good Habits

Summary

Chapter 7: Plugin Settings

The Options API

  • Saving Options
  • Saving an Array of Options
  • Retrieving Options
  • Loading an Array of Options
  • Deleting Options
  • The Autoload Parameter

The Settings API

  • Benefits of the Settings API
  • Settings API Functions
  • Wrapping It Up: A Complete Plugin Management Page
  • Improving Feedback on Validation Errors
  • Adding Fields to an Existing Page

The Transients API

  • Saving an Expiring Option
  • Retrieving an Expiring Option
  • Deleting an Expiring Option
  • A Practical Example Using Transients
  • Technical Details and Tip
  • Transient Ideas

Saving Per-User Settings

  • Craft a Plugin
  • User Metadata
  • Saving User Metadata
  • Updating User Metadata
  • Getting User Metadata
  • Deleting User Metadata
  • Getting a User’s ID
  • Adding Input Fields to a Profile Page
  • BOJ’s Admin Lang Plugin
  • Per-User Settings: Best Practices

Storing Data in Custom Tables

  • Types of Data
  • WordPress’ Standard Tables
  • Creating a Custom Table
  • Updating the Structure of a Custom Table
  • dbDelta() Tips for Success
  • Accessing Your Custom Table

Summary

Chapter 8: Users

Working with Users

  • User Functions
  • Creating, Updating, and Deleting Users
  • User Data
  • User Metadata

Roles and Capabilities

  • What Are Roles and Capabilities?
  • Default Roles
  • Custom Roles

Limiting Access

  • Checking User Permissions
  • Is the User an Admin?
  • Allowing Custom Permissions

Customizing Roles

  • Creating a Role
  • Deleting a Role
  • Adding Capabilities to a Role
  • Removing Capabilities from a Role
  • A Custom Role and Capability Plugin

Summary

Chapter 9: HTTP API

HTTP Requests Crash Course

  • What Is an HTTP Request?
  • How to Make HTTP Requests in PHP

WordPress’ HTTP Functions

  • The wp_remote_ Functions
  • Advanced Configuration and Tips

Practice: Reading JSON from a Remote API

  • Getting and Reading JSON
  • Your Functional Plugin

Practice: Sending Data to a Remote API

  • Formatting Parameters for POST Requests
  • Your Functional Plugin

Practice: Reading Arbitrary Content

Make Your Own Plugin Repository

  • How Plugin Upgrades Work in WordPress
  • Polling an Alternative API from a Plugin
  • Building the Alternative API
  • A Few Words of Caution About Self-Hosted API

Special Case: Fetching Remote Feeds

Summary

Chapter 10: The Shortcode API

Creating Shortcodes

  • What Shortcodes Are
  • Register Custom Shortcodes

Shortcode Tips

  • Think Simplicity for the User
  • Remember the Dynamicity
  • Look Under the Hoods
  • A “bb code” for Comments Plugin
  • Shortcode Nesting Limitations

Integrating Google Maps

  • Accessing the Google Geocoding API
  • Storing API Results
  • Accessing the Google Maps API

More Shortcode Quick Ideas

  • Display Member-Only Content
  • Display Time-Limited Content
  • Obfuscate Email Addresses

Summary

Chapter 11: Extending Posts: Meta Data, Custom Post Types, and Taxonomies

Creating Custom Post Types

  • Post Type Possibilities
  • Registering a Post Type
  • Setting Post Type Labels
  • Using Custom Capabilities
  • Attaching Existing Taxonomies

Using Custom Post Types

  • Creating a Custom Post Type Loop
  • Retrieving Custom Post Type Content
  • Checking if Post Type Exists

Post Meta Data

  • Adding Post Meta Data
  • Retrieving Post Meta Data
  • Updating Post Meta Data
  • Deleting Post Meta Data

Creating Custom Taxonomies

  • Understanding Taxonomies
  • Registering a Custom Taxonomy
  • Assigning a Taxonomy to a Post Type

Using Custom Taxonomies

  • Retrieving a Taxonomy
  • Using a Taxonomy with Posts
  • Taxonomy Conditional Tags

A Post Type and Taxonomy Plugin

Summary

Chapter 12: JavaScript and Ajax in WordPress

jQuery–A Brief Introduction

  • Benefits of Using jQuery
  • jQuery Crash Course

Ajax

  • What Is Ajax?
  • Ajax Best Practices

Adding JavaScript in WordPress

  • A Proper Way to Include Scripts
  • Where to Include Scripts
  • Adding Scripts Only When Needed
  • Dynamic Scripts in WordPress

Ajax in WordPress

  • Ajax in WordPress: Principles
  • A Complete Example: Instant “Read More” Links
  • Another Example: Frontend Comment Deletion
  • Debugging Ajax

Summary

Chapter 13: Cron

What Is Cron?

  • How Is Cron Executed?

Scheduling Cron Events

  • Scheduling a Recurring Event
  • Scheduling a Single Event
  • Unscheduling an Event
  • Specifying Your Own Cron Intervals
  • Viewing Cron Events Scheduled

True Cron

Practical Use

  • Deleting Post Revisions Weekly
  • The Blog Pester Plugin
  • The Delete Comments Plugin

Summary

Chapter 14: The Rewrite API

Why Rewrite URLs

  • Permalinks Principles
  • Apache’s mod_rewrite
  • URL Rewriting in WordPress

How WordPress Handles Queries

  • Overview of the Query Process
  • The rewrite Object
  • The query Object
  • What Plugins Can Do

Practical Uses

  • Rewriting a URL to Create a List of Shops
  • Creating a New Permalink Structure and Integrating Non-WordPress Pages
  • Adding an Endpoint and Altering Output Format
  • Adding a Custom Feed for the Latest Uploaded Images

Summary

Chapter 15: Multisite

Differences

  • WordPress Versus Multisite Network
  • Understanding Multisite Terminology
  • Advantages of Multisite

Enabling Multisite in WordPress

Multisite Functions

  • The Power of Blog ID
  • Common Functions
  • Switching and Restoring Sites
  • Network Content Shortcode Examples
  • A Network Content Widget Example
  • Creating a New Site
  • Multisite Site Options
  • Users in a Network
  • Multisite Super Admin
  • Checking the Site Owner
  • Network Stats

Multisite Database Schema

  • Multisite-Specific Tables
  • Site-Specific Tables

Summary

Chapter 16: Debugging and Optimizing

Supporting Old Versions (Not)

  • Keeping Current with WordPress Development
  • Deprecated Functions
  • Dealing with Obsolete Client Installs

Debugging

  • Enabling Debugging
  • Displaying Debug Messages
  • Correcting Debug Messages

Error Logging

  • Enabling Logging
  • Setting Log File Location
  • Understanding the Log File

Caching

  • Saving, Loading, and Deleting Cached Data
  • Caching Data Within a Plugin

Summary

Chapter 17: Marketing Your Plugin

Choosing a License for Your Plugin

  • Different Options
  • Why It Matters
  • Making Money While Using the GPL

Submitting to WordPress.org

  • Creating an Account
  • Submitting a Plugin
  • Setting Up SVN
  • Creating a readme.txt File

Getting Your Plugin Renowned

  • Naming Your Plugin
  • Building a Web Site
  • Creating a Page for Your Plugin
  • Announcing Your Plugin
  • Supporting Your Plugins
  • Getting Feedback
  • Getting Out of the Basement
  • Other Promotion Methods

Summary

Chapter 18: The Developer Toolbox

Core as Reference

  • Inline Documentation
  • Finding Functions
  • Common Core Files

Codex

  • Searching the Codex
  • Function Reference

Tool Web Sites

  • PHPXref
  • Hooks Database

Community Resources

  • Support Forums
  • Mailing Lists
  • WordPress Chat
  • WordPress Development Updates
  • WordPress Ideas
  • Community News Sites
  • Local Events

Tools

  • Browser
  • Editor
  • Deploying Files with FTP, SFTP, and SSH
  • phpMyAdmin

Summary

4 comments

  1. Xavier

    Sounds hefty, but tasty :)
    Can't wait to have a look at it!

  2. Maor Barazany

    Just ordered the book on Amazon. Looking forward to getting it!
    Do you have also affiliate programs for selling this book?

    Thanks,
    Maoe

  3. Ozh

    Maor Barazany » Amazon itself has an affiliate program which you can use to sell it

  4. Robert

    Bought your book after I read your article http://planetozh.com/blog/2009/09/top-10-most-common-coding-mistakes-in-wordpress-plugins/ – it was worth every cent of it – thanks for the huge amount of tipps & code examples!

Leave a Reply

Your email address will not be published. Required fields are marked *