Should I load my theme's options as a global? (3 posts)

  1. Luke Mlsna
    Posted 4 years ago #

    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?


  2. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

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

  3. Luke Mlsna
    Posted 4 years ago #

    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.)

Topic Closed

This topic has been closed to new replies.

About this Topic