responsive_share_buttons.module in Responsive Share Buttons 8
Same filename and directory in other branches
The responsive share buttons module.
File
responsive_share_buttons.moduleView source
<?php
/**
* @file
* The responsive share buttons module.
*/
use Drupal\Core\Block\BlockPluginInterface;
/**
* @file
* Module to enable CSS responsive share buttons.
*/
/**
* Implements hook_help().
*/
function responsive_share_buttons_help($path, $arg) {
$output = '';
switch ($path) {
case 'admin/config/modules#description':
$output .= t('Add a responsive social media share block to all pages.');
break;
case 'admin/config/user-interface/responsive_share_buttons':
$output .= t('<p>This is a simple module that adds a social media block to all pages.</p>');
break;
}
return $output;
}
/**
* Implements hook_contextual_links_view_alter().
*/
function responsive_share_buttons_contextual_links_view_alter(&$element, $items) {
$block = isset($element['#element']['#block']) ? $element['#element']['#block'] : NULL;
if (is_object($block) && $block->module == 'responsive_share_buttons') {
if ($block->delta == 'share' && user_access('configure responsive share buttons')) {
$element['#links']['responsive_share_buttons'] = [
'title' => t('Configure responsive share buttons'),
'href' => 'admin/config/user-interface/responsive_share_buttons',
'query' => drupal_get_destination(),
'attributes' => [
'title' => t('Configure the responsive share buttons links.'),
],
];
}
}
}
/**
* Implements hook_block_view_BASE_BLOCK_ID_alter().
*/
function responsive_share_buttons_block_view_responsive_sharing_buttons_alter(array &$build, BlockPluginInterface $block) {
// Add a contextual link for setting the module config.
$build['#contextual_links']['responsive_share_buttons'] = [
'route_parameters' => [
'responsive_share_buttons' => 'responsive_share_buttons',
],
];
}
Functions
Name | Description |
---|---|
responsive_share_buttons_block_view_responsive_sharing_buttons_alter | Implements hook_block_view_BASE_BLOCK_ID_alter(). |
responsive_share_buttons_contextual_links_view_alter | Implements hook_contextual_links_view_alter(). |
responsive_share_buttons_help | Implements hook_help(). |