Title: [Plugin: OptionTree] Settings array direct access
Last modified: August 19, 2016

---

# [Plugin: OptionTree] Settings array direct access

 *  Resolved [Cudazi](https://wordpress.org/support/users/cudazi/)
 * (@cudazi)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-optiontree-settings-array-direct-access/)
 * Hey there,
 * Great plugin, love the idea and would be happy to start using it with my themes.
 * Just a quick best practice question. I’m storing the options returned in an array
   as suggested to save trips to the db.
 * Do you forsee any harm is declaring that settings array as global in the header
   so it can be accessed directly throughout the theme vs. having to check if get_option_tree
   exists, assign the returned value to an array every single time a value is to
   be grabbed?
 * Example – in header.php:
 * `
    global $theme_options; if ( function_exists( 'get_option_tree') ) { $theme_options
   = get_option('option_tree'); }
 * Then, in the theme, just referencing: $theme_options[“some_setting”]; instead
   of:
 * `
    if ( function_exists( 'get_option_tree') ) { $some_setting = get_option_tree('
   some_setting', $theme_options, false, false, -1 ); }
 * Let me know – thanks again!
 * [http://wordpress.org/extend/plugins/option-tree/](http://wordpress.org/extend/plugins/option-tree/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Cudazi](https://wordpress.org/support/users/cudazi/)
 * (@cudazi)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-optiontree-settings-array-direct-access/#post-1775880)
 * I suppose a halfway point would be to add this to the header to kill any errors
   created until the plugin is activated too…
 * `
    if ( ! function_exists( 'get_option_tree') ) { function get_option_tree() {
   return false; } }
 * That would allow the use of get_option_tree() throughout the theme without having
   to check if it always exists. (Even if it wouldn’t return anything until they’ve
   activated the plugin of course.)
 * I’ll stop replying to myself now & let someone else chime in.
 *  Plugin Author [Derek Herman](https://wordpress.org/support/users/valendesigns/)
 * (@valendesigns)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-optiontree-settings-array-direct-access/#post-1776104)
 * I add the get_option_tree() function to my functions.php just incase the plugin
   is ever deactivated or errors on update and can’t be activated for whatever reason.
   However, you must make sure you wrap the backup function in functions.php with:
 *     ```
       if ( ! function_exists( 'get_option_tree') ) {
         copy and paste the original get_option_tree() function here ...
       }
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: OptionTree] Settings array direct access’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/option-tree_363534.svg)
 * [OptionTree](https://wordpress.org/plugins/option-tree/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/option-tree/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/option-tree/)
 * [Active Topics](https://wordpress.org/support/plugin/option-tree/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/option-tree/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/option-tree/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Derek Herman](https://wordpress.org/support/users/valendesigns/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-optiontree-settings-array-direct-access/#post-1776104)
 * Status: resolved