wpcf7_is_mailbox_list

The Contact Form 7 wpcf7 is mailbox list function.

Description

wpcf7_is_mailbox_list( $mailbox_list ); 

Parameters (1)

0. $mailbox_list
The mailbox list.

Usage

  1. if ( !function_exists( 'wpcf7_is_mailbox_list' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/includes/formatting.php'; 
  3.  
  4. // The mailbox list. 
  5. $mailbox_list = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpcf7_is_mailbox_list($mailbox_list); 
  9.  

Defined (1)

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

/includes/formatting.php  
  1. function wpcf7_is_mailbox_list( $mailbox_list ) { 
  2. if ( ! is_array( $mailbox_list ) ) { 
  3. $mailbox_text = (string) $mailbox_list; 
  4. $mailbox_text = wp_unslash( $mailbox_text ); 
  5.  
  6. $mailbox_text = preg_replace( '/\\\\(?:\"|\')/', 'esc-quote',  
  7. $mailbox_text ); 
  8.  
  9. $mailbox_text = preg_replace( '/(?:\".*?\"|\'.*?\')/', 'quoted-string',  
  10. $mailbox_text ); 
  11.  
  12. $mailbox_list = explode( ', ', $mailbox_text ); 
  13.  
  14. $addresses = array(); 
  15.  
  16. foreach ( $mailbox_list as $mailbox ) { 
  17. if ( ! is_string( $mailbox ) ) { 
  18. return false; 
  19.  
  20. $mailbox = trim( $mailbox ); 
  21.  
  22. if ( preg_match( '/<(.+)>$/', $mailbox, $matches ) ) { 
  23. $addr_spec = $matches[1]; 
  24. } else { 
  25. $addr_spec = $mailbox; 
  26.  
  27. if ( ! wpcf7_is_email( $addr_spec ) ) { 
  28. return false; 
  29.  
  30. $addresses[] = $addr_spec; 
  31.  
  32. return $addresses;