summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/token.inc7
1 files changed, 6 insertions, 1 deletions
diff --git a/includes/token.inc b/includes/token.inc
index edc8a962f..0b05c68f4 100644
--- a/includes/token.inc
+++ b/includes/token.inc
@@ -77,8 +77,13 @@
* Text with tokens replaced.
*/
function token_replace($text, array $data = array(), array $options = array()) {
+ $text_tokens = token_scan($text);
+ if (empty($text_tokens)) {
+ return $text;
+ }
+
$replacements = array();
- foreach (token_scan($text) as $type => $tokens) {
+ foreach ($text_tokens as $type => $tokens) {
$replacements += token_generate($type, $tokens, $data, $options);
if (!empty($options['clear'])) {
$replacements += array_fill_keys($tokens, '');