function bctt_shortcode($atts) { extract(shortcode_atts(array('tweet' => '', 'via' => 'yes', 'url' => 'yes'), $atts)); $handle = get_option('bctt-twitter-handle'); if (!empty($handle) && $via != 'no') { $handle_code = "&via=" . $handle . "&related=" . $handle; } else { $handle_code = ''; } $text = $tweet; if ($url != 'no') { if (get_option('bctt-short-url') != false) { $bcttURL = '&url=' . wp_get_shortlink(); } else { $bcttURL = '&url=' . get_permalink(); } } else { $bcttURL = ''; } $bcttBttn = sprintf(__('Click To Tweet', 'better-click-to-tweet')); $short = bctt_shorten($text, 117 - (6 + mb_strlen($handle))); if (!is_feed()) { return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank'>" . $short . "</a></span><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . "&url=" . $bcttURL . "' target='_blank' class='bctt-ctt-btn'>" . $bcttBttn . "</a></div>"; } else { return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'>" . $bcttBttn . "</a><br /><hr />"; } }
function bctt_shortcode($atts, $content) { $handle = get_option('bctt-twitter-handle'); if (!empty($handle)) { $handle_code = "&via=" . $handle . "&related=" . $handle; } else { $handle_code = $handle; } extract(shortcode_atts(array('tweet' => '$content', 'handle' => '$handle_code'), $atts)); $text = $tweet; $short = bctt_shorten($text, 118 - strlen($handle_code)); return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . "&url=" . get_permalink() . "' target='_blank'>" . $short . "</a></span><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . "&url=" . get_permalink() . "' target='_blank' class='bctt-ctt-btn'>Click To Tweet</a></div>"; }
function bctt_shortcode($atts, $content) { $handle = get_option('bctt-twitter-handle'); if (!empty($handle)) { $handle_code = "&via=" . $handle . "&related=" . $handle; } else { $handle_code = $handle; } extract(shortcode_atts(array('tweet' => '$content'), $atts)); $text = $tweet; $bcttBttn = sprintf(__('Click To Tweet', 'better-click-to-tweet')); $short = bctt_shorten($text, 117 - mb_strlen($handle)); if (!is_feed()) { return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . "&url=" . get_permalink() . "' target='_blank'>" . $short . "</a></span><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . "&url=" . get_permalink() . "' target='_blank' class='bctt-ctt-btn'>" . $bcttBttn . "</a></div>"; } else { return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . "&url=" . get_permalink() . "' target='_blank' class='bctt-ctt-btn'>" . $bcttBttn . "</a><br /><hr />"; } }
function bctt_shortcode($atts) { extract(shortcode_atts(array('tweet' => '', 'via' => 'yes', 'url' => 'yes', 'nofollow' => 'no'), $atts)); $handle = get_option('bctt-twitter-handle'); if (function_exists('mb_internal_encoding')) { $handle_length = 6 + mb_strlen($handle); } else { $handle_length = 6 + strlen($handle); } if (!empty($handle) && $via != 'no') { $handle_code = "&via=" . $handle . "&related=" . $handle; } else { $handle_code = ''; } if ($via != 'yes') { $handle = ''; $handle_code = ''; $handle_length = 0; } $text = $tweet; if (filter_var($url, FILTER_VALIDATE_URL)) { $bcttURL = '&url=' . $url; } elseif ($url != 'no') { if (get_option('bctt-short-url') != false) { $bcttURL = '&url=' . wp_get_shortlink(); } else { $bcttURL = '&url=' . get_permalink(); } } else { $bcttURL = ''; } $bcttBttn = sprintf(_x('Click To Tweet', 'Text for the box on the reader-facing box', 'better-click-to-tweet')); if ($url != 'no') { $short = bctt_shorten($text, 117 - $handle_length); } else { $short = bctt_shorten($text, 140 - $handle_length); } if ($nofollow != 'no') { $rel = "rel='nofollow'"; } else { $rel = ''; } if (!is_feed()) { return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank'" . $rel . ">" . $short . " </a></span><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'" . $rel . ">" . $bcttBttn . "</a></div>"; } else { return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'" . $rel . ">" . $bcttBttn . "</a><br /><hr />"; } }