From 1af1bd9c09d565620dde8c8cef71fdeb24b0f0eb Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 11 May 2015 14:06:31 -0700 Subject: [PATCH] Include hashtags and account in twitter share. --- e107_plugins/social/admin_config.php | 1 + e107_plugins/social/e_shortcode.php | 32 +++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/e107_plugins/social/admin_config.php b/e107_plugins/social/admin_config.php index 8e4fed9c5..2f450a212 100644 --- a/e107_plugins/social/admin_config.php +++ b/e107_plugins/social/admin_config.php @@ -84,6 +84,7 @@ class social_ui extends e_admin_ui 'twitter_menu_limit' => array('title'=> 'Limit', 'type'=>'number', 'tab'=>2, 'data' => 'int','help'=>'Number of tweets to display.'), 'sharing_mode' => array('title'=> 'Display Mode', 'type'=>'dropdown', 'tab'=>0, 'writeParms'=>array('optArray'=>array('normal'=>'Normal','dropdown'=>'Dropdown','off'=>'Disabled')), 'data' => 'str','help'=>''), + 'sharing_hashtags' => array('title'=> 'Hashtags', 'type'=>'tags', 'tab'=>0, 'data' => 'str','help'=>'Excluding the # symbol.'), 'sharing_providers' => array('title'=> 'Providers', 'type'=>'checkboxes', 'tab'=>0, 'writeParms'=>array(), 'data' => 'str','help'=>''), ); diff --git a/e107_plugins/social/e_shortcode.php b/e107_plugins/social/e_shortcode.php index 3df7cb8f6..5ea5f6689 100644 --- a/e107_plugins/social/e_shortcode.php +++ b/e107_plugins/social/e_shortcode.php @@ -138,7 +138,7 @@ class social_shortcodes extends e_shortcode return ''; } - + $hashtags = vartrue($pref['sharing_hashtags']); $defaultUrl = vartrue($this->var['url'], e_REQUEST_URL); $defaultTitle = vartrue($this->var['title'], deftrue('e_PAGETITLE'). " | ". SITENAME); @@ -186,10 +186,16 @@ class social_shortcodes extends e_shortcode { $butSize = 'btn-social'; } - + $opt = array(); - + + + + $hashtags = str_replace(array(" ",'#'),"", $hashtags); // "#mytweet"; + $twitterAccount = basename(XURL_TWITTER); + + // return print_a($hashtags,true); foreach($providers as $k=>$val) { @@ -199,8 +205,24 @@ class social_shortcodes extends e_shortcode } $pUrl = str_replace("&","&",$val['url']); - + $shareUrl = $tp->lanVars($pUrl,$data); + + if($k == 'twitter') + { + if(!empty($hashtags)) + { + $shareUrl .= "&hashtags=".rawurlencode($hashtags); + } + + if(!empty($twitterAccount)) + { + $shareUrl .= "&via=".$twitterAccount; + } + + } + + $opt[$k] = "".$tp->toIcon($val["icon"]).""; } @@ -249,7 +271,7 @@ class social_shortcodes extends e_shortcode { $ns = e107::getRender(); - $account = dirname(XURL_TWITTER); + $account = basename(XURL_TWITTER); //data-related="twitterapi,twitter" $text = 'Tweets by @'.$account.'';