whatsappshare.module in Whatsapp Share 8
File
whatsappshare.module
View source
<?php
function whatsappshare_page_attachments(array &$attachments) {
$attachments['#attached']['library'][] = 'whatsappshare/whatsappshare';
}
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;
}