Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- *Download Option Tree: http://wordpress.org/extend/plugins/option-tree/
- *Copy option-tree folder to your theme directory
- */
- /*================================================
- Usage on functions.php to activate Option-Tree
- =================================================*/
- 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' );
- /*===================================================
- Create Option theme-options.php under (inc) folder
- =====================================================*/
- 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'
- )
- ),
- 'settings' => array(
- array(
- 'id' => 'logo_text',
- 'label' => 'Logo Text',
- 'desc' => 'Use H1, H2, H3 tag',
- 'type' => 'textarea',
- 'section' => 'general'
- ),
- array(
- 'id' => 'footer_text',
- 'label' => 'Footer Text',
- 'type' => 'textarea',
- 'section' => 'general'
- )
- )
- );
- if ( $saved_settings !== $custom_settings ) {
- update_option( 'option_tree_settings', $custom_settings );
- }
- }
- /*=======================================
- Get Data From Option Tree
- =======================================*/
- // To get Condtional 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
- <?php endif; endif; ?>
- // To get Simple Data
- <?php get_option_tree( 'facebook', '', 'true' ); ?>
- ?>
- <?php
- //The following code would echo the images if the key was "src" and the setting ID was "images"
- if ( function_exists( 'ot_get_option' ) ) {
- /* get the images array */
- $images = ot_get_option( 'images', array() );
- if ( ! empty( $images ) ) {
- foreach( $images as $image ) {
- echo '<img src="' . $image['src'] . '" alt="' . $image['title'] . '" />';
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement