Support » Themes and Templates » Should I load my theme's options as a global?

  • Luke Mlsna

    (@bitacre)


    I’ve been using this line to load my theme’s options array whenever I need to get a value:

    if( !isset( $themeslug_options ) ) $themeslug_options = get_option( 'themeslug-theme-options', themeslug_default_options() );

    I’m wondering if people usually do something like this or just load it once as a global instead?

    Pros/cons?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Chip Bennett

    (@chipbennett)

    Theme Review Admin

    Personally, I use a global for my Theme options array.

    Luke Mlsna

    (@bitacre)

    I’ve had a sneaking suspicion that a global would be the best way to do it, I just have an irrational fear of using global variables when I’m not the only person writing the code.

    As far as implementation specifics, I was thinking I would make a function loading the global array and then just call it once with the init add_action. Is this what you do Chip? (And thanks for the response.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Should I load my theme's options as a global?’ is closed to new replies.