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 - Third Edition

Book Description

Learn in easy stages how to rapidly build leading-edge web applications from scratch.

About This Book

  • Develop powerful web applications rapidly with WordPress
  • Explore the significant features and improvements introduced in WordPress 4.7 by learning the numerous tips and techniques in this book.
  • Unleash the power of REST API endpoints to make your interaction with websites new and innovative.

Who This Book Is For

This book is targeted at WordPress developers and designers who want to develop quality web applications within a limited time frame and maximize their profits. A prior knowledge of basic web development and design is assumed.

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
  • Manage permissions for a wide range of content types in web applications based on different user types
  • 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

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. WordPress 4.7 introduces some exciting new improvements and several bug fixes, which further improve the entire development process.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 consistently emphasizes 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; content restrictions; routing; translation; caching; and many more, while you build the backend of a forum management application.

This book begins by explaining how to plan the development of a web application using WordPress' core features. Once the core features are explained, you will learn how to build an application by extending them through custom plugin development. Finally, you will explore advanced non-functional features and application integration.

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

Style and approach

An extensive, practical guide that explains how to adapt WordPress features, both conventional and trending, for web applications.

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 code file.

Table of Contents

  1. 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. Errata
      3. Piracy
      4. Questions
  2. 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. XML-RPC API
      7. REST API
      8. Caching
      9. Scheduling
      10. Plugins and widgets
      11. Themes
      12. Actions and filters
      13. 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 forum 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
    9. Categorizing questions
      1. Approving and rejecting questions
      2. Adding star rating to answers
    10. Summary
  3. 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 between 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 logging in the user after registration
      11. Activating system users
    6. Creating a login form in the frontend
      1. Handling login form submission
        1. Checking whether we implemented the process properly
    7. Essential user management features for web applications
      1. Frontend login and registration
      2. Custom profile fields
      3. Private data
      4. Search and member list
      5. Frontend profile
    8. Implementing user management features with popular plugins
      1. BuddyPress
      2. User Profiles Made Easy
      3. User Role Editor
    9. Time to practice
    10. Summary
  4. 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 in 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 &-; a project management application
      3. Term-related tables
      4. Other tables
    4. Extending the database with custom tables
    5. Planning the forum application tables
      1. Types of table 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 do you know whether to enable or disable revisions?
      3. Autosaving
      4. Using meta tables
    8. Summary
  5. 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 an application
      1. Forums
      2. Topics
    3. Implementing custom post types for a forum application
      1. Implementing the custom post type settings
      2. Creating forum and topic classes
        1. Assigning permissions to forums and topics
      3. Creating custom taxonomies for topic categories and topic tags
        1. Assigning permissions to the topic tags
      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. Introduction to post type templates
      1. Creating and using a post type template
    7. Introducing custom post type relationships
    8. Pods framework for custom content types
      1. Should you choose Pods for web development?
    9. Implementing custom post type features with popular plugins
      1. Custom Post Type UI
      2. Toolset Types
    10. Time to practice
    11. Summary
  6. Implementing Application Content Restrictions
    1. Introduction to content restrictions
    2. Practical usage of content restrictions
      1. The role of membership in content restrictions
    3. Understanding restriction levels
      1. User roles-based restrictions
      2. User groups-based restrictions
      3. Membership plans-based restrictions
      4. Unique password-based restrictions
    4. Implementing content restrictions in posts/pages
      1. Shortcode-based restrictions
      2. Individual post/page restrictions
        1. Creating a meta box for topic restrictions
        2. Saving topic restriction settings
        3. Verifying individual post/page restrictions
      3. Site lockdown
    5. Enabling restrictions on WordPress core features
      1. Restrictions on posts
      2. Restrictions on searches
      3. Restrictions on menus
      4. Restrictions on widgets
      5. Restrictions on archives
    6. Supplementary content restriction types and techniques
      1. Restrictions on custom generated content
      2. Attachment protection
      3. Social Locker
      4. E-mail subscription
      5. Private page
    7. Useful plugins for content restrictions
      1. Restrict Content
      2. WP Private Content Plus
      3. Membership 2
    8. Time to practice
    9. Summary
  7. 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
        4. Extensible plugins
        5. Extending plugins with WordPress core actions and filters
          1. Creating the extensible file uploader plugin
          2. Converting file fields with jQuery
          3. Integrating the media uploader to buttons
          4. Extending the file uploader plugin
          5. Customizing the allowed file types
          6. Saving and loading topic files
        6. Extending plugins with custom actions and filters
      2. Pluggable plugins
        1. Tips for using pluggable functions
    3. Tips for developing extendable plugins
    4. Time to practice
    5. Summary
  8. 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 forum topics
        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 the list data
        11. Step 11 &-; adding a custom list as a menu page
        12. Step 12 &-; displaying the generated list
      4. Managing the subscribe and unsubscribe status
      5. Adding content restrictions to admin list tables
    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. Supplementary admin dashboard features
      1. Dashboard widgets
      2. Screen options menu
      3. Help menu
      4. User language control
    10. Time for action
    11. Summary
  9. 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 forum application home page
      1. Building the forum list using shortcode
      2. Widgetizing home page
        1. What is a widget?
      3. Widgetizing application layouts
        1. Creating widgets
      4. Designing a home page template
    4. Generating the application frontend menu
      1. Creating a navigation menu
        1. Saving menu item restrictions
      2. Displaying user-specific menus on the frontend
    5. Managing options and widgets with customizer
      1. Adding custom options to the theme customizer
      2. Handling widgets in the theme customizer
    6. Creating pluggable templates
    7. Extending the home page template with action hooks
      1. Customizing widgets to enable extendable locations
    8. Planning action hooks for layouts
    9. Managing custom CSS with live preview
    10. Responsive previews in theme customizer
    11. Time for action
    12. Summary
  10. 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 forum user profile page with Backbone.js
        1. Structuring with Backbone.js and Underscore.js
        2. Displaying the topics list on page load
        3. Creating new topics 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 a LinkedIn account and generating a 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. Using open source plugins for web development
    8. Using plugins for checking security of other plugins
    9. Time for action
    10. Summary
  11. 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. WordPress REST API for web applications
      1. Introduction to WordPress REST API endpoints
        1. Testing GET requests
        2. Testing POST requests
        3. Disabling REST API
      2. Custom content types with REST API
      3. Managing custom routes and endpoints
        1. Creating custom routes and endpoints for forum topics
        2. Creating custom routes and endpoints for custom table data
      4. Building the REST API client
        1. REST API client in the same site
        2. REST API client from external site
      5. REST API authentication and access tokens
    9. Time for action
    10. Summary
  12. Integrating and Finalizing the Forum Management Application
    1. Integrating and structuring the forum application
    2. Integrating the template loader into a user manager
    3. Working with the restructured application
      1. Building the forum page
      2. Displaying forum details
      3. Creating new forum topics
      4. Displaying forum topics
      5. Joining users to forums
        1. Restricting topic creation to forum members
      6. Building forum topic page
      7. Creating forum topic replies
      8. Handling forum topic replies
      9. Understanding other forum features
    4. Updating a user profile with additional fields
      1. Updating the values of the profile fields
    5. Scheduling subscriber notifications
      1. Notifying subscribers through e-mails
    6. Time for action
    7. Final thoughts
    8. Summary
  13. 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 Eazy Po
        2. Creating and editing translations with PoEdit
        3. Loading language files
        4. Changing the WordPress language
    2. Working with media grid and image editor
    3. Introduction to the post editor
      1. Using the WordPress editor
        1. Keyboard shortcuts
        2. Editor item locations
        3. Highlighting broken links
      2. Video embedding
    4. Lesser-known WordPress features
      1. Caching
      2. Transients
      3. Testing
      4. Security
      5. Performance
        1. P3 - Plugin Performance Profiler plugin
        2. Query monitor plugin
        3. GTmetrix for WordPress
    5. Managing application scripts and styles
      1. Conditionally loading script and styles
      2. Inline script loading
    6. Version control
    7. E-commerce
      1. Creating products with WooCommerce
    8. Migrating WordPress applications
    9. Importing and exporting application content
    10. Introduction to multisite
    11. Time for action
    12. Summary
  14. Configurations, Tools, and Resources
    1. Configuring and setting 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