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.


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. register_setting( 
  4. 'twentyeleven_options', // Options group, see settings_fields() call in twentyeleven_theme_options_render_page() 
  5. 'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options() 
  6. ); 
  7.  
  8. // Register our settings field group 
  9. add_settings_section( 
  10. 'general', // Unique identifier for the settings section 
  11. '', // Section title (we don't want one) 
  12. '__return_false', // Section callback (we don't want anything) 
  13. 'theme_options' // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page() 
  14. ); 
  15.  
  16. // Register our individual settings fields 
  17. add_settings_field( 
  18. 'color_scheme', // Unique identifier for the field for this section 
  19. __( 'Color Scheme', 'twentyeleven' ), // Setting field label 
  20. 'twentyeleven_settings_field_color_scheme', // Function that renders the settings field 
  21. 'theme_options', // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page() 
  22. 'general' // Settings section. Same as the first argument in the add_settings_section() above 
  23. ); 
  24.  
  25. add_settings_field( 'link_color', __( 'Link Color', 'twentyeleven' ), 'twentyeleven_settings_field_link_color', 'theme_options', 'general' ); 
  26. add_settings_field( 'layout', __( 'Default Layout', 'twentyeleven' ), 'twentyeleven_settings_field_layout', 'theme_options', 'general' );