我正在研究 wordpress 主题并与回显自定义 css 混淆。我不知道清理自定义 css 的确切方法。请帮助我!!如何转义自定义 CSS??
WARNING: Found echo ($ in the file functions.php. Possible data validation issues found. All dynamic data must be correctly escaped for the context where it is rendered.
Line 222: echo ($css_output);
谢谢!!
最佳答案
你可以简单地使用函数esc_attr
,检查下面的例子,我已经使用函数implode
来提取数组,然后用esc_attr安全地转义它
。
$css_output = ['.hello-world { color: red }', '.test { font-size: 12px; }'];
echo esc_attr(implode(' ', $css_output));
** 已更新 **
对于 ThemeForest 提交,您应该使用 wp_add_inline_style
,在您的情况下,这应该是正确的代码。
wp_add_inline_style('your-wp-style', $css_output);
确保将内联样式添加到您已经排队的 CSS 文件之一。
关于css - 从 enavto 主题检查插件收到有关自定义 css 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51587356/