You are here

better_social_sharing_buttons.module in Better Social Sharing Buttons 8

Same filename and directory in other branches
  1. 8.3 better_social_sharing_buttons.module

Add template file for the social buttons.

File

better_social_sharing_buttons.module
View source
<?php

/**
 * @file
 * Add template file for the social buttons.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_theme().
 *
 * Defines template files for the social sharing buttons module.
 */
function better_social_sharing_buttons_theme($existing, $type, $theme, $path) {
  return [
    'better_social_sharing_buttons' => [
      'variables' => [
        'items' => '',
      ],
      'template' => 'better-social-sharing-buttons',
      'path' => $path . '/theme',
    ],
  ];
}

/**
 * Implements hook_preprocess_HOOK().
 */
function better_social_sharing_buttons_preprocess_better_social_sharing_buttons(&$variables) {
  $config = \Drupal::config('better_social_sharing_buttons.settings');
  $variables['social_buttons_sprite'] = '/' . drupal_get_path('module', 'better_social_sharing_buttons') . '/assets/dist/sprites/' . $config
    ->get('iconset') . '.svg';
}

/**
 * Implements hook_help().
 *
 * @inheritdoc
 */
function better_social_sharing_buttons_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the better_social_sharing_buttons module.
    case 'help.page.better_social_sharing_buttons':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Add social sharing buttons to your website.') . '</p>';
      return $output;
    default:
  }
}