function get_button_HTML in ShareThis 7
get_button_HTML is the function that creates the ShareThis code It returns the appropriate html based on your settings.
2 calls to get_button_HTML()
- sharethis_block_contents in sharethis_block/
sharethis_block.module - custom html block
- sharethis_node_view in ./
sharethis.module - Implements hook_node_view.
File
- ./
sharethis.module, line 343 - A module that adds one of the ShareThis widget to your website.
Code
function get_button_HTML($data_options, $mPath, $mTitle) {
// The share buttons are simply spans of the form class='st_SERVICE_BUTTONTYPE' -- "st" stands for ShareThis.
$type = substr($data_options['buttons'], 4);
$type = $type == "_" ? "" : $type;
$service_array = explode(",", $data_options['services']);
$st_spans = "";
for ($i = 0; $i < sizeof($service_array); $i++) {
// Strip the quotes from the element in the array (They are there for javascript)
$service = explode(":", $service_array[$i]);
$serviceCodeName = substr($service[1], 0, -1);
$display = "displaytext=";
$display .= $service[0] . "\"";
$display = $type == "" ? "" : $display;
$st_spans .= "<span st_url={$mPath} st_title='{$mTitle}' class='st_{$serviceCodeName}{$type}' {$display}></span>";
}
// These are the ShareThis scripts:
// If switchTo5x is set to false, then the "classic" widget will be selected.
$is_five = $data_options['widget'] == 'st_multi' ? 'true' : 'false';
$publisher_id = $data_options['publisherID'];
$st_js = "<script type='text/javascript'>var switchTo5x={$is_five};</script>\n <script type='text/javascript' src='http://w.sharethis.com/button/buttons.js'></script>\n <script type='text/javascript'>stLight.options({publisher:'{$publisher_id}'});</script>";
return $st_spans . $st_js;
}