1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Include hashtags and account in twitter share.

This commit is contained in:
Cameron
2015-05-11 14:06:31 -07:00
parent d85bc31932
commit 1af1bd9c09
2 changed files with 28 additions and 5 deletions

View File

@@ -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'=>''),
);

View File

@@ -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] = "<a class='e-tip btn ".$butSize." btn-default social-share' target='_blank' title='".$val["title"]."' href='".$shareUrl."'>".$tp->toIcon($val["icon"])."</a>";
}
@@ -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 = '<a class="twitter-timeline" href="'.XURL_TWITTER.'" data-widget-id="'.varset($parm['id']).'" data-theme="'.varset($parm['theme'],'light').'" data-link-color="#cc0000" data-aria-polite="assertive" width="100%" height="'.varset($parm['height'],300).'" lang="'.e_LAN.'">Tweets by @'.$account.'</a>';