Changeset 10491 for trunk/src/bp-core/classes/class-bp-email.php
- Timestamp:
- 02/01/2016 07:44:36 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-email.php
r10489 r10491 244 244 245 245 case 'replace-tokens': 246 $retval = self::replace_tokens( $retval, $this->get_tokens( 'raw' ) );246 $retval = bp_core_replace_tokens_in_text( $retval, $this->get_tokens( 'raw' ) ); 247 247 // Fall through. 248 248 … … 949 949 return apply_filters( 'bp_email_validate', $retval, $this ); 950 950 } 951 952 953 /*954 * Utility functions.955 *956 * Unlike other methods in this class, utility functions are not chainable.957 */958 959 /**960 * Replace all tokens in the input with appropriate values.961 *962 * Unlike most other methods in this class, this one is not chainable.963 *964 * @since 2.5.0965 *966 * @param string $text967 * @param array $tokens Token names and replacement values for the $text.968 * @return string969 */970 public static function replace_tokens( $text, $tokens ) {971 $unescaped = array();972 $escaped = array();973 974 foreach ( $tokens as $token => $value ) {975 if ( is_callable( $value ) ) {976 $value = call_user_func( $value );977 }978 979 // Some tokens are objects or arrays for backwards compatibilty. See bp_core_deprecated_email_filters().980 if ( ! is_scalar( $value ) ) {981 continue;982 }983 984 $unescaped[ '{{{' . $token . '}}}' ] = $value;985 $escaped[ '{{' . $token . '}}' ] = esc_html( $value );986 }987 988 $text = strtr( $text, $unescaped ); // Do first.989 $text = strtr( $text, $escaped );990 991 /**992 * Filters text that has had tokens replaced.993 *994 * @since 2.5.0995 *996 * @param string $text997 * @param array $tokens Token names and replacement values for the $text.998 */999 return apply_filters( 'bp_email_replace_tokens', $text, $tokens );1000 }1001 951 }
Note: See TracChangeset
for help on using the changeset viewer.