function sharethis_block_library_info_alter in Sharethis block 8
Implements hook_library_info_alter().
File
- ./
sharethis_block.module, line 14 - Hook implementations for the sharethis_block module.
Code
function sharethis_block_library_info_alter(&$libraries, $extension) {
if ($extension == 'sharethis_block' && isset($libraries['sharethis.core'])) {
$config = \Drupal::config('sharethis_block.configuration');
// Get the property ID.
$property_id = $config
->get('sharethis_property');
// Determine the product type from the configuration.
$product_type = $config
->get('sharethis_inline') ? 'inline-share-buttons' : 'sticky-share-button';
$remote = str_replace('PROPERTYID', $property_id, $libraries['sharethis.core']['remote']);
$remote = str_replace('PRODUCT_TYPE', $product_type, $remote);
$libraries['sharethis.core']['remote'] = $remote;
$options = reset($libraries['sharethis.core']['js']);
$libraries['sharethis.core']['js'] = [
$libraries['sharethis.core']['remote'] => $options,
];
}
}