O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

WordPress Web Application Development - Second Edition

Book Description

Build rapid web applications with cutting-edge technologies using WordPress

In Detail

WordPress is one of the most rapidly expanding markets on the Web. Learning how to build complex and scalable web applications will give you the ability and knowledge to step into the future of WordPress.

This book is a practical, scenario-based guide to expanding the power of the WordPress core modules to develop modular and maintainable real-world applications from scratch. This book will consistently emphasize adapting WordPress features into web applications. It will walk you through the advanced usages of existing features such as access controlling, database handling, custom post types, pluggable plugins, routing, translation, caching, and many more while you build the backend of a portfolio management application.

After reading this book, you will have the ability to develop powerful web applications rapidly within limited time frames.

What You Will Learn

  • Develop extendable plugins with the use of WordPress features in core modules
  • Develop pluggable modules to extend the core features of WordPress as independent modules
  • Follow WordPress coding standards to develop reusable and maintainable code
  • Build and customize themes beyond conventional web layouts
  • Explore the power of core database tables and understand the limitations when designing database tables for large applications
  • Integrate open source modules into WordPress applications to keep up with the latest open source technologies
  • Customize the WordPress admin section and themes to create the look and feel of a typical web application

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. WordPress Web Application Development Second Edition
    1. Table of Contents
    2. WordPress Web Application Development Second Edition
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. WordPress as a Web Application Framework
      1. WordPress as a CMS
      2. WordPress as a web application framework
        1. The MVC versus event-driven architecture
      3. Simplifying development with built-in features
        1. User management
        2. Media management
        3. Template management
        4. Database management
        5. Routing
        6. XMR-RPC API
        7. Caching
        8. Scheduling
        9. Plugins and widgets
        10. Themes
        11. Actions and filters
        12. The admin dashboard
      4. Identifying the components of WordPress
        1. The role of WordPress themes
        2. Structure of a WordPress page layout
        3. Customizing the application layout
        4. The role of the admin dashboard
          1. The admin dashboard
          2. Posts and pages
          3. Users
          4. Appearance
          5. Settings
        5. The role of plugins
        6. The role of widgets
      5. A development plan for the portfolio management application
        1. Application goals and target audience
        2. Planning the application
        3. User roles of the application
        4. Planning application features and functions
      6. Understanding limitations and sticking to guidelines
      7. Building a question-answer interface
        1. Prerequisites for building a question-answer interface
        2. Creating questions
        3. Customizing the comments template
        4. Changing the status of answers
        5. Saving the status of answers
        6. Generating a question list
      8. Enhancing features of the questions plugin
        1. Customizing the design of questions
        2. Categorizing questions
        3. Approving and rejecting questions
        4. Adding star rating to answers
      9. Summary
    9. 2. Implementing Membership Roles, Permissions, and Features
      1. Introduction to user management
        1. Preparing the plugin
      2. Getting started with user roles
        1. Creating application user roles
          1. The best action for adding user roles
        2. Knowing the default roles of WordPress
          1. Choosing among default and custom roles
            1. Scenario 1
            2. Scenario 2
        3. Removing existing user roles
      3. Understanding user capabilities
        1. Creating your first capability
        2. Understanding default capabilities
      4. Registering application users
      5. Implementing frontend registration
        1. Shortcode implementation
          1. Pros and cons of using shortcodes
        2. Page template implementation
          1. Pros and cons of page templates
        3. Custom template implementation
        4. Building a simple router for a user module
          1. Creating the routing rules
          2. Adding query variables
          3. Flushing the rewriting rules
        5. Controlling access to your functions
          1. The advantages of using the do_action function
        6. Creating custom templates
        7. Designing the registration form
        8. Planning the registration process
        9. Handling registration form submission
          1. Exploring the registration success path
        10. Automatically log in the user after registration
        11. Activating system users
      6. Creating a login form in the frontend
        1. Displaying the login form
          1. Checking whether we implemented the process properly
      7. Time to practice
      8. Summary
    10. 3. Planning and Customizing the Core Database
      1. Understanding the WordPress database
      2. Exploring the role of existing tables
        1. User-related tables
        2. Post-related tables
        3. Term-related tables
        4. Other tables
      3. Adapting existing tables into web applications
        1. User-related tables
        2. Post-related tables
          1. Scenario 1 – An online shopping cart
          2. Scenario 2 – A hotel reservation system
          3. Scenario 3 – The project management application
        3. Term-related tables
        4. Other tables
      4. Extending the database with custom tables
      5. Planning the portfolio application tables
        1. Types of tables in web applications
        2. Creating custom tables
      6. Querying the database
        1. Querying the existing tables
          1. Inserting records
          2. Updating records
          3. Deleting records
          4. Selecting records
        2. Querying the custom tables
        3. Working with posts
        4. Extending the WP_Query class for applications
        5. Introduction to WordPress query classes
          1. The WP_User_Query class
          2. The WP_Comment_Query class
          3. Other query classes
      7. Limitations and considerations
        1. Transaction support
        2. Post revisions
          1. How to know whether to enable or disable revisions?
        3. Auto saving
        4. Using meta tables
      8. Summary
    11. 4. Building Blocks of Web Applications
      1. Introduction to custom content types
        1. The role of custom post types in web applications
      2. Planning custom post types for application
        1. Projects
        2. Services
        3. Articles
        4. Books
      3. Implementing custom post types for a portfolio application
        1. Implementing the custom post type settings
        2. Creating the project class
          1. Assigning permissions to projects
        3. Creating custom taxonomies for technologies and project types
          1. Assigning permissions to the project type
        4. Introduction to custom fields with meta boxes
      4. What is a template engine?
        1. Building a simple custom template loader
        2. Creating your first template
        3. Comparing the template loader and template engine
      5. Persisting custom field data
        1. Customizing custom post type messages
      6. Introducing custom post type relationships
      7. Pods framework for custom content types
        1. Should you choose Pods for web development?
      8. Time to practice
      9. Summary
    12. 5. Developing Pluggable Modules
      1. A brief introduction to WordPress plugins
        1. Understanding the WordPress plugin architecture
      2. WordPress plugins for web development
        1. Creating reusable libraries with plugins
          1. Planning the template loader plugin
          2. Using the template loader plugin
          3. Handling plugin dependencies
        2. Extensible plugins
          1. Extend plugins with WordPress core actions and filters
            1. Planning a file uploader for portfolio application
            2. Creating the extensible file uploader plugin
            3. Converting file fields with jQuery
            4. Integrating the media uploader to buttons
            5. Extending the file uploader plugin
            6. Customize the allowed types of images
            7. Saving and loading project screens
          2. Extend plugins with custom actions and filters
        3. Pluggable plugins
          1. Tips for using pluggable functions
      3. Time to practice
      4. Summary
    13. 6. Customizing the Dashboard for Powerful Backends
      1. Understanding the admin dashboard
      2. Customizing the admin toolbar
        1. Removing the admin toolbar
        2. Managing the admin toolbar items
      3. Customizing the main navigation menu
        1. Creating new menu items
      4. Adding features with custom pages
      5. Building options pages
        1. Creating a custom layout for options pages
        2. Building an application options panel
        3. Using the WordPress options API
      6. Using feature-packed admin list tables
        1. Working with default admin list tables
          1. The post list
            1. Creating custom actions for custom posts
            2. Creating custom filters for custom post types
            3. Creating custom post status links
            4. Displaying custom list columns
          2. The user list
          3. The comments list
        2. Building extended lists
        3. Using the admin list table for the following developers
          1. Step 1 – defining the custom class
          2. Step 2 – defining the instance variables
          3. Step 3 – creating the initial configurations
          4. Step 4 – implementing the custom column handlers
          5. Step 5 – implementing the column default handlers
          6. Step 6 – displaying the checkbox for records
          7. Step 7 – listing the available custom columns
          8. Step 8 – defining the sortable columns of list
          9. Step 9 – creating a list of bulk actions
          10. Step 10 – retrieving list data
          11. Step 11 – adding a custom list as a menu page
          12. Step 12 – displaying the generated list
      7. An awesome visual presentation for admin screens
        1. Using existing themes
        2. Using plugin-based third-party admin themes
        3. Creating your own admin theme
      8. The responsive nature of the admin dashboard
      9. Time for action
      10. Summary
    14. 7. Adjusting Theme for Amazing Frontends
      1. An introduction to the WordPress application frontend
        1. A basic file structure of the WordPress theme
        2. Understanding the template execution hierarchy
        3. The template execution process of web application frameworks
      2. Web application layout creation techniques
        1. Shortcodes and page templates
        2. Custom templates with custom routing
          1. Using pure PHP templates
          2. The WordPress way of using templates
          3. Direct template inclusion
          4. Theme versus plugin-based templates
            1. Are you planning to create an application-specific theme?
      3. Building the portfolio application home page
        1. What is a widget?
      4. Widgetizing application layouts
        1. Creating widgets
      5. Designing a home page template
      6. Generating the application frontend menu
        1. Creating a navigation menu
        2. Displaying user-specific menus on the frontend
      7. Managing options and widgets with customizer
        1. Adding custom options to the theme customizer
        2. Handling widgets in the theme customizer
      8. Creating pluggable templates
        1. Pluggable templates in WordPress
      9. Extending the home page template with action hooks
        1. Customize widgets to enable extendable locations
      10. Planning action hooks for layouts
      11. Time for action
      12. Summary
    15. 8. Enhancing the Power of Open Source Libraries and Plugins
      1. Why choose open source libraries?
      2. Open source libraries inside the WordPress core
      3. Open source JavaScript libraries in the WordPress core
        1. What is Backbone.js?
        2. Understanding the importance of code structuring
        3. Integrating Backbone.js and Underscore.js
        4. Creating a developer profile page with Backbone.js
          1. Structuring with Backbone.js and Underscore.js
          2. Displaying the projects list on page load
          3. Creating new projects from the frontend
          4. Integrating events to Backbone.js views
          5. Validating and creating new models for the server
          6. Creating new models in the server
      4. Using PHPMailer for custom e-mail sending
        1. Usage of PHPMailer within the WordPress core
          1. Creating a custom version of a pluggable wp_mail function
          2. Loading PHPMailer inside plugins and creating custom functions
      5. Implementing user authentication with OpenAuth
        1. Configuring login strategies
          1. Implementing LinkedIn account authentication
          2. Verifying LinkedIn account and generating response
        2. Building a LinkedIn app
        3. The process of requesting the strategies
        4. Initializing the library
        5. Authenticating users to our application
      6. Using third- party libraries and plugins
      7. Time for action
      8. Summary
    16. 9. Listening to Third-party Applications
      1. Introduction to APIs
        1. The advantages of having an API
      2. The WordPress XML-RPC API for web applications
      3. Building the API client
      4. Creating a custom API
      5. Integrating API user authentication
      6. Integrating API access tokens
      7. Providing the API documentation
      8. Time for action
      9. Summary
    17. 10. Integrating and Finalizing the Portfolio Management Application
      1. Integrating and structuring the portfolio application
      2. Adding the template loader dependencies
      3. Interating the template loader into a user manager
      4. Working with a restructured application
        1. Building the developer model
        2. Designing the developer list template
        3. Enabling AJAX-based filtering
      5. Updating a user profile with additional fields
        1. Updating the values of the profile fields
      6. Scheduling subscriber notifications
        1. Notifying subscribers through e-mails
      7. Time for action
      8. Final thoughts
      9. Summary
    18. 11. Supplementary Modules for Web Development
      1. Internationalization
        1. Introduction to WordPress translation support
          1. The translation functions in WordPress
        2. Creating plugin translations
          1. Creating the POT file using PoEdit
          2. Loading language files
          3. Changing the WordPress language
      2. Working with media grid and image editor
      3. Introduction to the post editor
        1. Using the WordPress editor
        2. Video embedding
      4. Lesser-known WordPress features
        1. Caching
        2. Transients
        3. Testing
        4. Security
      5. Introduction to multisite
      6. Time for action
      7. Summary
    19. A. Configurations, Tools, and Resources
      1. Configure and set up WordPress
        1. Step 1 – downloading WordPress
        2. Step 2 – creating the application folder
        3. Step 3 – configuring the application URL
          1. Creating a virtual host
          2. Using a localhost
        4. Step 4 – installing WordPress
        5. Step 5 – setting up permalinks
        6. Step 6 – downloading the Responsive theme
        7. Step 7 – activating the Responsive theme
        8. Step 8 – activating the plugin
        9. Step 9 – using the application
      2. Open source libraries and plugins
      3. Online resources and tutorials
    20. Index