WordPress Plugin Development Cookbook


WordPress Plugin Development Cookbook
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters

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

Book Details

Language : English
Paperback : 318 pages [ 235mm x 191mm ]
Release Date : July 2012
ISBN : 1849517681
ISBN 13 : 9781849517683
Author(s) : Yannick Lefebvre
Topics and Technologies : All Books, CMS and eCommerce, Cookbooks, Content Management (CMS), Open Source, WordPress

Table of Contents

Preface
Chapter 1: Preparing a Local Development Environment
Chapter 2: Plugin Framework Basics
Chapter 3: User Settings and Administration Pages
Chapter 4: The Power of Custom Post Types
Chapter 5: Customizing Post and Page Editors
Chapter 6: Accepting User Content Submissions
Chapter 7: Creating Custom MySQL Database Tables
Chapter 8: Leveraging JavaScript, jQuery, and AJAX Scripts
Chapter 9: Adding New Widgets to the WordPress Library
Chapter 10: Enabling Plugin Internationalization
Chapter 11: Distributing Your Plugin on wordpress.org
Index
  • Chapter 1: 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
    • Chapter 2: 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
      • Chapter 3: 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
        • Managing multiple sets of user settings from a single admin page
        • Chapter 4: 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
          • Chapter 5: 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
            • Chapter 6: 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
              • Chapter 7: 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
                • Chapter 8: 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
                    • Chapter 10: 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

                        Yannick Lefebvre

                        Yannick Lefebvre is a plugin developer who has published eight projects to the official WordPress repository. His first creation, Link Library, has been used on hundreds of sites around the world. With a background in computer science and working for Presagis, a company providing software tools in the modeling and simulation industry, Yannick started writing plugins for his own WordPress site in 2004 and quickly shared his creations with the community. Yannick is actively involved in the Montreal WordPress community and has presented multiple times at WordCamp Montreal. You can find out more about him and his plugins on his blog, Yannick's Corner (http://ylefebvre.ca).
                        Sorry, we don't have any reviews for this title yet.

                        Code Downloads

                        Download the code and support files for this book.


                        Submit Errata

                        Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                        Errata

                        - 6 submitted: last submission 16 Jan 2014

                        Errata type: Code | Page number: 106 The function ch3sapi_select_list on the line: <select name="ch3sapi_options[<?php echo $name; ?>]'> Should be: <select name="ch3sapi_options[<?php echo $name; ?>]">

                        Errata type: Code | Page number: 162 The third line of the ch4_br_perform_book_type_filtering function:if ( empty( $qv['book_reviews_book_type'] ) &&Should be: if ( !empty( $qv['book_reviews_book_type'] ) &&

                        Errata type:Technical editor | page number:105


                        The 4th paragraph that begins with "When the configuration page is visited, 
                        the top-level form is created using regular HTML code, setting the action to 
                        admin_post.php ...

                        Here, "admin_post.php" should be "options.php"

                        Errata type:code | page number:152

                        The original code in book is as follows:
                        
                        for ( $i = 0; $i < count( $first_entry ); $i++ ) {
                        
                        This code line should be as follows:
                        
                        for ( $i = 0; $i < count( $book_types ); $i++ ) {
                        
                        On Page 103, Step 14, the following line:
                        <?php if ( $options[$name] ) echo ' checked="checked"';
                        should read as:
                        <?php if ( isset( $options[$name] ) && $options[$name] ) echo ' checked="checked"';



                        On Page 106, in second block of code, the following line:
                        <?php selected( $options[$name] == $item ); ?>>
                        should read as:
                        <?php if ( isset( $options[$name] ) ) { selected( $options[$name] == $item ); } ?>>



                        On Page 107, in first block of code, the following line:
                        <?php echo esc_html ( $options[$name] ); ?></textarea>
                        should read as:

                        <?php if ( isset( $options[$name] ) ) { echo esc_html ( $options[$name] ); } ?></textarea>

                        Errata should read:

                        On Page 119, in the code for Step 6, the following line:
                        plugins_dir_path( __FILE__ ) . 'stylesheet.css';
                        should read as:

                        plugin_dir_path( __FILE__ ) . 'stylesheet.css';

                        Sample chapters

                        You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                        Frequently bought together

                        WordPress Plugin Development Cookbook +    Java 7 Concurrency Cookbook =
                        50% Off
                        the second eBook
                        Price for both: €30.90

                        Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                        What you will learn from this book

                        Prepare an efficient development environment  Create your first plugins using WordPress action and filter hooks Add new sections to the administration interface for plugin configuration Create new content types using Custom Post Types or Custom Database Tables Make your content dynamic with JavaScript, jQuery, and AJAX Add new widgets to the WordPress library Prepare your plugin to be translated for broad international use Get 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.  

                        Approach

                        This is a cookbook with step-by-step instructions and code examples required to learn WordPress plugin development easily.

                        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.

                        Code Download and Errata
                        Packt Anytime, Anywhere
                        Register Books
                        Print Upgrades
                        eBook Downloads
                        Video Support
                        Contact Us
                        Awards Voting Nominations Previous Winners
                        Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                        Resources
                        Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software