Note: keep option tree plugin code in your theme folder: Download
Usage: To Activate Option Tree
functions.php:
add_filter( 'ot_show_pages', '__return_false' );
add_filter( 'ot_show_new_layout', '__return_false' );
add_filter( 'ot_theme_mode', '__return_true' );
include_once( 'option-tree/ot-loader.php' );
include_once( 'includes/theme-options.php' );
Note: Create Option Tree In the theme (Make a folder ==>includes<== and make a file ==>theme-options.php<== and paste the below code)
theme-options.php:
<?php
add_action( 'admin_init', 'custom_theme_options', 1 );
function custom_theme_options() {
$saved_settings = get_option( 'option_tree_settings', array() );
$custom_settings = array(
'sections' => array(
array(
'id' => 'general',
'title' => 'Site Settings'
)
),
/*
array(
'id' => 'social',
'title' => 'Social Settings'
)
), */
'settings' => array(
array(
'id' => 'logo_uploader',
'label' => 'Upload Your Logo',
'desc' => 'Size of the logo should be 400px width and 200px height',
'type' => 'upload',
'section' => 'general'
),
/* array(
'id' => 'social_option',
'label' => 'Footer Text',
'type' => 'textarea',
'section' => 'social'
) */
)
);
if ( $saved_settings !== $custom_settings ) {
update_option( 'option_tree_settings', $custom_settings );
}
}
?>
Note: Get Data From Option Tree
Conditional Data:
<?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'your_tree_id') ) : ?>
<?php get_option_tree( 'your_tree_id', '', 'true' ); ?>
<?php else : ?>
Your Default Data Here
<?php endif; endif; ?>
Simple Data:
<?php get_option_tree( 'facebook', '', 'true' ); ?>
Note: Reload the dashboard of wordpress admin page. One can see a option in Appearance => Theme Options.Usage: To Activate Option Tree
functions.php:
add_filter( 'ot_show_pages', '__return_false' );
add_filter( 'ot_show_new_layout', '__return_false' );
add_filter( 'ot_theme_mode', '__return_true' );
include_once( 'option-tree/ot-loader.php' );
include_once( 'includes/theme-options.php' );
Note: Create Option Tree In the theme (Make a folder ==>includes<== and make a file ==>theme-options.php<== and paste the below code)
theme-options.php:
<?php
add_action( 'admin_init', 'custom_theme_options', 1 );
function custom_theme_options() {
$saved_settings = get_option( 'option_tree_settings', array() );
$custom_settings = array(
'sections' => array(
array(
'id' => 'general',
'title' => 'Site Settings'
)
),
/*
array(
'id' => 'social',
'title' => 'Social Settings'
)
), */
'settings' => array(
array(
'id' => 'logo_uploader',
'label' => 'Upload Your Logo',
'desc' => 'Size of the logo should be 400px width and 200px height',
'type' => 'upload',
'section' => 'general'
),
/* array(
'id' => 'social_option',
'label' => 'Footer Text',
'type' => 'textarea',
'section' => 'social'
) */
)
);
if ( $saved_settings !== $custom_settings ) {
update_option( 'option_tree_settings', $custom_settings );
}
}
?>
Note: Get Data From Option Tree
Conditional Data:
<?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'your_tree_id') ) : ?>
<?php get_option_tree( 'your_tree_id', '', 'true' ); ?>
<?php else : ?>
Your Default Data Here
<?php endif; endif; ?>
Simple Data:
<?php get_option_tree( 'facebook', '', 'true' ); ?>
Example(header.php)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php bloginfo('name');?></title>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/bar/bar.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/dark/dark.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/default/default.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/light/light.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/nivo-slider.css"/>
<link rel="stylesheet" type="text/css" href="<?php bloginfo(stylesheet_url);?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/fonts/stylesheet.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/comments.css"/>
<link href='http://fonts.googleapis.com/css?family=Port+Lligat+Slab' rel='stylesheet' type='text/css'>
<?php wp_head(); ?>
</head>
<body>
<div class="main">
<div class="header">
<?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'logo_Uploader') ) : ?>
<a href="<?php bloginfo('home');?>"><img src="<?php get_option_tree( 'logo_Uploader', '', 'true' ); ?>" alt=""/></a>
<?php else : ?>
<a href="<?php bloginfo('home');?>"><img src="<?php echo get_template_directory_uri();?>/images/logo.jpg" alt=""/></a>
<?php endif; endif; ?>
</div>
<div class=" mainmenu">
<?php wp_nav_menu( array( 'theme_location' => 'header-menu') ); ?>
</div>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php bloginfo('name');?></title>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/bar/bar.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/dark/dark.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/default/default.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/light/light.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/css/nivo-slider.css"/>
<link rel="stylesheet" type="text/css" href="<?php bloginfo(stylesheet_url);?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/fonts/stylesheet.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/comments.css"/>
<link href='http://fonts.googleapis.com/css?family=Port+Lligat+Slab' rel='stylesheet' type='text/css'>
<?php wp_head(); ?>
</head>
<body>
<div class="main">
<div class="header">
<?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'logo_Uploader') ) : ?>
<a href="<?php bloginfo('home');?>"><img src="<?php get_option_tree( 'logo_Uploader', '', 'true' ); ?>" alt=""/></a>
<?php else : ?>
<a href="<?php bloginfo('home');?>"><img src="<?php echo get_template_directory_uri();?>/images/logo.jpg" alt=""/></a>
<?php endif; endif; ?>
</div>
<div class=" mainmenu">
<?php wp_nav_menu( array( 'theme_location' => 'header-menu') ); ?>
</div>