Skip to content

Instantly share code, notes, and snippets.

@klaasvw
Created October 10, 2013 10:28
Show Gist options
  • Save klaasvw/6916283 to your computer and use it in GitHub Desktop.
Save klaasvw/6916283 to your computer and use it in GitHub Desktop.
Fix missing addthis toolbox buttons
<?php
/**
* Implements hook_addthis_markup_alter().
*
* Fix addthis bug where services aren't added.
*/
function your_module_addthis_markup_alter(&$markup) {
if (isset($markup['#display']['type']) && $markup['#display']['type'] == 'addthis_basic_toolbox') {
$addthis_services = array_filter(variable_get('addthis_enabled_services', array()));
$markup['#display']['settings']['share_services'] = implode(',', $addthis_services);
// If you need custom labels.
$labels = array(
'google_plusone_share' => 'google+',
);
if (function_exists('addthis_displays_addthis_display_markup__addthis_basic_toolbox')) {
$markup = addthis_displays_addthis_display_markup__addthis_basic_toolbox($markup);
// Set a label for each service.
foreach (element_children($markup) as $service) {
if (empty($markup[$service]['#value'])) {
if (isset($labels[$markup[$service]['#addthis_service']])) {
$markup[$service]['#value'] = $labels[$markup[$service]['#addthis_service']];
}
else {
$markup[$service]['#value'] = $markup[$service]['#addthis_service'];
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment