The Titan Framework is a new WordPress options framework that was released on WordPress.org this week. This set of tools was created to make it easy for WordPress theme and plugin developers to add options to their projects. This first release contains more than 20 options, including meta boxes, Google font selector, a media uploader, multicheck categories and taxonomies, theme customizer options and more.
Titan claims to be the easiest options framework you’ll ever use. With just a few simple lines of code you can quickly add customization options that are easy for clients to use and understand. For example, to get an instance of the Titan Framework for your plugin, you’d add just one line to the the main plugin file:
$titan = TitanFramework::getInstance( 'my-plugin' );
Setting up an admin page and menu for your options is as easy as adding a couple lines of code:
$panel = $titan->createAdminPanel( array(name => 'Theme Options',) );
This helps to keep your code clean with the Titan engine powering the details related to building options.
The Titan Framework Was Built For Efficiency
I had the chance to speak with Benjamin Intal, Titan Framework’s creator, to ask him why he decided to put another WordPress options framework out into the wild, despite the fact that there are already so many. Intal said that Titan resulted from a bit of spring cleaning he completed on his themes.
“When I started creating WordPress themes 4 years ago, as my number of projects grew, I had a hard time managing all the code from the different themes I had,” he said. “By instinct, I started unifying all the similar code to make things more manageable. After months of work, I ended up with a huge framework that handled everything the theme needed.”
From there his private framework evolved as he learned more about WordPress best practices. Intal began removing much of the functionality and turning it into plugins:
My mindset was that every feature should be included with the theme. As I learned more and more about the ins and outs of WordPress, I learned that what I did was a big no no. So now, I’m dissecting those themes, and turning its innards into plugins. One of those is the Titan Framework.
Intal’s spring cleaning resulted in a powerful set of options that speed up development. He uses it regularly in client projects. In one example he needed to provide information on various locations on a map, so he created a custom post type for locations and Titan powers most of the meta box options for inputting custom fields such as latitude, longitude and other location properties.
While Intal maintains the framework for the purpose of efficiency in his own work, it’s now something that anyone can use. “Titan Framework focuses on ease of use,” he said. “For me, that translates to minimal coding and fewer things to remember.”
When creating the Titan Framework, Intal wanted to make a standardized way of adding options, so that it’s easy for developers to remember how to accomplish common tasks. He described the problem he was trying to solve and how Titan can improve your workflow:
In WordPress, admin options, custom fields and theme customizer controls are all different from each other. These are set up differently and getting the saved values for each type is performed differently. Titan Framework unifies all these so that you won’t really have to know whether you’re using an admin option, a custom field or a customizer control. Everything is just an option. Because of this, getting your saved values is just one simple method: the getOption method.
How to Include the Titan Framework in Your Project
Currently, if you want to use Titan with your work, you’ll need to have the plugin activated alongside your own theme or plugin. This will allow you to call the framework’s functions inside your project. Refer to the developers’ documentation on the Titan project page for further instructions and a snippet for checking to see if Titan has been activated.
“Ideally, Titan should always be a plugin that’s separate from your theme or plugin so that Titan can be updated for bug fixes or new features,” Intal said. However, he recognizes that some developers might want to bundle the framework within their projects. He plans on performing an update soon that will make that possible.
Future Additions to the Titan Framework
Intal has plans to expand the number of options in the framework, which currently includes most of the basics. He’ll be adding a palette selector, widget area selector and menu selector further down the road.
He also plans to include functionality for easily creating and selecting widget areas, as well as new functions for creating shortcodes.
Ital said that what he’s trying to accomplish with Titan is not based on a desire to improve deficiencies he’s seen in other frameworks. “When I was in the process of creating Titan Framework, I honestly did not dive into the other existing frameworks since I already had everything I needed to complete it,” he said. “I’ve just started now to check out what’s out there and I’m finding that there are a lot of great frameworks such as Redux and OptionTree.”
Of course, if you’re trying to learn how to code plugin and theme options from the inside out, then using an options framework is not the way to go. The idea behind using a framework is to save yourself time in development and focus on building your project. There’s no need to reinvent the wheel every time you need to add a few options. Titan saves you the hassle of having to code them from scratch. For more information and examples on how to use it, check out the Titan Framework homepage and documentation.