Book Image

WordPress Web Application Development

By : Rakhitha Nimesh Ratnayake
Book Image

WordPress Web Application Development

By: Rakhitha Nimesh Ratnayake

Overview of this book

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 turn their attentions to the possibility of using it as a web development framework. 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 an application with a modularized structure supported by the latest trending technologies. "Wordpress Web Application Development" provides a comprehensive, practical, and example-based approach for pushing the limits of WordPress for web applications beyond your imagination. This book 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 into 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, Underscore, and jQuery, and server-side technologies and techniques such as template engines, RSS feeds, Open Auth integration, and more. 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.
Table of Contents (18 chapters)
WordPress Web Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Configure and set up WordPress


WordPress is a CMS that can be installed in a few minutes with the help of an easy-to-follow tutorial. Throughout this book, we have implemented a personal portfolio management application with advanced users. This compact tutorial is intended to help you set up your WordPress installation with the necessary configurations to be compatible with the features of our application. Let's get started.

Step 1 – downloading WordPress

We are using WordPress 3.6 as it's the latest version available at the time of writing this book. So, we have to download Version 3.6 from the official website at:

http://wordpress.org/download/

Step 2 – creating the application folder

First, we need to create a folder for our application inside the web root directory. Then, we will extract the contents of the downloaded ZIP file into the application folder. Finally, we have to provide the necessary permissions to create files inside the application folder. Make sure you provide the write permission for the wp-config.php file before starting the installation. Generally, we can set the permission for directories as 755 and for files as 644. You can learn more about WordPress file permissions at:

http://codex.wordpress.org/Hardening_WordPress#File_Permissions

Step 3 – configuring the application URL

Initially, our application will be running on a local machine with a local web server. There are ways of working in the local environment:

  • Create a virtual host to run the application

  • Use the localhost to run the application

Creating a virtual host

Virtual hosts, often referred to as vhosts, allow us to configure multiple websites inside a single web server. Also, to refer to our application, we can match a custom URL. This method should be preferred in web application development as the migration from a local to a real server becomes less complex.

Let's say we want to run the portfolio application as www.developerportfolio.com. All we have to do is configure a virtual host to point the application folder to www.developerportfolio.com. Once set up, this will call the local application folder instead of the actual online website.

By using the actual server URL for the virtual host, we can directly export the local database into the server without changes.

The following resources will help you to set up a virtual host on different operating systems:

Using a localhost

A second and commonly used method is to use a localhost as the URL to access the web application. Once the application folder is created inside the web root, we can use http://localhost/application_folder_name to access the application.

Step 4 – installing WordPress

Open a web browser and enter your application URL mentioned previously to get the initial screen of the WordPress installation process, as illustrated in the following screenshot.

We have to manually create the database before starting this installation process. So, create a new database from your favorite database editor and create a database user with the necessary permission to access the database.

Then click on the Create a Configuration File button which will load the screen shown in the following screenshot:

The preceding screenshot displays all the information needed to continue with the installation. After reading the contents, click on the Let's go! button to get the next screen as shown in the following screenshot:

Here, we have to enter the details to connect to the database. Use the details in the database-creation process to define the database name, user, password, and database host. Finally, we have to enter the table prefix. By default, WordPress uses wp_ as the prefix. It's ideal to set a custom prefix like a random string for your tables to improve the security of your application. Once all the details are entered, click on the Submit button to get the next screen as shown in the following screenshot:

Note

Also, we can use the WP Better Security plugin to generate a random prefix and update the database.

Click on the Run the install button to get the next screen as shown in the following screenshot:

Fill in the form with the requested details. By default, WordPress uses admin as the username. Ideally, you should be using a custom username as the admin role to improve the security of the application. Once all the details are filled in, submit the form to complete the installation and you will get the following screenshot:

The details of your admin account will be displayed on this screen. Click on the Log In button to get the login form and log in to the admin area. Now we are ready to go.

Step 5 – setting up permalinks

Permalinks allow you to define the custom URL structure for your posts, pages, and custom URLs using mod_rewrite. By default, WordPress uses query parameters to load posts and pages through IDs. Usually, we change the existing URL structure to provide a neat URL. So, navigate to Settings | Permalink on the admin menu and you will find different URL structures. Select the Post name option for the URL and click on the Save button. Your screen should look something similar to the following screenshot:

Step 6 – downloading the Responsive theme

We have used a free theme called Responsive for the developer portfolio management application of this book. We can download the Responsive theme from the official WordPress themes directory at http://wordpress.org/themes/responsive. Then, we have to copy the extracted theme folder into the /wp-content/themes directory of our application.

Step 7 – activating the Responsive theme

Now we have to activate the theme from the WordPress admin panel. Choose Apperence | Themes from the left menu and click on the Activate link under the Responsive theme.

Step 8 – activating the plugin

Now copy the wpwa-web-application plugin into the /wp-content/plugins folder. Use the Plugins section on the admin menu to activate the plugin for this book.

Step 9 – using the application

Now we have completed the process of configuring WordPress for our portfolio management application. Open the web browser and enter the URL as http://www.yoursite.com/user/register or http://localhost/application_folder/user/register based on your URL structure to load the registration page of the application. You can use the menu and forms to navigate through the site and check all the features built throughout this book.