function _addthis_create_button in AddThis 5.2
Same name and namespace in other branches
- 6.2 addthis.module \_addthis_create_button()
- 7.2 addthis.module \_addthis_create_button()
Internal function to generate code for AddThis button
Return value
String containing html code for the button
2 calls to _addthis_create_button()
- addthis_block in ./
addthis.module - Implementation of hook_block().
- addthis_link in ./
addthis.module - Implementation of hook_link().
File
- ./
addthis.module, line 191 - Stand alone module file to handle AddThis button integration
Code
function _addthis_create_button($node = NULL, $teaser = FALSE) {
global $addthis_counter;
$addthis_counter++;
if ($addthis_counter == 1) {
drupal_add_css(drupal_get_path('module', 'addthis') . '/addthis.css');
drupal_add_js(sprintf('
addthis_pub = \'%s\';
addthis_logo = \'%s\';
addthis_logo_background = \'%s\';
addthis_logo_color = \'%s\';
addthis_brand = \'%s\';
addthis_options = \'%s\';
', addslashes(check_plain(variable_get('addthis_username', 'my-username'))), addslashes(check_plain(variable_get('addthis_logo', 'http://www.addthis.com/images/yourlogo.png'))), addslashes(check_plain(variable_get('addthis_logo_background', 'EFEFFF'))), addslashes(check_plain(variable_get('addthis_logo_color', '666699'))), addslashes(check_plain(variable_get('addthis_brand', 'Your Site'))), addslashes(check_plain(variable_get('addthis_options', 'favorites, email, digg, delicious, myspace, facebook, google, live, more')))), 'inline');
}
return sprintf('
<div class="addthis"><a href="http://www.addthis.com/bookmark.php"
onmouseover="return addthis_open(this, \'\', \'%s\', \'%s\')"
onmouseout="addthis_close()"
onclick="return addthis_sendto()"><img src="%s" width="%d" height="%d" %s /></a></div>
<script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
', $teaser ? url('node/' . $node->nid) : '[URL]', $teaser ? addslashes($node->title) : '[TITLE]', addslashes(check_plain(variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif'))), variable_get('addthis_image_width', '125'), variable_get('addthis_image_height', '16'), filter_xss(variable_get('addthis_image_attributes', 'alt=""')));
}