function easy_social_preprocess_easy_social_googleplus in Easy Social 8.3
Same name and namespace in other branches
- 8.4 easy_social.module \easy_social_preprocess_easy_social_googleplus()
Implements hook_preprocess_HOOK() for easy_social_googleplus theme.
See also
theme_easy_social_googleplus()
File
- ./
easy_social.module, line 292 - Easy Social module.
Code
function easy_social_preprocess_easy_social_googleplus(&$variables, &$hook) {
//ToDo: Figure out how to pass variables to the JS using DrupalSettings
if ($variables['lang'] !== 'en') {
$script = <<<JS
window.___gcfg = {lang: '{<span class="php-variable">$variables</span>[<span class="php-string">'lang'</span>]}'};
JS;
}
$hook = str_replace('easy_social_', 'easy_social.', $hook);
$attributes = array(
'class' => array(
'g-plus',
),
'data-action' => 'share',
);
if ($config = \Drupal::config($hook)) {
// @TODO load contextual config.
$widget_params = $config
->get();
if (!empty($variables['url'])) {
$attributes['data-href'] = $variables['url'];
}
if (isset($widget_params['annotation']) && $widget_params['annotation'] !== 'inline') {
$attributes['data-annotation'] = $widget_params['annotation'];
}
if (!empty($widget_params['width'])) {
$attributes['data-width'] = $widget_params['width'];
}
}
$variables['attributes'] = $attributes;
}