monsterinsights_delete_options

Helper method for deleting multiple settings value.

Description

(boolean) monsterinsights_delete_options( (array) $keys = array() ); 

Returns (boolean)

True if removed, false if not.

Parameters (1)

0. $keys — Optional. (array) => array()
The setting key.

Usage

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

Defined (1)

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

/includes/options.php  
  1. function monsterinsights_delete_options( $keys = array() ) { 
  2. // If no keys, exit 
  3. if ( empty( $keys ) || ! is_array( $keys ) ) { 
  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 keys 
  21. foreach ( $keys as $key ) { 
  22. if( isset( $settings[ $key ] ) ) { 
  23. unset( $settings[ $key ] ); 
  24.  
  25. $did_update = false; 
  26. //if ( $update_network_option ) { 
  27. // $did_update = update_site_option( 'monsterinsights_settings', $settings ); 
  28. //} else { 
  29. $did_update = update_option( $option_name, $settings ); 
  30. //} 
  31.  
  32. // If it updated, let's update the global variable 
  33. if ( $did_update ) { 
  34. global $monsterinsights_settings; 
  35. $monsterinsights_settings = $settings; 
  36.  
  37. return $did_update;