monsterinsights_delete_option

Helper method for deleting a setting's value.

Description

(boolean) monsterinsights_delete_option( (string) $key = '' ); 

Returns (boolean)

True if removed, false if not.

Parameters (1)

0. $key — Optional. (string) => ''
The setting key.

Usage

  1. if ( !function_exists( 'monsterinsights_delete_option' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/options.php'; 
  3.  
  4. // The setting key. 
  5. $key = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = monsterinsights_delete_option($key); 
  9.  

Defined (1)

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

/includes/options.php  
  1. function monsterinsights_delete_option( $key = '' ) { 
  2. // If no key, exit 
  3. if ( empty( $key ) ) { 
  4. return false; 
  5.  
  6. $option_name = monsterinsights_get_option_name(); 
  7.  
  8. // First let's grab the current settings 
  9.  
  10. // if on network panel or if on single site using network settings 
  11. //$settings = get_site_option( $option_name ); 
  12. //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false; 
  13. //$is_network = is_multisite(); 
  14. //$update_network_option = true; 
  15. //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) { 
  16. $settings = get_option( $option_name ); 
  17. // $update_network_option = false; 
  18. //} 
  19.  
  20. // Next let's try to remove the key 
  21. if( isset( $settings[ $key ] ) ) { 
  22. unset( $settings[ $key ] ); 
  23.  
  24. $did_update = false; 
  25. //if ( $update_network_option ) { 
  26. // $did_update = update_site_option( 'monsterinsights_settings', $settings ); 
  27. //} else { 
  28. $did_update = update_option( $option_name, $settings ); 
  29. //} 
  30.  
  31. // If it updated, let's update the global variable 
  32. if ( $did_update ) { 
  33. global $monsterinsights_settings; 
  34. $monsterinsights_settings = $settings; 
  35.  
  36. return $did_update;