wpcf7_normalize_newline

The Contact Form 7 wpcf7 normalize newline function.

Description

wpcf7_normalize_newline( $text, $to = ' 
' ); 

Parameters (2)

0. $text
The text.
1. $to — Optional. (string) => ' '
The to.

Usage

  1. if ( !function_exists( 'wpcf7_normalize_newline' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/includes/formatting.php'; 
  3.  
  4. // The text. 
  5. $text = null; 
  6.  
  7. // The to. 
  8. $to = ' 
  9. '; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = wpcf7_normalize_newline($text, $to); 
  13.  

Defined (1)

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

/includes/formatting.php  
  1. function wpcf7_normalize_newline( $text, $to = "\n" ) { 
  2. if ( ! is_string( $text ) ) { 
  3. return $text; 
  4.  
  5. $nls = array( "\r\n", "\r", "\n" ); 
  6.  
  7. if ( ! in_array( $to, $nls ) ) { 
  8. return $text; 
  9.  
  10. return str_replace( $nls, $to, $text );