wpcf7_special_mail_tag

The Contact Form 7 wpcf7 special mail tag function.

Description

wpcf7_special_mail_tag( $output, (string) $name, $html ); 

Parameters (3)

0. $output
The output.
1. $name (string)
The name.
2. $html
The html.

Usage

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

Defined (1)

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

/includes/mail.php  
  1. function wpcf7_special_mail_tag( $output, $name, $html ) { 
  2. $name = preg_replace( '/^wpcf7\./', '_', $name ); // for back-compat 
  3.  
  4. $submission = WPCF7_Submission::get_instance(); 
  5.  
  6. if ( ! $submission ) { 
  7. return $output; 
  8.  
  9. if ( '_remote_ip' == $name ) { 
  10. if ( $remote_ip = $submission->get_meta( 'remote_ip' ) ) { 
  11. return $remote_ip; 
  12. } else { 
  13. return ''; 
  14.  
  15. if ( '_user_agent' == $name ) { 
  16. if ( $user_agent = $submission->get_meta( 'user_agent' ) ) { 
  17. return $html ? esc_html( $user_agent ) : $user_agent; 
  18. } else { 
  19. return ''; 
  20.  
  21. if ( '_url' == $name ) { 
  22. if ( $url = $submission->get_meta( 'url' ) ) { 
  23. return esc_url( $url ); 
  24. } else { 
  25. return ''; 
  26.  
  27. if ( '_date' == $name || '_time' == $name ) { 
  28. if ( $timestamp = $submission->get_meta( 'timestamp' ) ) { 
  29. if ( '_date' == $name ) { 
  30. return date_i18n( get_option( 'date_format' ), $timestamp ); 
  31.  
  32. if ( '_time' == $name ) { 
  33. return date_i18n( get_option( 'time_format' ), $timestamp ); 
  34.  
  35. return ''; 
  36.  
  37. if ( '_post_' == substr( $name, 0, 6 ) ) { 
  38. $unit_tag = $submission->get_meta( 'unit_tag' ); 
  39.  
  40. if ( $unit_tag 
  41. && preg_match( '/^wpcf7-f(\d+)-p(\d+)-o(\d+)$/', $unit_tag, $matches ) ) { 
  42. $post_id = absint( $matches[2] ); 
  43.  
  44. if ( $post = get_post( $post_id ) ) { 
  45. if ( '_post_id' == $name ) { 
  46. return (string) $post->ID; 
  47.  
  48. if ( '_post_name' == $name ) { 
  49. return $post->post_name; 
  50.  
  51. if ( '_post_title' == $name ) { 
  52. return $html ? esc_html( $post->post_title ) : $post->post_title; 
  53.  
  54. if ( '_post_url' == $name ) { 
  55. return get_permalink( $post->ID ); 
  56.  
  57. $user = new WP_User( $post->post_author ); 
  58.  
  59. if ( '_post_author' == $name ) { 
  60. return $user->display_name; 
  61.  
  62. if ( '_post_author_email' == $name ) { 
  63. return $user->user_email; 
  64.  
  65. return ''; 
  66.  
  67. return $output;