optionsframework_init

Creates the settings in the database by looping through the array we supplied in options.

Description

optionsframework_init(); 

This is a neat way to do it since we won't have to save settings for headers, descriptions, or arguments.

Read more about the Settings API in the WordPress codex: http://codex.wordpress.org/Settings_API


Usage

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

Defined (1)

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

/inc/options-framework.php  
  1. function optionsframework_init() { 
  2.  
  3. // Include the required files 
  4. require_once dirname( __FILE__ ) . '/options-interface.php'; 
  5. require_once dirname( __FILE__ ) . '/options-media-uploader.php'; 
  6.  
  7. // Optionally Loads the options file from the theme 
  8. $location = apply_filters( 'options_framework_location', array( 'options.php' ) ); 
  9. $optionsfile = locate_template( $location ); 
  10.  
  11. // Load settings 
  12. $optionsframework_settings = get_option('optionsframework' ); 
  13.  
  14. // Updates the unique option id in the database if it has changed 
  15. if ( function_exists( 'optionsframework_option_name' ) ) { 
  16. elseif ( has_action( 'optionsframework_option_name' ) ) { 
  17. // If the developer hasn't explicitly set an option id, we'll use a default 
  18. else { 
  19. $default_themename = get_option( 'stylesheet' ); 
  20. $default_themename = preg_replace("/\W/", "_", strtolower($default_themename) ); 
  21. $default_themename = 'optionsframework_' . $default_themename; 
  22. if ( isset( $optionsframework_settings['id'] ) ) { 
  23. if ( $optionsframework_settings['id'] == $default_themename ) { 
  24. // All good, using default theme id 
  25. } else { 
  26. $optionsframework_settings['id'] = $default_themename; 
  27. update_option( 'optionsframework', $optionsframework_settings ); 
  28. else { 
  29. $optionsframework_settings['id'] = $default_themename; 
  30. update_option( 'optionsframework', $optionsframework_settings ); 
  31.  
  32. // If the option has no saved data, load the defaults 
  33. if ( ! get_option( $optionsframework_settings['id'] ) ) { 
  34.  
  35. // Registers the settings fields and callback 
  36. register_setting( 'optionsframework', $optionsframework_settings['id'], 'optionsframework_validate' ); 
  37. // Change the capability required to save the 'optionsframework' options group.