通过*符号生成工具提示

时间:2014-03-31 12:03:04

标签: php html wordpress

我有以下PHP代码:

function word_filter()
{
$tt_tijdelijke = '';
$tt_gestoffeerd = '';
$tt_gemeubileerd = '';

str_replace('tijdelijke', '<span class="incexc-single" tooltip="'.$tt_tijdelijke.'">tijdelijke</span>');
str_replace('gestoffeerd', '<span class="incexc-single" tooltip="'.$tt_gestoffeerd.'">gestoffeerd</span>');
str_replace('gemeubileerd', '<span class="incexc-single" tooltip="'.$tt_gemeubileerd.'">gemeubileerd</span>');
return true;
}
add_filter('wordfilter','word_filter');

我需要在网站的每个页面上运行,用相同的单词替换所有单词,但插入跨度。这样做可以在我将鼠标悬停在单词上时显示工具提示。

鼠标悬停和工具提示已经有效,但我无法弄清楚如何让替换在所有页面上都有效。

如何在不造成太多页面加载的情况下最好地调用此函数?

1 个答案:

答案 0 :(得分:0)

我认为你可以使用javascript split。代码将提醒文本,但您可以更改它并将其用于工具提示。

var txt = 'Word*tooltip';
alert(txt.split("*")[1]);