twentyeleven_theme_options_init

Register the form setting for our twentyeleven_options array.

Description

twentyeleven_theme_options_init(); 

This function is attached to the admin_init action hook.

This call to register_setting() registers a validation callback, twentyeleven_theme_options_validate(), which is used when the option is saved, to ensure that our option values are complete, properly formatted, and safe.

We also use this function to add our theme option if it doesn't already exist.


Usage

  1. if ( !function_exists( 'twentyeleven_theme_options_init' ) ) { 
  2. require_once '/inc/theme-options.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = twentyeleven_theme_options_init(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/inc/theme-options.php  
  1. function twentyeleven_theme_options_init() { 
  2.  
  3. // If we have no options in the database, let's add them now. 
  4. if ( false === twentyeleven_get_theme_options() ) 
  5. add_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() ); 
  6.  
  7. register_setting( 
  8. 'twentyeleven_options', // Options group, see settings_fields() call in theme_options_render_page() 
  9. 'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options() 
  10. );