You are here

function sharethis_get_light_options in ShareThis 7.2

Function is creating options to be passed to stLight.

Parameters

array $data_options: The settings selected by publisher in admin panel.

Return value

array An array of options.

1 call to sharethis_get_light_options()
sharethis_include_js in ./sharethis.module
Include st js scripts.

File

./sharethis.module, line 189
A module that adds one of the ShareThis widget to your website.

Code

function sharethis_get_light_options(array $data_options) {

  // Provide the publisher ID.
  $paramsStLight = array(
    'publisher' => $data_options['publisherID'],
  );
  $paramsStLight['version'] = $data_options['widget'] == 'st_multi' ? "5x" : "4x";
  if ($data_options['sharethis_callesi'] == 0) {
    $paramsStLight["doNotCopy"] = !sharethis_to_boolean($data_options['sharethis_cns']['donotcopy']);
    $paramsStLight["hashAddressBar"] = sharethis_to_boolean($data_options['sharethis_cns']['hashaddress']);
    if (!$paramsStLight["hashAddressBar"] && $paramsStLight["doNotCopy"]) {
      $paramsStLight["doNotHash"] = TRUE;
    }
    else {
      $paramsStLight["doNotHash"] = FALSE;
    }
  }
  if (isset($data_options['onhover']) && $data_options['onhover'] == FALSE) {
    $paramsStLight['onhover'] = FALSE;
  }
  if ($data_options['neworzero']) {
    $paramsStLight['newOrZero'] = "zero";
  }
  if (!$data_options['shorten']) {
    $paramsStLight['shorten'] = 'false';
  }
  if ($data_options['servicePopup']) {
    $paramsStLight['servicePopup'] = TRUE;
  }

  // Let sharethis be able to detect current language, just workaround.
  global $language;
  $paramsStLight['lang'] = $language->language;
  $stlight = drupal_json_encode($paramsStLight);
  return $stlight;
}