Free Sample
+ Collection

WordPress Plugin Development Cookbook

Yannick Lefebvre

Why rely on third-party plugins for WordPress when you can create your own? This book shows you how with a series of brilliant recipes and code examples, taking your skills to a whole new level of customization.
RRP $26.99
RRP $44.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849517683
Paperback318 pages

About This Book

Learn to create plugins and configuration panels in order to bring new capabilities to WordPressTailor WordPress to your needs with new content types, custom widgets, and fancy jQuery elements, without breaching security needsDetailed instructions on how to achieve each task, followed by clear explanations of concepts featured in each recipe 

Who This Book Is For

If you are a WordPress user, developer, or a site integrator with basic knowledge of PHP and an interest to create new plugins to address your personal needs, client needs, or share with the community, then this book is for you.

Table of Contents

Chapter 1: Preparing a Local Development Environment
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
Chapter 2: Plugin Framework Basics
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
Chapter 3: User Settings and Administration Pages
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
Chapter 4: The Power of Custom Post Types
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
Chapter 5: Customizing Post and Page Editors
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
Chapter 6: Accepting User Content Submissions
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
Chapter 7: Creating Custom MySQL Database Tables
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
Chapter 8: Leveraging JavaScript, jQuery, and AJAX Scripts
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
Chapter 9: Adding New Widgets to the WordPress Library
Creating a new widget in WordPress
Displaying configuration options
Validating configuration options
Implementing the widget display function
Adding a custom dashboard widget
Chapter 10: Enabling Plugin Internationalization
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
Chapter 11: Distributing Your Plugin on
Creating a readme file for your plugin
Applying for your plugin to be hosted on
Uploading your plugin using Subversion
Providing a plugin banner image

What You Will Learn

Prepare an efficient development environment Create your first plugins using WordPress action and filter hooksAdd new sections to the administration interface for plugin configurationCreate new content types using Custom Post Types or Custom Database TablesMake your content dynamic with JavaScript, jQuery, and AJAXAdd new widgets to the WordPress libraryPrepare your plugin to be translated for broad international useGet your new creations ready to be shared on the official WordPress site

In Detail

WordPress is a popular, powerful, and open Content Management System. Learning to extend its core capabilities allows you to unleash its full potential, whether you're an administrator who cannot find the right extension, or a developer with a great idea to enhance the platform for the community, or a website designer/developer working to fulfill a client's needs. "WordPress Plugin Development Cookbook" is the perfect companion for plugin developers, offering easy-to-follow instructions to accomplish tasks that range from basic plugin creation and configuration to advanced customization techniques. Each topic is illustrated through realistic examples showing how it can be applied to solve common problems, followed by explanations of all concepts used. Create WordPress plugins of varying complexity, from a few lines that change a specific function to complex extensions that provide intricate new capabilities. From the creation of your first simple plugin to adding entire new sections and widgets in the administration interface, learn how to change and extend WordPress to perform virtually any task. After installing and configuring an efficient plugin development environment, you will discover how to register your own callbacks that WordPress will execute at key points, forming the basis of plugin creation. Armed with this essential knowledge, you'll explore how to create administration pages to allow users to configure your new creations and to add new content management sections to WordPress through custom post types and custom database tables. Once you have all these elements in place, improve your plugins by customizing the post and page editors, creating user-facing forms to populate new content sections, making your plugin output dynamic using Javascript and AJAX as well as adding new widgets to the platform. Finally, see how to add support for multiple languages and distribute your work to the global WordPress community. "WordPress Plugin Development Cookbook" provides you with tools to create any plugin you can imagine.  


Read More