Last active
January 4, 2016 13:39
-
-
Save webhasan/8628924 to your computer and use it in GitHub Desktop.
wp: options tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use options Tree as theme mood: | |
<?php | |
add_filter( 'ot_show_pages', '__return_false' ); | |
add_filter( 'ot_show_new_layout', '__return_false' ); | |
add_filter( 'ot_theme_mode', '__return_true' ); | |
load_template( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' ); | |
/** | |
* Theme Options | |
*/ | |
load_template( trailingslashit( get_template_directory() ) . 'includes/theme-options.php' ); | |
// Options settings | |
<?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' => 'General Setting' | |
) | |
), | |
'settings' => array( | |
array( | |
'id' => 'logo', | |
'label' => 'Logo', | |
'desc' => 'Upload your logo', | |
'type' => 'upload', | |
'section' => 'general' | |
), | |
array( | |
'id' => 'phone_number', | |
'label' => 'Phone Number', | |
'desc' => 'Upload your phone number image ', | |
'type' => 'upload', | |
'section' => 'general' | |
), | |
array( | |
'id' => 'footer-text', | |
'label' => 'Footer Text', | |
'desc' => 'Write footer copyright text', | |
'type' => 'text', | |
'section' => 'general' | |
) | |
) | |
); | |
if ( $saved_settings !== $custom_settings ) { | |
update_option( 'option_tree_settings', $custom_settings ); | |
} | |
} | |
?> | |
//Use the options | |
<?php if( get_option_tree( 'your_tree_id')) : ?> | |
<?php echo get_option_tree( 'your_tree_id'); ?> | |
<?php else : ?> | |
Your Default Data | |
<?php endif;?> | |
// not conditional use | |
<?php if( get_option_tree( 'your_tree_id')) : ?> | |
<?php echo get_option_tree( 'your_tree_id'); ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment