We all know that the WordPress Settings API is hard, and while it provides you with more control, there is a need for a single API that can be used to build admin panel settings pages, meta boxes for post types, and options in the customizer. This is where Titan Framework steps in.
In my previous article, I gave a quick introduction to Titan Framework, in which I highlighted some of the features which make it the finest of all options frameworks. Now it's time to begin exploring some of the details of this framework. In this article today, I will explain how you can install, integrate and configure Titan Framework with your WordPress project. So let's start!
Titan Framework's Installation
Titan Framework is plug and play! That means it comes as a plugin which can be downloaded, or you can embed it in your WordPress theme/plugin.
I personally like the later, i.e. embedding it in the project of installing plugins. If you'd like to install it as a plugin, here is what you need to do:
- Log in to your WordPress dashboard.
- Go to Plugins > Add New.
- In the search bar, write Titan Framework and browse it.
- It appears first in the displayed results.
- Click the Install Now button. This step completes the installation.
- In the end, you will need to activate the plugin.
Integrating Titan Framework in Your Project
Installing and activating the plugin is not sufficient for Titan Framework to work. You'll need to integrate it. To make it short and sweet, you are required to include Titan Framework in the core file of your WordPress development project, which could either be functions.php of your WP theme or the core PHP file of your WP plugins. Titan offers two ways through which it can be integrated. These are:
- Integrate using the plugin.
- Integrate by embedding the framework.
Both of these methods will bring the same outcome, i.e. include Titan Framework in your project. However, the approach adopted in each is slightly different. So, let's explore each one of these options.
1. Integrate Using the Plugin
The plug and play aspect of Titan Framework is pretty great. However, this feature is also helpful in its integration. So, to make sure that Titan Framework gets included in your project, proper installation and activation of the plugin is a prerequisite. The next step is to add a new file called titan-framework-checker.php
.
titan-framework-checker.php
This file will serve two purposes. First, this script will verify that the user has installed the framework plugin. If not, it will generate an error message. Secondly, this file should be a part of your plugin/theme as your project becomes dependent on this framework.
Just download this file from GitHub and place it inside your WordPress theme or plugin.
Including Titan Framework
Next you will include this file in your theme's functions.php
or plugin's core PHP file using the require_once()
command. To do so, add the following line of code:
require_once( 'titan-framework-checker.php' );
This completes the basic integration of Titan Framework via plugin.
2. Integrate by Embedding the Framework
There are some developers who do not like to rely on a plugin. So, for all such developers this second method of integrating Titan Framework is quite handy. This sets you free from the hassle of installing and activating the Titan Framework plugin. But at the same time, embedding Titan in your project will stop notifying you about any updates in the framework.
Creating a New Folder
Embedding the framework begins with the creation of a new folder in your plugin/theme's directory. Name this folder titan-framework
. All your framework related code is kept here.
Including Titan Framework
Again you will include this file in your theme's functions.php
or plugin's core PHP file using the require_once()
command. To do so, add the following line of code:
require_once( 'titan-framework/titan-framework-embedder.php' );
This script will make sure that the framework gets embedded in your project.
Conclusion
That's about it. The basic installation and integration of Titan Framework is pretty simple. I hope that both of the above mentioned methods are quite clear. This was just a quick setup of the framework. However, I haven't explained the basic concept of options and getting values from them yet. If you find any difficulty in this article then you may post your queries below or reach out to me at Twitter..
Comments