Changeset 31860
- Timestamp:
- 03/22/2015 11:15:34 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r31852 r31860 4245 4245 */ 4246 4246 function _wp_staticize_emoji_for_email( $mail ) { 4247 if ( isset( $mail['message'] ) ) { 4247 if ( ! isset( $mail['message'] ) ) { 4248 return $mail; 4249 } 4250 4251 /* 4252 * We can only transform the emoji into images if it's a text/html email. 4253 * To do that, here's a cut down version of the same process that happens 4254 * in wp_mail() - get the Content-Type from the headers, if there is one, 4255 * then pass it through the wp_mail_content_type filter, in case a plugin 4256 * is handling changing the Content-Type. 4257 */ 4258 $headers = array(); 4259 if ( isset( $mail['headers'] ) ) { 4260 if ( is_array( $mail['headers'] ) ) { 4261 $headers = $mail['headers']; 4262 } else { 4263 $headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) ); 4264 } 4265 } 4266 4267 foreach ( $headers as $header ) { 4268 if ( strpos($header, ':') === false ) { 4269 continue; 4270 } 4271 4272 // Explode them out 4273 list( $name, $content ) = explode( ':', trim( $header ), 2 ); 4274 4275 // Cleanup crew 4276 $name = trim( $name ); 4277 $content = trim( $content ); 4278 4279 if ( 'content-type' === strtolower( $name ) ) { 4280 if ( strpos( $content, ';' ) !== false ) { 4281 list( $type, $charset ) = explode( ';', $content ); 4282 $content_type = trim( $type ); 4283 } else { 4284 $content_type = trim( $content ); 4285 } 4286 break; 4287 } 4288 } 4289 4290 // Set Content-Type if we don't have a content-type from the input headers 4291 if ( ! isset( $content_type ) ) { 4292 $content_type = 'text/plain'; 4293 } 4294 4295 /** This filter is documented in wp-includes/pluggable.php */ 4296 $content_type = apply_filters( 'wp_mail_content_type', $content_type ); 4297 4298 if ( 'text/html' === $content_type ) { 4248 4299 $mail['message'] = wp_staticize_emoji( $mail['message'], true ); 4249 4300 } 4301 4250 4302 return $mail; 4251 4303 }
Note: See TracChangeset
for help on using the changeset viewer.