wp_staticize_emoji_for_email

Convert emoji in emails into static images.

Description

(array) wp_staticize_emoji_for_email( (array) $mail ); 

Returns (array)

The email data array, with emoji in the message staticized.

Parameters (1)

0. $mail (array)
The email data array.

Usage

  1. if ( !function_exists( 'wp_staticize_emoji_for_email' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // The email data array. 
  5. $mail = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_staticize_emoji_for_email($mail); 
  9.  

Defined (1)

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

/wp-includes/formatting.php  
  1. function wp_staticize_emoji_for_email( $mail ) { 
  2. if ( ! isset( $mail['message'] ) ) { 
  3. return $mail; 
  4.  
  5. /** 
  6. * We can only transform the emoji into images if it's a text/html email. 
  7. * To do that, here's a cut down version of the same process that happens 
  8. * in wp_mail() - get the Content-Type from the headers, if there is one,  
  9. * then pass it through the wp_mail_content_type filter, in case a plugin 
  10. * is handling changing the Content-Type. 
  11. */ 
  12. $headers = array(); 
  13. if ( isset( $mail['headers'] ) ) { 
  14. if ( is_array( $mail['headers'] ) ) { 
  15. $headers = $mail['headers']; 
  16. } else { 
  17. $headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) ); 
  18.  
  19. foreach ( $headers as $header ) { 
  20. if ( strpos($header, ':') === false ) { 
  21. continue; 
  22.  
  23. // Explode them out. 
  24. list( $name, $content ) = explode( ':', trim( $header ), 2 ); 
  25.  
  26. // Cleanup crew. 
  27. $name = trim( $name ); 
  28. $content = trim( $content ); 
  29.  
  30. if ( 'content-type' === strtolower( $name ) ) { 
  31. if ( strpos( $content, ';' ) !== false ) { 
  32. list( $type, $charset ) = explode( ';', $content ); 
  33. $content_type = trim( $type ); 
  34. } else { 
  35. $content_type = trim( $content ); 
  36. break; 
  37.  
  38. // Set Content-Type if we don't have a content-type from the input headers. 
  39. if ( ! isset( $content_type ) ) { 
  40. $content_type = 'text/plain'; 
  41.  
  42. /** This filter is documented in wp-includes/pluggable.php */ 
  43. $content_type = apply_filters( 'wp_mail_content_type', $content_type ); 
  44.  
  45. if ( 'text/html' === $content_type ) { 
  46. $mail['message'] = wp_staticize_emoji( $mail['message'] ); 
  47.  
  48. return $mail;