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


Check if variable used to trigger popup

你好,我正在一个wordpress网站上工作,如果短代码中的arrtibute设置为"popup="register"),我目前有一个弹出窗口设置要显示……我添加了另一个灯箱,如果属性设置为"popup="apply")

我的问题是如何将另一个变量添加到以下函数中。。我需要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>';

    }

我想添加的是:

$popup = ('apply' == $popup) ? ' onclick="jQuery(''#applyid, .overlayLogin'').show();"' : '';

尝试使用这些代码。。希望它能帮助你

  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>';

}