stroke icons free download

How to Save and Read Option in WordPress with Titan Framework

WordPress theme without any options like painting without color, not beautiful and can not be customized. A good template is can be Customize by the owner of the blog, without touching the code of the program.

In the wordpress system, there is called options. Options is a storage that can be used by wp theme developers to store a settings. Can be used for themes or plugins. I’m talking about options for wp theme.

You can create and read options manually with add_option function and get_option. However, there is a more easy and fast, with the framework. Nowadays there are many options that you can use the framework. For example, the Option framework and Titan Framework.

I prefer the Titan framework. To that end, I would like to share simple tips that you can immediately start using the Titan framework for purposes of your wp theme.

I do not know, I am more familiar with the Titan Framework. Titan framework can be used like a plugin or attachment directly in your template. The second way is more professional look, even though the first way (to install plugin) is also good, but requires the user touches.

Ok, I just started.

1. Download Titan Framework (non-plugin)

You can download it from Git-hub, follow this link and extract. And search titan-framework.

2. Copy titan-framework folder into you main theme directory.

3. Ok, its enough to starting using titan framework. Follow this article.

Prepare your functions.php with this code.

 /*
 * When using the embedded framework, use it only if the framework
 * plugin isn't activated.
 */
 
// Don't do anything when we're activating a plugin to prevent errors
// on redeclaring Titan classes
if ( ! empty( $_GET['action'] ) && ! empty( $_GET['plugin'] ) ) {
    if ( $_GET['action'] == 'activate' ) {
        return;
    }
}
// Check if the framework plugin is activated
$useEmbeddedFramework = true;
$activePlugins = get_option('active_plugins');
if ( is_array( $activePlugins ) ) {
    foreach ( $activePlugins as $plugin ) {
        if ( is_string( $plugin ) ) {
            if ( stripos( $plugin, '/titan-framework.php' ) !== false ) {
                $useEmbeddedFramework = false;
                break;
            }
        }
    }
}
// Use the embedded Titan Framework
if ( $useEmbeddedFramework && ! class_exists( 'TitanFramework' ) ) {
    require_once( trailingslashit( dirname( __FILE__ ) ) . 'titan-framework/titan-framework.php' );
}

Create Admin Panel with Titan Framework

$titan = TitanFramework::getInstance( 'my-theme' );
$panel = $titan->createAdminPanel( array(
    'name' => 'Theme Options',
) );

Save Options with Titan Framework

$generalTab = $panel->createTab( array(
    'name' => 'General',
) );

$generalTab->createOption( array(
    'name' => 'Footer Text',
    'id' => 'footer_text',
    'type' => 'textarea',
    'desc' => ''
) );

$generalTab->createOption( array(
    'name' => 'Headline Text',
    'id' => 'headline',
    'type' => 'editor',
    'desc' => ''
) );

$panel->createOption( array(
    'type' => 'save'
) );

And so on. We recomended you to finish reading Titan framework documentation.

Read Saved Options Value with Titan Framework.

function read_option($id){
 $titan = TitanFramework::getInstance( 'my-theme' );
 return $titan->getOption($id);
}

You can use read_option function in your template, very easy to use.

Ok, its very basic save and read option in wordpress system.

Create Tabbed Options Page

Tabbed page option allows you to divide a few settings in your template. Suppose you want to group page settings on the General, Social, sliders and etc.

This code to using tabbed interface.

$titan = TitanFramework::getInstance( 'my-theme' );
$panel = $titan->createAdminPanel( array(
    'name' => 'Theme Options',
) );

$generalTab = $panel->createTab( array(
    'name' => 'General',
) );

$sliderTab = $panel->createTab( array(
    'name' => 'Slider',
) );

$socialTab = $panel->createTab( array(
    'name' => 'Social',
) );

Then, fill the tabbed page with setting

$generalTab->createOption( array(
    'name' => 'Link Color',
    'id' => 'link_color',
    'type' => 'color',
    'desc' => '',
    'default' => '#555555'
) );

$sliderTab->createOption( array(
    'name' => 'Upload your image',
    'id' => 'slider1',
    'type' => 'upload'
) );

$socialTab->createOption( array(
    'name' => 'AddThis Code',
    'id' => 'addthis',
    'type' => 'textarea'
) );

Useful Resource for Titan Framework

  1. http://wptavern.com/speed-up-wordpress-development-with-the-titan-framework
  2. http://www.kvcodes.com/2014/02/wordpress-development-with-titan-framework/

Thats all, its very easy to follow. I hope this article is help you, then you can share this to your social network.

2 Responses

Show all responses
  1. Benjamin Intal
    February 20, 2015
  2. Onur
    March 8, 2017

Write a response