WordPress Web Application Development - Second Edition
()
About this ebook
- Develop rapid web applications using the core features of WordPress
- Explore various workaround techniques to prevent maintenance nightmares by identifying the limitations of WordPress
- A practical guide filled with real-world scenarios that will guide you through how to build modular and scalar applications
This book is intended for WordPress developers and designers who want to develop quality web applications within a limited time frame and for maximum profit. Prior knowledge of basic web development and design is assumed.
Rakhitha Nimesh Ratnayake
Rakhitha Nimesh Ratnayake is a freelance web developer, writer, and an open source enthusiast. He also provides technical consultation on large scale web applications to one of the leading software development firms in SriLanka. Rakhitha is the creator of www.innovativephp.com, where he writes tutorials on the latest web development and design technologies. He is also a regular contributor to a number of popular websites such as 1stwebdesigner, the Tuts+ network, and the SitePoint network. Building Impressive Presentations with impress.js was his first book, also published by Packt Publishing. In his spare time, he likes to watch cricket and spend time with his family. Make sure you visit him online at www.innovativephp.com and follow him on Google+ at http://goo.gl/UiEf5B.
Read more from Rakhitha Nimesh Ratnayake
WordPress Web Application Development Rating: 5 out of 5 stars5/5Wordpress Web Application Development - Third Edition Rating: 0 out of 5 stars0 ratingsBuilding Impressive Presentations with Impress.js Rating: 4 out of 5 stars4/5
Related to WordPress Web Application Development - Second Edition
Related ebooks
WordPress Plugin Development: Beginner's Guide Rating: 0 out of 5 stars0 ratingsWordPress 3 Plugin Development Essentials Rating: 4 out of 5 stars4/5WordPress Top Plugins Rating: 1 out of 5 stars1/5Dreamweaver CS6 For Dummies Rating: 5 out of 5 stars5/5Responsive Web Design with HTML5 and CSS3 - Second Edition Rating: 4 out of 5 stars4/5HTML5 and CSS3: Building Responsive Websites Rating: 0 out of 5 stars0 ratingsWordPress 2.8 Theme Design Rating: 0 out of 5 stars0 ratingsBootstrap 4 Site Blueprints Rating: 5 out of 5 stars5/5WordPress 3.7 Complete Rating: 5 out of 5 stars5/5AngularJS Web Application Development Blueprints Rating: 0 out of 5 stars0 ratingsWordPress 3 Search Engine Optimization Rating: 0 out of 5 stars0 ratingsWeb Design All-in-One For Dummies Rating: 3 out of 5 stars3/5Joomla! 3 Beginner's Guide Second Edition Rating: 0 out of 5 stars0 ratingsLearning Drupal 8 Rating: 0 out of 5 stars0 ratingsNode.js Web Development - Third Edition Rating: 2 out of 5 stars2/5Mastering JavaScript Single Page Application Development Rating: 0 out of 5 stars0 ratingsBuilding Websites All-in-One For Dummies Rating: 4 out of 5 stars4/5jQuery Design Patterns Rating: 0 out of 5 stars0 ratingsWordPress Search Engine Optimization - Second Edition Rating: 0 out of 5 stars0 ratingsWordPress 4.0 Site Blueprints - Second Edition Rating: 0 out of 5 stars0 ratingsLearn WordPress In 7 Days: Complete Step by Step Beginners Guide To Become WordPress Expert Rating: 2 out of 5 stars2/5Wordpress Websites for Business: How Anyone Can Maximize Website Performance and Results Rating: 0 out of 5 stars0 ratingsWordPress A Complete Guide - 2019 Edition Rating: 3 out of 5 stars3/5WordPress 2019: The Beginner's Complete Step-by-Step Guide to Creating a Mobile Friendly Website with WordPress Rating: 0 out of 5 stars0 ratingsWordPress 4 Business Website Redesign: With Custom Coding Of Imported Database Rating: 1 out of 5 stars1/5WordPress For Dummies Rating: 0 out of 5 stars0 ratingsSetup Your WordPress 4.X.X Website From Scratch Rating: 0 out of 5 stars0 ratingsWordpress for Beginners: The Easy Step-by-Step Guide to Creating a Website with WordPress Rating: 5 out of 5 stars5/5WooCommerce A Complete Guide - 2019 Edition Rating: 0 out of 5 stars0 ratings
Programming For You
Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5Web Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsRaspberry Pi Cookbook for Python Programmers Rating: 0 out of 5 stars0 ratingsPython QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsPython: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Python Data Structures and Algorithms Rating: 5 out of 5 stars5/5OneNote: The Ultimate Guide on How to Use Microsoft OneNote for Getting Things Done Rating: 1 out of 5 stars1/5Poirot's Early Cases Rating: 5 out of 5 stars5/5The Little SAS Book: A Primer, Sixth Edition Rating: 5 out of 5 stars5/5Learn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5
Reviews for WordPress Web Application Development - Second Edition
0 ratings0 reviews
Book preview
WordPress Web Application Development - Second Edition - Rakhitha Nimesh Ratnayake
Table of Contents
WordPress Web Application Development Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. WordPress as a Web Application Framework
WordPress as a CMS
WordPress as a web application framework
The MVC versus event-driven architecture
Simplifying development with built-in features
User management
Media management
Template management
Database management
Routing
XMR-RPC API
Caching
Scheduling
Plugins and widgets
Themes
Actions and filters
The admin dashboard
Identifying the components of WordPress
The role of WordPress themes
Structure of a WordPress page layout
Customizing the application layout
The role of the admin dashboard
The admin dashboard
Posts and pages
Users
Appearance
Settings
The role of plugins
The role of widgets
A development plan for the portfolio management application
Application goals and target audience
Planning the application
User roles of the application
Planning application features and functions
Understanding limitations and sticking to guidelines
Building a question-answer interface
Prerequisites for building a question-answer interface
Creating questions
Customizing the comments template
Changing the status of answers
Saving the status of answers
Generating a question list
Enhancing features of the questions plugin
Customizing the design of questions
Categorizing questions
Approving and rejecting questions
Adding star rating to answers
Summary
2. Implementing Membership Roles, Permissions, and Features
Introduction to user management
Preparing the plugin
Getting started with user roles
Creating application user roles
The best action for adding user roles
Knowing the default roles of WordPress
Choosing among default and custom roles
Scenario 1
Scenario 2
Removing existing user roles
Understanding user capabilities
Creating your first capability
Understanding default capabilities
Registering application users
Implementing frontend registration
Shortcode implementation
Pros and cons of using shortcodes
Page template implementation
Pros and cons of page templates
Custom template implementation
Building a simple router for a user module
Creating the routing rules
Adding query variables
Flushing the rewriting rules
Controlling access to your functions
The advantages of using the do_action function
Creating custom templates
Designing the registration form
Planning the registration process
Handling registration form submission
Exploring the registration success path
Automatically log in the user after registration
Activating system users
Creating a login form in the frontend
Displaying the login form
Checking whether we implemented the process properly
Time to practice
Summary
3. Planning and Customizing the Core Database
Understanding the WordPress database
Exploring the role of existing tables
User-related tables
Post-related tables
Term-related tables
Other tables
Adapting existing tables into web applications
User-related tables
Post-related tables
Scenario 1 – An online shopping cart
Scenario 2 – A hotel reservation system
Scenario 3 – The project management application
Term-related tables
Other tables
Extending the database with custom tables
Planning the portfolio application tables
Types of tables in web applications
Creating custom tables
Querying the database
Querying the existing tables
Inserting records
Updating records
Deleting records
Selecting records
Querying the custom tables
Working with posts
Extending the WP_Query class for applications
Introduction to WordPress query classes
The WP_User_Query class
The WP_Comment_Query class
Other query classes
Limitations and considerations
Transaction support
Post revisions
How to know whether to enable or disable revisions?
Auto saving
Using meta tables
Summary
4. Building Blocks of Web Applications
Introduction to custom content types
The role of custom post types in web applications
Planning custom post types for application
Projects
Services
Articles
Books
Implementing custom post types for a portfolio application
Implementing the custom post type settings
Creating the project class
Assigning permissions to projects
Creating custom taxonomies for technologies and project types
Assigning permissions to the project type
Introduction to custom fields with meta boxes
What is a template engine?
Building a simple custom template loader
Creating your first template
Comparing the template loader and template engine
Persisting custom field data
Customizing custom post type messages
Introducing custom post type relationships
Pods framework for custom content types
Should you choose Pods for web development?
Time to practice
Summary
5. Developing Pluggable Modules
A brief introduction to WordPress plugins
Understanding the WordPress plugin architecture
WordPress plugins for web development
Creating reusable libraries with plugins
Planning the template loader plugin
Using the template loader plugin
Handling plugin dependencies
Extensible plugins
Extend plugins with WordPress core actions and filters
Planning a file uploader for portfolio application
Creating the extensible file uploader plugin
Converting file fields with jQuery
Integrating the media uploader to buttons
Extending the file uploader plugin
Customize the allowed types of images
Saving and loading project screens
Extend plugins with custom actions and filters
Pluggable plugins
Tips for using pluggable functions
Time to practice
Summary
6. Customizing the Dashboard for Powerful Backends
Understanding the admin dashboard
Customizing the admin toolbar
Removing the admin toolbar
Managing the admin toolbar items
Customizing the main navigation menu
Creating new menu items
Adding features with custom pages
Building options pages
Creating a custom layout for options pages
Building an application options panel
Using the WordPress options API
Using feature-packed admin list tables
Working with default admin list tables
The post list
Creating custom actions for custom posts
Creating custom filters for custom post types
Creating custom post status links
Displaying custom list columns
The user list
The comments list
Building extended lists
Using the admin list table for the following developers
Step 1 – defining the custom class
Step 2 – defining the instance variables
Step 3 – creating the initial configurations
Step 4 – implementing the custom column handlers
Step 5 – implementing the column default handlers
Step 6 – displaying the checkbox for records
Step 7 – listing the available custom columns
Step 8 – defining the sortable columns of list
Step 9 – creating a list of bulk actions
Step 10 – retrieving list data
Step 11 – adding a custom list as a menu page
Step 12 – displaying the generated list
An awesome visual presentation for admin screens
Using existing themes
Using plugin-based third-party admin themes
Creating your own admin theme
The responsive nature of the admin dashboard
Time for action
Summary
7. Adjusting Theme for Amazing Frontends
An introduction to the WordPress application frontend
A basic file structure of the WordPress theme
Understanding the template execution hierarchy
The template execution process of web application frameworks
Web application layout creation techniques
Shortcodes and page templates
Custom templates with custom routing
Using pure PHP templates
The WordPress way of using templates
Direct template inclusion
Theme versus plugin-based templates
Are you planning to create an application-specific theme?
Building the portfolio application home page
What is a widget?
Widgetizing application layouts
Creating widgets
Designing a home page template
Generating the application frontend menu
Creating a navigation menu
Displaying user-specific menus on the frontend
Managing options and widgets with customizer
Adding custom options to the theme customizer
Handling widgets in the theme customizer
Creating pluggable templates
Pluggable templates in WordPress
Extending the home page template with action hooks
Customize widgets to enable extendable locations
Planning action hooks for layouts
Time for action
Summary
8. Enhancing the Power of Open Source Libraries and Plugins
Why choose open source libraries?
Open source libraries inside the WordPress core
Open source JavaScript libraries in the WordPress core
What is Backbone.js?
Understanding the importance of code structuring
Integrating Backbone.js and Underscore.js
Creating a developer profile page with Backbone.js
Structuring with Backbone.js and Underscore.js
Displaying the projects list on page load
Creating new projects from the frontend
Integrating events to Backbone.js views
Validating and creating new models for the server
Creating new models in the server
Using PHPMailer for custom e-mail sending
Usage of PHPMailer within the WordPress core
Creating a custom version of a pluggable wp_mail function
Loading PHPMailer inside plugins and creating custom functions
Implementing user authentication with OpenAuth
Configuring login strategies
Implementing LinkedIn account authentication
Verifying LinkedIn account and generating response
Building a LinkedIn app
The process of requesting the strategies
Initializing the library
Authenticating users to our application
Using third- party libraries and plugins
Time for action
Summary
9. Listening to Third-party Applications
Introduction to APIs
The advantages of having an API
The WordPress XML-RPC API for web applications
Building the API client
Creating a custom API
Integrating API user authentication
Integrating API access tokens
Providing the API documentation
Time for action
Summary
10. Integrating and Finalizing the Portfolio Management Application
Integrating and structuring the portfolio application
Adding the template loader dependencies
Interating the template loader into a user manager
Working with a restructured application
Building the developer model
Designing the developer list template
Enabling AJAX-based filtering
Updating a user profile with additional fields
Updating the values of the profile fields
Scheduling subscriber notifications
Notifying subscribers through e-mails
Time for action
Final thoughts
Summary
11. Supplementary Modules for Web Development
Internationalization
Introduction to WordPress translation support
The translation functions in WordPress
Creating plugin translations
Creating the POT file using PoEdit
Loading language files
Changing the WordPress language
Working with media grid and image editor
Introduction to the post editor
Using the WordPress editor
Video embedding
Lesser-known WordPress features
Caching
Transients
Testing
Security
Introduction to multisite
Time for action
Summary
A. Configurations, Tools, and Resources
Configure and set up WordPress
Step 1 – downloading WordPress
Step 2 – creating the application folder
Step 3 – configuring the application URL
Creating a virtual host
Using a localhost
Step 4 – installing WordPress
Step 5 – setting up permalinks
Step 6 – downloading the Responsive theme
Step 7 – activating the Responsive theme
Step 8 – activating the plugin
Step 9 – using the application
Open source libraries and plugins
Online resources and tutorials
Index
WordPress Web Application Development Second Edition
WordPress Web Application Development Second Edition
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2013
Second edition: May 2015
Production reference: 1250515
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78217-439-4
www.packtpub.com
Credits
Author
Rakhitha Nimesh Ratnayake
Reviewers
Alex Bachuk
Baljeet Singh
Doug Sparling
Commissioning Editor
Deepika Gaonkar
Acquisition Editor
Reshma Raman
Content Development Editor
Rohit Singh
Technical Editor
Dhiraj Chandanshive
Copy Editor
Janbal Dharmaraj
Project Coordinator
Mary Alex
Proofreaders
Stephen Copestake
Safis Editing
Indexer
Hemangini Bari
Production Coordinator
Komal Ramchandani
Cover Work
Komal Ramchandani
About the Author
Rakhitha Nimesh Ratnayake is a freelance web developer, writer, and an open source enthusiast. He develops premium WordPress plugins for individual clients and the CodeCanyon marketplace. Rakhitha is the creator of www.innovativephp.com, where he writes tutorials on the latest web development and design technologies. He is also a regular contributor to a number of popular websites, such as 1stwebdesigner, the Tuts+ network, and the SitePoint network. Building Impressive Presentations with impress.js was his first book, which was published by Packt Publishing. In his spare time, he likes to watch cricket and spend time with his family. You can visit him online at www.innovativephp.com and follow him on ODesk at http://goo.gl/ykDLnk.
About the Reviewers
Alex Bachuk is a web developer with over 7 years of experience, specializing in custom JavaScript and WordPress web applications. Alex has been working with WordPress since Version 2.5 and has worked on projects ranging from a single-page website to interactive web applications and social platforms.
These days, Alex mostly works on single-page web applications powered by Angular.js and full stack Javascript applications using Meteor. His current projects include http://classmate.io, a web application for education, and www.timebooklet.com, a timesheet-focused reporting application.
Alex also organizes and talks at WordPress meetups throughout New England. He writes about technology on his blog, www.alexbachuk.com.
In his free time, Alex likes to travel the world with his wife Oksana, and when there is even more time, he practices Judo and Brazilian Jiu Jitsu.
Baljeet Singh is a web programmer, mobile application developer, consultant, and trainer. He is the creator of Cinnabar WordPress Framework (a WordPress theme framework based on Bootstrap 3). A github repo link for this is available at http://goo.gl/7z2Zom. He is very passionate about web technologies. In his free time, he likes to write about WordPress and various emerging technologies at http://baljeetsingh.in/blog/.
His objective is to make a positive impact on clients, co-workers, and the Internet, using his skills and experience to design and develop compelling and attractive websites, web applications, and mobile applications. He enjoys working on projects that involve a mix of web design, web development, and mobile application development.
Doug Sparling works as a technical architect and software developer for Andrews McMeel Universal, a publishing and syndication company in Kansas City, MO. At AMU, he uses Go for web services and backend processing, Ruby on Rails for web development, and Objective-C, Swift, and Java for iOS and Android development. The sites include www.gocomics.com, www.uexpress.com, www.puzzlesociety.com, and www.dilbert.com.
He is also the director of technology for a small web development firm called New Age Graphics (www.newage-graphics.com). After creating a custom CMS using C# and ASP.NET, all his work has moved to WordPress since the time WordPress 3.0 was released.
He is a passionate advocate for WordPress and has written several WordPress plugins. He can occasionally be found on the WordPress (https://wordpress.org) forums answering questions (and writing sample code) under the username scriptrunner.
He was also the co-author of a Perl book, Instant Perl Modules, for McGraw-Hill and is a reviewer for other Packt Publishing books, including jQuery 2.0 Animation Techniques: Beginner's Guide, and its first edition. He was also a reviewer for The Well-Grounded Rubyist, Second Edition, Manning Publications, and a technical proofer for Programming for Musicians and Digital Artists.
He is currently the technical directing editor for Programming in Haskell and reviewer for Go In Action, among others.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Preface
Developing WordPress-powered websites is one of the standout trends in the modern web development world. The flexibility and power of the built-in features offered by WordPress has made developers use this framework for advanced web development. This book will act as a comprehensive resource for building web applications with this amazing framework.
WordPress Web Application Development, is a comprehensive guide focused on incorporating the existing features of WordPress into typical web development. This book is structured towards building a complete web application from scratch. With this book, you will build a portfolio management application with a modularized structure supported by the latest trending technologies.
This book provides a comprehensive, practical, and example-based approach for pushing the limits of WordPress to create web applications beyond your imagination.
It begins by exploring the role of existing WordPress components and discussing the reasons for choosing WordPress for web application development. As we proceed, more focus will be put onto adapting WordPress features into web applications with the help of an informal use-case-based model for discussing the most prominent built-in features. While striving for web development with WordPress, you will also learn about the integration of popular client-side technologies, such as Backbone.js, Underscore.js, jQuery, and server-side technologies and techniques, such as template engines and OpenAuth integration.
This book differentiates from the norm by creating a website that is dedicated to providing tutorials, articles, and source code to continue and enhance the web application development techniques discussed throughout this book. You can access the website for this book at http://www.innovativephp.com/wordpress-web-applications.
After reading this book, you will possess the ability to develop powerful web applications rapidly within limited time frames with the crucial advantage of benefitting low-budget and time-critical projects.
What this book covers
Chapter 1, WordPress as a Web Application Framework, walks you through the existing modules and techniques to identify their usage in web applications. The identification of the WordPress features beyond the conventional CMS and planning portfolio management application are the highlights of this chapter.
Chapter 2, Implementing Membership Roles, Permissions, and Features, begins the implementation of a portfolio management application by exploring the features of the built-in user management module. Working with various user roles and permissions, as well as an introduction to the MVC process through routing, are the highlights of this chapter.
Chapter 3, Planning and Customizing the Core Database, serves as an extensive guide for understanding the core database structure and the role of database tables in web applications. Database querying techniques using WordPress query classes and coverage of the planning portfolio management application database are the highlights of this chapter.
Chapter 4, Building Blocks of Web Applications, explores the possibilities of extending WordPress posts beyond their conventional usage to suit complex applications. Advanced use of custom post types and an introduction to managing template loaders are the highlights of this chapter.
Chapter 5, Developing Pluggable Modules, introduces the techniques of creating highly reusable and extensible plugins to enhance the flexibility of web applications. Implementing various plugins for explaining these techniques with the use of WordPress action and filter hooks is the highlight of this chapter.
Chapter 6, Customizing the Dashboard for Powerful Backends, walks you through the process of customizing the WordPress admin panel for adding new features, as well as changing existing features and design. Building reusable grids and designing an admin panel with various different techniques are the highlights of this chapter.
Chapter 7, Adjusting Theme for Amazing Frontends, dives into the techniques of designing amazing layouts, thereby opening them up for future extension. Widgetizing layouts and building reusable templates are the highlights of this chapter.
Chapter 8, Enhancing the Power of Open Source Libraries and Plugins, explores the use of the latest trending open source technologies and libraries. Integrating open authentication into your web application and structuring the application on the client side are the highlights of this chapter.
Chapter 9, Listening to Third-party Applications, demonstrates how to use the WordPress XML-RPC API to create a custom API for your web application. Building a simple yet complete API with all the main features is the highlight of this chapter.
Chapter 10, Integrating and Finalizing the Portfolio Management Application, guides you through the integration of modules and refactoring the code developed throughout this book. Improving the consistency of the application's code and completing the features developed throughout the previous chapters are the highlights of this chapter.
Chapter 11, Supplementary Modules for Web Development, introduces you to the supplementary WordPress features, such as Internationalization, video embedding, media grid, and multisite. An introduction to important concepts in application development, such as caching, security, and testing are the highlight of this chapter.
Appendix, Configurations, Tools, and Resources, provides an application setup guide with necessary links to download the plugins and libraries used throughout the book.
What you need for this book
Technically, you need a computer, browser, and an Internet connection with the following working environment:
The Apache web server
PHP Version 5.2 or higher
WordPress Version 4.0 or higher.
MySQL Version 5.0 or higher
Once you have the preceding environment, you can download the Responsive theme from http://wordpress.org/themes/responsive and activate it from the Themes section. Finally, you can activate the plugin developed for this book to get things started.
Please refer to Appendix, Configurations, Tools, and Resources, for the application setup guide, required software, and plugins.
Who this book is for
This book is intended for WordPress developers or designers, who know how to create a basic CMS site and are looking for ways to learn the complex web application development in a reusable, maintainable, and modular way. Basic knowledge of WordPress themes and plugin development is expected, although this is not a must for experienced PHP developers to go through this book.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text are shown as follows: WordPress passes existing MIME types as the parameter to this function. Here, we have modified the $mimes array to restrict the image types to JPG.
A block of code is set as follows:
function filter_mime_types($mimes) {
$mimes = array(
'jpg|jpeg|jpe' => 'image/jpeg',
);
return $mimes;
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
function filter_mime_types($mimes) {
$mimes = array(
'jpg|jpeg|jpe' => 'image/jpeg',
);
do_action_ref_array('wpwa_custom_mimes', array(&$mimes));
return $mimes;
}
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: Once the Publish button is clicked, we validate the form and save the error messages as transients.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <feedback@packtpub.com>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.
Downloading the color images of this book
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: http://www.packtpub.com/sites/default/files/downloads/4082OS_ColorImages.pdf.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at <questions@packtpub.com>, and we will do our best to address the problem.
Chapter 1. WordPress as a Web Application Framework
In recent years, WordPress has matured from the most popular blogging platform to the most popular content management system. Thousands of developers around the world are making a living from WordPress design and development. As more and more people are interested in using WordPress, there are discussions and arguments about exploring the possibilities of using this amazing framework for web application development.
The future seems bright as WordPress has already got dozens of built-in features, which can be easily adapted to web application development using slight modifications. Since you are already reading this book, you have to be someone who is really excited to see how WordPress fits into web application development. Throughout this book, we will learn how we can inject the best practices of web development into WordPress framework to build web applications in rapid process.
Basically, this book will be important for developers from two different perspectives. On one hand, beginner- to intermediate-level WordPress developers can get knowledge of cutting-edge web development technologies and techniques to build complex applications. On the other hand, web development experts who are already familiar with popular PHP frameworks can learn WordPress for rapid application development. So, let's get started!
In this chapter, we will cover the following topics:
WordPress as a CMS
WordPress as a web application framework
Simplifying development with built-in features
Identifying the components of WordPress
Making a development plan for portfolio management application
Understanding limitations and sticking with guidelines
Building a question-answer interface
In order to work with this book, you should be familiar with WordPress themes, plugins, and its overall process. Developers who are experienced in PHP frameworks can work with this book while using the reference sources to learn WordPress. By the end of this chapter, you will have the ability to make the decision to choose WordPress for web development.
WordPress as a CMS
Way back in 2003, WordPress released its first version as a simple blogging platform and continued to improve until it became the most popular blogging tool. Later, it continued to improve as a CMS and now has a reputation for being the most popular CMS. These days everyone sees WordPress as a CMS rather than just a blogging tool.
Now the question is, where will it go next?
Recent versions of WordPress have included popular web development libraries such as Backbone.js and Underscore.js and developers are building different types of applications with WordPress. So, we can assume that it's moving in the direction of building applications. It's important to keep an eye on the next few versions to see what WordPress offers for web applications.
Before we consider the application development aspects of WordPress, it's ideal to figure out the reasons for it being such a popular framework. The following are some of the reasons behind the success of WordPress as a CMS:
Plugin-based architecture for adding independent features and the existence of over 20,000 open source plugins
A super simple and easy-to-access administration interface
A fast learning curve and comprehensive documentation for beginners
A rapid development process involving themes and plugins
An active development community with awesome support
Flexibility in building websites with its themes, plugins, widgets, and hooks
These reasons prove why WordPress is the top CMS for website development. However, experienced developers who work with full stack web applications don't believe that WordPress has a future in web application development. While it's up for debate, we'll see what WordPress has to offer for web development.
Once you complete reading this book, you will be able to decide whether WordPress has a future in web applications. I have been working with full stack frameworks for several years, and I certainly believe the future of WordPress for web development.
WordPress as a web application framework
In practice, the decision to choose a development framework depends on the complexity of your application. Developers will tend to go for frameworks in most scenarios. It's important to figure out why we go with frameworks for web development. Here's a list of possible reasons why frameworks become a priority in web application development:
Frameworks provide stable foundations for building custom functionalities
Usually, stable frameworks have a large development community with an active support
They have built-in features to address the common aspects of application development, such as routing, language support, form validation, user management, and more
They have a large amount of utility functions to address repetitive tasks
Full stack development frameworks such as Zend, CodeIgniter, and CakePHP adhere to the points mentioned in the preceding section, which in turn becomes the framework of choice for most developers. However, we have to keep in mind that WordPress is an application where we built applications on top of existing features. On the other hand, traditional frameworks are foundations used for building applications such as WordPress. Now, let's take a look at how WordPress