Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Docs Containers & Options

Phill Healey edited this page Aug 22, 2020 · 1 revision

Overview

Titan Framework is very simple and revolves around just 2 concepts:

  1. Containers
  2. Options

To use the framework, you just have to create containers, then put options into them. That’s it!

Creating containers

Containers are basically your admin pages, tabs, meta boxes, and theme customiser sections. These are essentially the areas where you put your options.

$titan = TitanFramework::getInstance( 'my-theme-or-plugin-name' );

// Create an admin page with a menu
$panel = $titan->createAdminPanel( array(
    'name' => 'Theme Options',
) );

// Create an admin tab inside the admin page above
$tab = $panel->createTab( array(
    'name' => 'General Options',
) );

// Create a meta box
$box = $titan->createMetaBox( array(
    'name' => 'My Meta Box',
) );

// Create a theme customizer section
$section = $titan->createThemeCustomizerSection( array(
    'name' => 'My Section',
) );

Creating options

Options are the input fields which serve as the settings to your theme or plugin. Options are valuable tools for any theme or plugin, and extends its functionality by allowing the user to modify it to their hearts content.

Any of the above containers have a createOption function that can be used to create an option:

$titan = TitanFramework::getInstance( 'my-theme-or-plugin-name' );

// Create an admin page with a menu
$panel = $titan->createAdminPanel( array(
    'name' => 'Theme Options',
) );

// Create an option inside the admin page above
$panel->createOption( array(
    'name' => 'My Option',
    'id' => 'my_option1',
) );

// Create an admin tab inside the admin page above
$tab = $panel->createTab( array(
    'name' => 'General Options',
) );

// Create an option inside the admin tab above
$tab->createOption( array(
    'name' => 'My Option',
    'id' => 'my_option2',
) );

// Create a meta box
$box = $titan->createMetaBox( array(
    'name' => 'My Meta Box',
) );

// Create an option inside the meta box above
$box->createOption( array(
    'name' => 'My Option',
    'id' => 'my_option3',
) );

// Create a theme customizer section
$section = $titan->createThemeCustomizerSection( array(
    'name' => 'My Section',
) );

// Create an option inside the customizer section above
$section->createOption( array(
    'name' => 'My Option',
    'id' => 'my_option4',
) );
Clone this wiki locally