Skip to content

Instantly share code, notes, and snippets.

@Ravenna
Created August 22, 2016 15:47
Show Gist options
  • Select an option

  • Save Ravenna/fa02066f7a4d530e3e0a55d3a37eba1b to your computer and use it in GitHub Desktop.

Select an option

Save Ravenna/fa02066f7a4d530e3e0a55d3a37eba1b to your computer and use it in GitHub Desktop.
// ASSUMING [button link="some-slug" text="Linked Te" offsite="true/false"]
function button_shortcode( $buttonAtts ){
$button = shortcode_atts( array(
'link' => '',
'text' => '',
'offsite' => ''
), $buttonAtts );
$target;
$targetOption = $button['offsite'];
if($targetOption == 'true'){
$target = '_blank';
}
$out = '<a href="'. $button['link'] .'" target="'. $target .'" class="button">'.$button['text'].'</a>';
return html_entity_decode($out, ENT_COMPAT, 'UTF-8');
}
add_shortcode( 'button', 'button_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment