You are here

whatsappshare.module in Whatsapp Share 8

File

whatsappshare.module
View source
<?php

/**
 * Implements hook_page_attachments().
 */
function whatsappshare_page_attachments(array &$attachments) {
  $attachments['#attached']['library'][] = 'whatsappshare/whatsappshare';
}

/**
 * Implements hook_preprocess_html().
 */
function whatsappshare_preprocess_html(&$variables) {
  global $base_url;
  $whatsappshareConfig = \Drupal::config('whatsappshare.adminsettings');
  $whatsappshare_button_text = $whatsappshareConfig
    ->get('whatsappshare_button_text');
  $whatsappshare_button_size = $whatsappshareConfig
    ->get('whatsappshare_button_size');
  $whatsappshare_sharing_text = $whatsappshareConfig
    ->get('whatsappshare_sharing_text');
  $whatsappshare_sharing_location = $whatsappshareConfig
    ->get('whatsappshare_sharing_location');
  $variables['#attached']['library'][] = 'whatsappshare/whatsappshare';
  $variables['#attached']['drupalSettings']['whatsappshare']['whatsappshareJS']['page_url'] = $base_url . \Drupal::request()
    ->getRequestUri();
  $variables['#attached']['drupalSettings']['whatsappshare']['whatsappshareJS']['whatsappshare_button_text'] = $whatsappshare_button_text;
  $variables['#attached']['drupalSettings']['whatsappshare']['whatsappshareJS']['whatsappshare_button_size'] = $whatsappshare_button_size;
  $variables['#attached']['drupalSettings']['whatsappshare']['whatsappshareJS']['whatsappshare_sharing_text'] = $whatsappshare_sharing_text;
  $variables['#attached']['drupalSettings']['whatsappshare']['whatsappshareJS']['whatsappshare_sharing_location'] = $whatsappshare_sharing_location;
}

Functions

Namesort descending Description
whatsappshare_page_attachments Implements hook_page_attachments().
whatsappshare_preprocess_html Implements hook_preprocess_html().