wpcf7_mail_replace_tags

The Contact Form 7 wpcf7 mail replace tags function.

Description

wpcf7_mail_replace_tags( $content, (string) $args = '' ); 

Parameters (2)

0. $content
The content.
1. $args — Optional. (string) => ''
The args.

Usage

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

Defined (1)

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

/includes/mail.php  
  1. function wpcf7_mail_replace_tags( $content, $args = '' ) { 
  2. $args = wp_parse_args( $args, array( 
  3. 'html' => false,  
  4. 'exclude_blank' => false,  
  5. ) ); 
  6.  
  7. if ( is_array( $content ) ) { 
  8. foreach ( $content as $key => $value ) { 
  9. $content[$key] = wpcf7_mail_replace_tags( $value, $args ); 
  10.  
  11. return $content; 
  12.  
  13. $content = explode( "\n", $content ); 
  14.  
  15. foreach ( $content as $num => $line ) { 
  16. $line = new WPCF7_MailTaggedText( $line, $args ); 
  17. $replaced = $line->replace_tags(); 
  18.  
  19. if ( $args['exclude_blank'] ) { 
  20. $replaced_tags = $line->get_replaced_tags(); 
  21.  
  22. if ( empty( $replaced_tags ) || array_filter( $replaced_tags ) ) { 
  23. $content[$num] = $replaced; 
  24. } else { 
  25. unset( $content[$num] ); // Remove a line. 
  26. } else { 
  27. $content[$num] = $replaced; 
  28.  
  29. $content = implode( "\n", $content ); 
  30.  
  31. return $content;