WordPress.org

Make WordPress Core

Ticket #19743: 19743.diff

File 19743.diff, 1.3 KB (added by nacin, 4 years ago)
  • wp-content/themes/twentyeleven/inc/theme-options.php

     
    3737 */ 
    3838function twentyeleven_theme_options_init() { 
    3939 
    40         // If we have no options in the database, let's add them now. 
    41         if ( false === twentyeleven_get_theme_options() ) 
    42                 add_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() ); 
    43  
    4440        register_setting( 
    4541                'twentyeleven_options',       // Options group, see settings_fields() call in twentyeleven_theme_options_render_page() 
    4642                'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options() 
     
    239235 * @since Twenty Eleven 1.0 
    240236 */ 
    241237function twentyeleven_get_theme_options() { 
    242         return get_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() ); 
     238        $options = get_option( 'twentyeleven_theme_options' ); 
     239 
     240        if ( false === $options ) { 
     241                $options = twentyeleven_get_default_theme_options(); 
     242 
     243                // Since we have no options in the database, let's add them now. 
     244                if ( is_admin() ) 
     245                        add_option( 'twentyeleven_theme_options', $options ); 
     246        } 
     247 
     248        return $options; 
    243249} 
    244250 
    245251/**