Check if variable used to trigger popup

Hello I’m working on a wordpress site and I currently have a popup set to display if an arrtibute in the shortcode is set to “popup=”register”)… I added another lightbox that I want to display if the attribute is set to “popup=”apply”)

My question is how to add another variable to the following function.. would I need an if statement? Im new to php, any advice is greatly appreciated.. Thanks!!!!

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



    }

What i’m looking to add is:

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

Related posts

Leave a Reply

1 comment

  1. Try using this codes..Hope it helps you

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