全局变量用于存储Wordpress Shortcodes中的所有CSS

时间:2015-12-27 19:53:56

标签: php wordpress wordpress-plugin wordpress-theming

我需要您的输入和洞察使用GLOBALS变量来存储通过Wordpress Shortcodes生成的所有CSS。我设计了使用以下css格式的Shortcode:

 <style>
      #divID1 .blah { /* code */}
      #divID2 .blah { /* code */}
 </style>

这很有效,但在通过https://validator.w3.org进行验证时,我不断收到如下错误:

 - Element style is missing required attribute scoped.

或有时..

 - Element style not allowed as child of element div in this context. (Suppressing further errors from this subtree.)

现在我的问题是如果我继续将动态CSS代码添加到一个变量$ GLOBALS ['custom-css']。='无论代码';

我可以在<head>内打印该变量。这是不安全的吗?或$ GLOBALS在许多主机上不起作用?或者它可能影响Wordpress网站,我不想冒险并最终不在许多不同的网络主机上工作。

有人可以解释和/或确认这是否是正确的方法。

0 个答案:

没有答案