of_reset_options

The ColorWay Theme of reset options function.

Description

of_reset_options( $options, (string) $page = '' ); 

Parameters (2)

0. $options
The options.
1. $page — Optional. (string) => ''
The page.

Usage

  1. if ( !function_exists( 'of_reset_options' ) ) { 
  2. require_once '/functions/admin-interface.php'; 
  3.  
  4. // The options. 
  5. $options = null; 
  6.  
  7. // The page. 
  8. $page = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = of_reset_options($options, $page); 
  12.  

Defined (1)

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

/functions/admin-interface.php  
  1. function of_reset_options($options, $page = '') { 
  2.  
  3. global $wpdb; 
  4. $query_inner = ''; 
  5. $count = 0; 
  6.  
  7. $excludes = array( 'blogname' , 'blogdescription' ); 
  8.  
  9.  
  10. foreach($options as $option) { 
  11.  
  12. if(isset($option['id'])) {  
  13. $count++; 
  14. $option_id = $option['id']; 
  15. $option_type = $option['type']; 
  16.  
  17. //Skip assigned id's 
  18. if(in_array($option_id, $excludes)) { continue; } 
  19.  
  20. if($count > 1) { $query_inner .= ' OR '; } 
  21. if($option_type == 'multicheck') { 
  22. $multicount = 0; 
  23. foreach($option['options'] as $option_key => $option_option) { 
  24. $multicount++; 
  25. if($multicount > 1) { $query_inner .= ' OR '; } 
  26. $query_inner .= "option_name = '" . $option_id . "_" . $option_key . "'"; 
  27.  
  28.  
  29. } else if(is_array($option_type)) { 
  30. $type_array_count = 0; 
  31. foreach($option_type as $inner_option) { 
  32. $type_array_count++; 
  33. $option_id = $inner_option['id']; 
  34. if($type_array_count > 1) { $query_inner .= ' OR '; } 
  35. $query_inner .= "option_name = '$option_id'"; 
  36.  
  37. } else { 
  38. $query_inner .= "option_name = '$option_id'"; 
  39.  
  40.  
  41. //When Theme Options page is reset - Add the of_options option 
  42. if($page == 'optionsframework') { 
  43. $query_inner .= " OR option_name = 'of_options'"; 
  44.  
  45. //echo $query_inner; 
  46.  
  47. $query = "DELETE FROM $wpdb->options WHERE $query_inner"; 
  48. $wpdb->query($query); 
  49.