Php 检查变量是否用于触发弹出窗口

Php 检查变量是否用于触发弹出窗口,php,wordpress,if-statement,Php,Wordpress,If Statement,您好,我正在wordpress网站上工作,如果短代码中的arrtibute设置为“popup=”register“…我添加了另一个lightbox,如果属性设置为“popup=”apply“,我将显示该lightbox) 我的问题是如何将另一个变量添加到以下函数中。。我需要if声明吗?我是php新手,非常感谢您的建议。。谢谢 function oxy_shortcode_button_fancy($atts , $content = '' ) { // setup options

您好,我正在wordpress网站上工作,如果短代码中的arrtibute设置为“popup=”register“…我添加了另一个lightbox,如果属性设置为“popup=”apply“,我将显示该lightbox)

我的问题是如何将另一个变量添加到以下函数中。。我需要if声明吗?我是php新手,非常感谢您的建议。。谢谢

function oxy_shortcode_button_fancy($atts , $content = '' ) {
     // setup options
    extract( shortcode_atts( array(
        'button_swatch'     => 'swatch-coral',
        'button_animation'  => '',
        'size'              => 'default',
        'xclass'            => '',
        'link'              => '',
        'label'             => 'My button',
        'icon'              => '',
        'link_open'         => '_self',
        'popup'             => ''
    ), $atts ) );

    $popup = ('register' == $popup) ? ' onclick="jQuery(\'#registerid, .overlayLogin\').show();"' : '';
    $animation = ( $button_animation != "") ? ' data-animation="'.$button_animation.'"' :"";
    return '<a'.$popup.' href="'. $link .'" class="btn '. $size.' btn-icon-right '. $xclass . ' '. $button_swatch .'" target="' . $link_open . '"> '. $label . '<span><i class="'.$icon.'" '.$animation.'></i></span></a>';



    }

尝试使用这些代码。希望它对您有所帮助

  function oxy_shortcode_button_fancy($atts , $content = '' ) {
 // setup options
extract( shortcode_atts( array(
    'button_swatch'     => 'swatch-coral',
    'button_animation'  => '',
    'size'              => 'default',
    'xclass'            => '',
    'link'              => '',
    'label'             => 'My button',
    'icon'              => '',
    'link_open'         => '_self',
    'popup'             => ''
), $atts ) );


 if('register' == $popup) {
$popup = ('register' == $popup) ? ' onclick="jQuery(\'#registerid, .overlayLogin\').show();"' : '';
} else {
$popup = ('apply' == $popup) ? ' onclick="jQuery(\'#applyid, .overlayLogin\').show();"' : '';
}
$animation = ( $button_animation != "") ? ' data-animation="'.$button_animation.'"' :"";
return '<a'.$popup.' href="'. $link .'" class="btn '. $size.' btn-icon-right '. $xclass . ' '. $button_swatch .'" target="' . $link_open . '"> '. $label . '<span><i class="'.$icon.'" '.$animation.'></i></span></a>';



}
function oxy\u shortcode\u button\u fancy($atts,$content=''){
//设置选项
提取(短码)附件(数组)(
“button_swatch”=>“swatch coral”,
'按钮动画'=>'',
“大小”=>“默认值”,
“xclass'=>”,
'链接'=>'',
“标签”=>“我的按钮”,
'图标'=>'',
'link_open'=>'u self',
“弹出窗口”=>“
)美元(附件);;
如果('register'=$popup){
$popup=('register'=$popup)?'onclick=“jQuery(\'\'\\\\'registerid,.overlayLogin\”).show();“:”;
}否则{
$popup=('apply'=$popup)“:”;
}
$animation=($button_animation!=”)?“数据动画=”。$button_animation.“:”;
返回“”;
}

尝试使用此代码。希望对您有所帮助

  function oxy_shortcode_button_fancy($atts , $content = '' ) {
 // setup options
extract( shortcode_atts( array(
    'button_swatch'     => 'swatch-coral',
    'button_animation'  => '',
    'size'              => 'default',
    'xclass'            => '',
    'link'              => '',
    'label'             => 'My button',
    'icon'              => '',
    'link_open'         => '_self',
    'popup'             => ''
), $atts ) );


 if('register' == $popup) {
$popup = ('register' == $popup) ? ' onclick="jQuery(\'#registerid, .overlayLogin\').show();"' : '';
} else {
$popup = ('apply' == $popup) ? ' onclick="jQuery(\'#applyid, .overlayLogin\').show();"' : '';
}
$animation = ( $button_animation != "") ? ' data-animation="'.$button_animation.'"' :"";
return '<a'.$popup.' href="'. $link .'" class="btn '. $size.' btn-icon-right '. $xclass . ' '. $button_swatch .'" target="' . $link_open . '"> '. $label . '<span><i class="'.$icon.'" '.$animation.'></i></span></a>';



}
function oxy\u shortcode\u button\u fancy($atts,$content=''){
//设置选项
提取(短码)附件(数组)(
“button_swatch”=>“swatch coral”,
'按钮动画'=>'',
“大小”=>“默认值”,
“xclass'=>”,
'链接'=>'',
“标签”=>“我的按钮”,
'图标'=>'',
'link_open'=>'u self',
“弹出窗口”=>“
)美元(附件);;
如果('register'=$popup){
$popup=('register'=$popup)?'onclick=“jQuery(\'\'\\\\'registerid,.overlayLogin\”).show();“:”;
}否则{
$popup=('apply'=$popup)“:”;
}
$animation=($button_animation!=”)?“数据动画=”。$button_animation.“:”;
返回“”;
}

你说得对..照你说的做there@VaibhavBhanushali当添加到第一个$popup=('register'=$popup')的正下方时,它不起作用…您是否使用if-else语句进行检查?您是对的..按照您提到的方式执行there@VaibhavBhanushali当添加到第一个$popup=('register'=$popup)的正下方时,它不起作用…您是否使用if else语句进行检查?