jetpack_protect_format_whitelist

Returns an array of IP objects that will never be blocked by the Protect module.

Description

(array) jetpack_protect_format_whitelist(); 

The array is segmented into a local whitelist which applies only to the current site and a global whitelist which, for multisite installs, applies to the entire networko

Returns (array)


Usage

  1. if ( !function_exists( 'jetpack_protect_format_whitelist' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/protect/shared-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = jetpack_protect_format_whitelist(); 
  7.  

Defined (1)

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

/modules/protect/shared-functions.php  
  1. function jetpack_protect_format_whitelist() { 
  2.  
  3. $local_whitelist = jetpack_protect_get_local_whitelist(); 
  4.  
  5. $formatted = array ( 
  6. 'local' => array (),  
  7. ); 
  8.  
  9. foreach ( $local_whitelist as $item ) { 
  10. if ( $item->range ) { 
  11. $formatted['local'][] = $item->range_low . ' - ' . $item->range_high; 
  12. } else { 
  13. $formatted['local'][] = $item->ip_address; 
  14.  
  15. if ( is_multisite() && current_user_can( 'manage_network' ) ) { 
  16. $formatted['global'] = array (); 
  17. $global_whitelist = jetpack_protect_get_global_whitelist(); 
  18.  
  19. if ( false === $global_whitelist ) { 
  20. // if the global whitelist has never been set, check for a legacy option set prior to 3.6 
  21. $global_whitelist = get_site_option( 'jetpack_protect_whitelist', array () ); 
  22.  
  23. foreach ( $global_whitelist as $item ) { 
  24. if ( $item->range ) { 
  25. $formatted['global'][] = $item->range_low . ' - ' . $item->range_high; 
  26. } else { 
  27. $formatted['global'][] = $item->ip_address; 
  28.  
  29. return $formatted;