Posted by charos on September 23, 2009 at 9:04am
Jump to:
| Project: | AddThis |
| Version: | 6.x-2.7 |
| Component: | Code |
| Category: | feature request |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hi,
Although the first thought that comes to your mind is "if the node is not published , who is going to share it?" , chances that many news/article sites use Workflow for publication. With this IF statement , we make sure that nobody will make an "Addthis" to a "page denied" ! Merely a suggestion :)
Comments
#1
There will be more advanced admin settings in AddThis 3.0 and maybe this will be one of them. But for now you can check the node status in AddThis theme function.
Copy the function from module to you themes template.php and add an if to beginning. For example:
<?php
/**
* Theme the AddThis button.
*/
function YOURTHEME_addthis_button($node, $teaser) {
// Check that node is published.
if($node->status == 0) {
return;
}
global $_addthis_counter;
// Fix IE's bug.
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
drupal_add_link(array(
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => "http://s7.addthis.com/static/r07/widget02.css",
));
}
if (variable_get('addthis_dropdown_disabled', '0')) {
$button = sprintf('
<a class="addthis-button" href="http://www.addthis.com/bookmark.php"
onclick="addthis_url = location.href; addthis_title = document.title; return addthis_click(this);">
<img src="%s" width="%d" height="%d" alt="%s" class="%s" /></a>',
$_SERVER['HTTPS'] == 'on' ? addslashes(check_plain(variable_get('addthis_image_secure', 'https://secure.addthis.com/button1-share.gif'))) : 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'),
trim(check_plain(strip_tags(variable_get('addthis_image_attributes_alt', 'share')))),
trim(check_plain(strip_tags(variable_get('addthis_image_attributes_class', 'addthisimage'))))
);
}
else {
$button = sprintf('
<a class="addthis-button" 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" alt="%s" class="%s" /></a>',
$teaser ? url('node/'. $node->nid, array('absolute' => 1) ) : '[URL]',
$teaser ? addslashes($node->title) : '[TITLE]',
$_SERVER['HTTPS'] == 'on' ? addslashes(check_plain(variable_get('addthis_image_secure', 'https://secure.addthis.com/button1-share.gif'))) : 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'),
trim(check_plain(strip_tags(variable_get('addthis_image_attributes_alt', 'share')))),
trim(check_plain(strip_tags(variable_get('addthis_image_attributes_class', 'addthisimage'))))
);
if ($_addthis_counter == 1) {
$button .= sprintf('<script type="text/javascript" src="%s/js/%d/addthis_widget.js">',
$_SERVER['HTTPS'] == 'on' ? 'https://secure.addthis.com' : 'http://s7.addthis.com',
variable_get('addthis_widget_version', '152')
);
$button .= '</script>';
}
}
return $button;
}
?>
#2
Automatically closed -- issue fixed for 2 weeks with no activity.