WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Sharebar] Titles with Characters or "." in them break in twitter

[Plugin: Sharebar] Titles with Characters or "." in them break in twitter

  • This is more of a feature request than an issue – but unfortunately, because of the way the plugin just uses the post title, if a writer includes any characters like “&” “‘” “.com” “%” etc… it breaks the twitter button. Is there a way that you could encode these prior to passing on to the buttons? I hope that makes sense. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Well, I fixed it. Feel free to change the code in the plugin where it has.

    function sharebar_filter($input){
    	global $post;
    	$code = array('[title]','[url]','[author]','[twitter]');
    	$values = array($post->post_title,get_permalink(),get_the_author(),get_option('sharebar_twitter_username'));
    	return str_replace($code,$values,$input);
    }

    Change it to

    function sharebar_filter($input){
    global $post;
    $code = array('[title]','[url]','[author]','[twitter]');
    <em>$meta = strip_tags($post->post_title);
    $meta = str_replace(array(<strong>ELEMENTS_HERE</strong>),array(<strong>REPLACEMENTS_HERE</strong>), $meta);</em>
    $values = array(<em>$meta</em>,get_permalink(),get_the_author(),get_option('sharebar_twitter_username'));
    return str_replace($code,$values,$input);
    }

    Sorry, ignore the bolding and in the second code example – should be

    function sharebar_filter($input){
    global $post;
    $code = array('[title]','[url]','[author]','[twitter]');
    $meta = strip_tags($post->post_title);
    $meta = str_replace(array("\"","”","“","&","%","\n","\r","\t"),array("'","'","'","and"," Percent","'","'","'"), $meta);
    $values = array($meta,get_permalink(),get_the_author(),get_option('sharebar_twitter_username'));
    return str_replace($code,$values,$input);
    }

    Obviously – you can change the array to suit your needs.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Sharebar] Titles with Characters or "." in them break in twitter’ is closed to new replies.