Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chasereeves/1a5f383bc453ad1cee7d3a1d916cacd4 to your computer and use it in GitHub Desktop.
Save chasereeves/1a5f383bc453ad1cee7d3a1d916cacd4 to your computer and use it in GitHub Desktop.
// [quotable]"Here's my quote."[/quotable]
// [quotable link="" class="" link_class=""]"Here's my quote."[/quotable]
// if link says 'no', use only content, no permalink
//=========================================================== TWEET THIS SHORTCODE
function quotable_shortcode( $atts, $content = null ) {
extract(shortcode_atts(array(
'class' => 'no_lede',
'link' => '',
'link_class' => '',
), $atts));
$return_string = '';
if(isset($content)) {
$content = strip_tags($content);
if (empty($link)) $link = get_permalink();
$return_string = "<blockquote class='$class quotable'><p class='$class'>$content<br />
<a target='_blank' class='twitter icon_btn $link_class'
href='https://twitter.com/intent/tweet?text=$content&url=$link&via=fizzle'
title='Click to share on Twitter!'><span>Tweet This</span>
</a></p></blockquote>";
}
return $return_string;
}
add_shortcode('quotable', 'quotable_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment