我有
return \'<button type="button" class="btn btn-success">Open Now</button>\';
如果我重复这一点,它会工作得很好。我收到了一个警告,好像echo没有逃逸就被使用了。我知道,这将是没有必要逃避这一点,因为它不是用户输入的东西。但是为了摆脱这个错误,我能做什么呢?我试过了esc_html($thehtmlabove);
不会对其进行渲染。它像文本一样打印-><button type="button" class="btn btn-success">Open Now</button>
有什么办法吗?
完整代码:
public function opening_hour_html()
{
$type = $this->shopstatus(); // this will be \'Open Now\' or \'Closed\'
if ($type == \'Open Now\') {
$wppl_open = __(\'Open Now\',\'arika\');
return \'<button type="button" class="btn btn-success">.\'$wppl_open\'.</button>\';
} else {
$wppl_closed = __(\'Closed\',\'arika\');
return \'<button type="button" class="btn btn-danger">.\'$wppl_closed\'.</button>\';
}
}