wp_add_inline_style()包含以下redux动态css。
// redux dynamic css
global $x_redux_option;
$x_blogpost_overlay_switch = $ x_redux_option [' x_blogpost_overlay_switch];
$x_redux_dynamic_css = '
.single_post:hover{
background: ". if ($x_blogpost_overlay_switch == true): echo $x_blogpost_overlay; endif; ." ;
-webkit-box-shadow: " . if($x_blogpost_overlay_switch == true): ." 0 1px 10px 0 rgba(251,252,252,0.8) " . endif; ." ;
-moz-box-shadow: " . if($x_blogpost_overlay_switch == true): . " 0 1px 10px 0 rgba(251,252,252,0.8) " . endif; . " ;
box-shadow: " . if($x_blogpost_overlay_switch == true): . " 0 1px 10px 0 rgba(251,252,252,0.8) " . endif; . " ;
}
';
wp_add_inline_style( 'x-main-style', $x_redux_dynamic_css );
Mentor Themeforest插件显示以下错误:
必须为呈现它的上下文正确转义所有动态数据。在文件inc / scripts-styles.php,第213行:background:“。if($ x_blogpost_overlay_switch == true):echo $ x_blogpost_overlay; endif;。” ;
如何转义此动态($ x_blogpost_overlay)css属性值?
提前致谢。
答案 0 :(得分:1)
试试这种方式。
global $x_redux_option;
$x_blogpost_overlay_switch = $x_redux_option['x_blogpost_overlay_switch'];
// You must specify this variable as a valid CSS style.
$x_blogpost_overlay = 'white';
$x_redux_dynamic_css = '
.single_post:hover{
';
if ($x_blogpost_overlay_switch == true){
$x_redux_dynamic_css = $x_redux_dynamic_css . 'background: '. $x_blogpost_overlay . ';' .
'-webkit-box-shadow: 0 1px 10px 0 rgba(251,252,252,0.8);
-moz-box-shadow: 0 1px 10px 0 rgba(251,252,252,0.8);
box-shadow: 0 1px 10px 0 rgba(251,252,252,0.8);';
}
$x_redux_dynamic_css .= '}';
wp_add_inline_style( 'x-main-style', $x_redux_dynamic_css );