Woocommerce 在href中包含onclick操作
我有一个woocommerce网站商店,在那里我尝试在变体标签中包含一个setAttribute('open','true') 但是,返回标签时会出现错误: 分析错误:语法错误,第95行的…/shortcode.php中出现意外的“open”(T_字符串) 我将引号改为双引号,反之亦然,但没有解决它Woocommerce 在href中包含onclick操作,woocommerce,variations,setattribute,Woocommerce,Variations,Setattribute,我有一个woocommerce网站商店,在那里我尝试在变体标签中包含一个setAttribute('open','true') 但是,返回标签时会出现错误: 分析错误:语法错误,第95行的…/shortcode.php中出现意外的“open”(T_字符串) 我将引号改为双引号,反之亦然,但没有解决它 add_filter( 'woocommerce_attribute_label' , 'modify_the_attribute_filter' , 10 , 3 ); function mod
add_filter( 'woocommerce_attribute_label' , 'modify_the_attribute_filter' , 10 , 3 );
function modify_the_attribute_filter( $label , $name , $product ){
$id = get_the_id();
if ( ($id ==189 || $id == 32 || $id == 754) && !is_admin() ){
if( $label == 'Lunch' ){
$label .= '<a class="extra_label" href="#anchor" onclick="det.setAttribute('open', 'true'); return false;">i</a>';
}
else {
$label .= '<a class="extra_label" href="#anchor">i</a>';
}
}
return $label;
}
add_filter('woocommerce_属性_label','modify_属性_filter',10,3);
函数修改属性过滤器($label、$name、$product){
$id=get_the_id();
if($id==189 | |$id==32 | |$id==754)和&!is|u admin(){
如果($label==“午餐”){
$label.='';
}
否则{
$label.='';
}
}
返回$label;
}
目标是每个变体标签都包含一个可单击的项目,该项目是页面上某个点的锚定,同时打开一个详细信息摘要框。您是否尝试按以下方式转义引号
$label .= '<a class="extra_label" href="#anchor" onclick="det.setAttribute(\'open\', \'true\'); return false;">i</a>';
$label.='';
虽然没有错误,但url中没有传递任何内容。我想这个过滤器里有消毒措施。。。