Tonjoo Tom Theme Integration

todiadiyatmo 28 Jun 2014 3 Menit 1

In this tutorial we will guide you how to integrate Tonjoo Theme Options Maker (TTOM) into your WordPress Theme. Please note that the current version of TTOM is only come in plugin version. So every theme using TTOM must have TTOM installed on their plugin.


We need a fresh copy of TTOM plugin, and then copy and paste tonjoostudio_options.php from tonjoostudio-tom/sample-options to your theme.

MODIFY tonjoostudio_options.php

The tonjoostudio_options.php consisting of 3 function :

// Setting up the default behaviour of WP Editor in TTOM function tonjoostudio_tom_default() { ... } // Options for your theme function tonjoostudio_tom_option() { ... } // Theme options configuration (name, title, etc) function tonjoostudio_tom_config($config) { ... }


You can specify the behaviour of WP Editor by changing the array key and value on the tonjoostudio_tom_default() function. For example we can change the font-size range or maybe change the available font options on WP Editor using font-face key

$default = array( 'font-size' => range( 9, 71 ), 'font-face' => array( 'arial' => 'Arial', 'verdana' => 'Verdana, Geneva', ), 'font-style' => array( 'normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic', ), /********************************************************* * @ **********************************************************/ 'editor-settings' => array( 'media_buttons' => false, /* Set true to display media button */ 'textarea_rows' => 5, 'tinymce' => array( 'plugins' => 'wordpress' ) ) );


To create a new options we must first define an Options Group. Each Options Group is defined by type => ‘heading’ on the options array. It will create a new tab on the Option Page.

/********** Tab Homepage ***********/ $options['homepage'] = array( 'name' => 'Homepage', 'type' => 'heading', // Define that this is an option groups 'desc' => 'Test description homepage'); )

Each time you define an option with type => ‘heading’ (Options Group), every options bellow the $options will belong to the Options Group defined before.

To add an options you need to add this default template to the $options array :

$options['your-options-shortcode-id'] = array( 'name' => 'Options Name', 'desc' => 'Options Description', 'type' => 'Options Type', 'default' => 'Default Value' );

Supported type value is

  • heading
  • text
  • textarea
  • select
  • select tag
  • select-image
  • radio
  • upload
  • checkbox
  • multicheck

The tonjoostudio_options.php default file have many sample of default options available.


Most of the time, you will need to change the name of the Theme Options name on the WP Admin side. To do this you just need to modifiy your tonjoostudio_tom_config() functions on your tonjoostudio_options.php file.

function tonjoostudio_tom_config($config) { /* * $config['mode'] = 'lite' or 'full' * lite : User cannot create new options from the wp-admin */ # $config['mode'] = 'lite'; # $config['page_title'] = 'Your Theme Option'; # $config['page_desc'] = 'Your custom descriptions'; # $config['menu_title'] = 'Your Custom Title'; # $config['capability'] = 'edit_theme_options'; # $config['menu_slug'] = ''; # $config['icon_url'] = 'dashicons-editor-paste-text'; # $config['position'] = '61'; # $config['sub_page_title'] = 'Your Sub Page Title'; # $config['sub_page_desc'] = 'Your custom descriptions'; # $config['sub_menu_title'] = 'Your Sub Page Title'; # $config['sub_capability'] = ''; # $config['sub_menu_slug'] = ''; # $config['ads_enabled'] = true; # $config['ads_title'] = 'My Ads'; # $config['ads_endpoint'] = ''; return $config; } 


TTOM currently supports custom ads on the options page, so you can create your own ads on theme options page. the default of this feature is disabled. to activate it you need to add this code to tonjoostudio_tom_config(); function on tonjoostudio_options.php file located on your active theme.

$config['ads_enabled'] = true; $config['ads_title'] = 'Your ads header title';

and add the URL endpoint ads with code:

$config['ads_endpoint'] = '';

Url endpoint must have a return value as jsonp with parameters :

permalink_promo_1 (link for 1st ad),
permalink_promo_2 (link for 2nd ad),
img_promo_1 (image url of 1st ad),
img_promo_2 (image url of 2nd ad)

Example of return value:

jsonp: ({ "permalink_promo_1":"https:\/\/\/addons\/fluid-responsive-slideshow\/", "permalink_promo_2":"https:\/\/\/addons\/easy-custom-auto-excerpt\/", "img_promo_1":"https:\/\/\/rahasia\/wp-content\/themes\/tonjoostudio\/tom-images\/ads\/FRS-banner-box.jpg", "img_promo_2":"https:\/\/\/rahasia\/wp-content\/uploads\/2014\/07\/ECAE-small-banner-ads-regular.jpg" })

to make a jsonp callback to your ads, simply create an array of parameters and print it using json_encode :

Example :

$data = array( 'permalink_promo_1' => ''), 'permalink_promo_2'=> ''), 'img_promo_1' => ''), 'img_promo_2' => '') ); // for example, in ads url has parameters get ( if(!isset($_GET['type']) && !empty($_GET['type'])){ echo "jsonp:" . json_encode($data); }


Last Updated on Februari 6, 2015 by Haris

Bagikan ke:
Ditulis oleh


engineer | keyboard warrior | founder @tonjoostudio

Post comment


Leave a Reply

Alamat email Anda tidak akan dipublikasikan.

Situs ini menggunakan Akismet untuk mengurangi spam. Pelajari bagaimana data komentar Anda diproses.