/**
  * Creates tool specific settings for the JavaScript variable
  * addthis_layers, used to bootstrap layers
  *
  * @param array $configs optional array of settings (used with widgets)
  *
  * @return array an associative array
  */
 public function getAddThisLayers($configs = array())
 {
     if (empty($configs)) {
         $configs = $this->getToolConfigs();
     }
     $layers = array('follow' => $configs['follow'], 'buttonBarTheme' => $configs['buttonBarTheme'], 'buttonBarPosition' => $configs['buttonBarPosition']);
     $layers['followServices'] = AddThisFollowButtonsToolParent::formatServicesForAddThisLayers($configs['followServices']);
     $result = array($this->layersApiProductName => $layers);
     return $result;
 }
 /**
  * Creates tool specific settings for the JavaScript variable
  * addthis_layers, used to bootstrap layers
  *
  * @param array $configs optional array of settings (used with widgets)
  *
  * @return array an associative array
  */
 public function getAddThisLayers($configs = array())
 {
     if (empty($configs)) {
         $configs = $this->getToolConfigs();
     }
     if (!$this->isEnabled()) {
         return array();
     }
     $layers = array('services' => array(), 'orientation' => 'horizontal', 'size' => $configs['size'], 'thankyou' => $configs['thankyou'], 'title' => $configs['title'], 'elements' => '.' . $this->layersClass);
     $layers['services'] = AddThisFollowButtonsToolParent::formatServicesForAddThisLayers($configs['services']);
     $result = array($this->layersApiProductName => $layers);
     return $result;
 }
 /**
  * This must be public as it's used in the feature object with this tool
  *
  * This takes form input for a  tool sub settings variable, manipulates
  * it, and returns the variables that should be saved to the database.
  *
  * @param array   $input             An associative array of values
  * input for this tools' settings
  * @param boolean $addDefaultConfigs Whether to populate in default
  * values for missing fields
  *
  * @return array A cleaned up associative array of settings specific to
  *               this feature.
  */
 public function sanitizeSettings($input, $addDefaultConfigs = true)
 {
     $output = parent::sanitizeSettings($input, false);
     if (is_array($input)) {
         foreach ($input as $field => $value) {
             switch ($field) {
                 case 'responsive':
                     $output[$field] = (int) $value['responsive'];
                     break;
                 case 'offset':
                     if (isset($value['location'])) {
                         $output[$field]['location'] = sanitize_text_field($value['location']);
                     }
                     if (!empty($value['amount'])) {
                         $output[$field]['amount'] = (int) $value['amount'];
                     }
                     if (!empty($value['unit'])) {
                         $output[$field]['unit'] = sanitize_text_field($value['unit']);
                     }
                     break;
                 case 'theme':
                     $output[$field] = sanitize_text_field($value);
                     break;
                 case '__hideOnHomepage':
                     $output[$field] = (bool) $value;
                     break;
                 case '__hideOnUrls':
                     if (is_array($value)) {
                         foreach ($value as $urlPattern) {
                             $output[$field][] = sanitize_text_field($urlPattern);
                         }
                     }
                     break;
             }
         }
     }
     if (isset($output['size'])) {
         unset($output['size']);
     }
     if ($addDefaultConfigs) {
         $output = $this->addDefaultConfigs($output);
     }
     return $output;
 }