Advertisement
kobial8

Theme Option Activation

Feb 16th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.84 KB | None | 0 0
  1. Step 01: Download Latest Option tree from wordpress and extract it. Place the Folder 'Option Tree' in the theme directory.
  2. Step 02: Keep 'meta-boxes.php' & 'theme-options.php' in the inc folder of your theme.
  3. Step 03: Activate the Theme Option by putting the following code in functions.php
  4.  
  5. // add_filter( 'ot_show_pages', '__return_false' );
  6. add_filter( 'ot_show_new_layout', '__return_false' );
  7. add_filter( 'ot_theme_mode', '__return_true' );
  8. include_once( 'option-tree/ot-loader.php' );
  9. include_once('inc/meta-boxes.php');
  10. include_once('inc/theme-options.php'); 
  11.  
  12. Since we commented out  add_filter( 'ot_show_pages', '__return_false' );by using //, we can see the option tree in the admin area. If we want to hide it, just delete these //.
  13.  
  14.  
  15. Step 04: Create your own 'section' & 'settings' in following way:
  16.  
  17. 'sections'        => array(
  18.  
  19.       array(
  20.         'id'          => 'header_settings',
  21.         'title'       => __( 'Header Settings', 'theme-text-domain' )
  22.       ),
  23.       array(
  24.         'id'          => 'footer_settings',
  25.         'title'       => __( 'footer Settings', 'theme-text-domain' )
  26.       ),
  27.       array(
  28.         'id'          => 'social_settings',
  29.         'title'       => __( 'Social Media Settings', 'theme-text-domain' )
  30.       )
  31.     ),
  32.     'settings'        => array(
  33.         array(
  34.             'id' => 'copyright',
  35.             'label' => 'Copyright',
  36.             'desc' => 'Enter Copyright Information',
  37.             'std' => 'Copyright 2012 Andia - All rights reserved. Template by Azmind.',
  38.             'type' => 'textarea',
  39.             'section' => 'footer_settings',
  40.             ),
  41.  
  42.         array(
  43.             'id' => 'address',
  44.             'label' => 'Address',
  45.             'desc' => 'Enter Address Information',
  46.             'std' => 'Via Principe Amedeo 9, 10100, Torino, TO, Italy',
  47.             'type' => 'text',
  48.             'section' => 'footer_settings',
  49.             ),
  50.     )
  51.   );
  52.  
  53. Step 05: Call the variable you created in theme-options.php by using the following code:
  54.                     <div class="widget span3">
  55.                         <h4>Contact Us</h4>
  56.                     <?php
  57.                         $address = ot_get_option('address');
  58.                         $phone = ot_get_option('phone');
  59.                         $skype = ot_get_option('skype');
  60.                         $email = ot_get_option('email');
  61.                     ?>
  62.                         <?php if($address): ?>
  63.                         <p><i class="icon-map-marker"></i> Address: <?php echo $address; ?></p>
  64.                         <?php else : ?>
  65.                         <p><i class="icon-map-marker"></i> Address: Sarasota, CA, USA</p>
  66.                         <?php endif; ?>
  67.                         <p><i class="icon-envelope-alt"></i> Email: <a href="mailto:"><?php echo $email; ?></a></p>
  68.                     </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement