* @license GNU General Public License, version 2 * @link http://addthis.com AddThis website */ class AddThisFollowButtonsToolParent extends AddThisTool { public $availableSizes = array(); protected $featureClassName = 'AddThisFollowButtonsFeature'; /** * Returns client API code settings for this specific tool * * @return array client api code settings for this specific tool */ protected function getClientApiCodeSettings() { $configs = $this->getToolConfigs(); return $configs; } /** * Returns HTML that AddThis client code will pick up and replace * without using lojson/boost configurations (i.e. can be used * anonymously) * * @param array $settings settings for this particular tool, if not * being used from the tool settings * * @return string this should be valid html */ protected function getClientApiCode($settings = array()) { $dbSettings = $this->getToolConfigs(); $settings = array_merge($dbSettings, $settings); $class = $this->availableSizes[$settings['size']]['class']; $html = '
'; $gooSettings = $this->getGlobalOptionsConfigs(); if (!empty($gooSettings['ajax_support'])) { $html .= ''; } return $html; } /** * 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 = array(); if (is_array($input)) { foreach ($input as $field => $value) { switch ($field) { case 'services': if (is_array($value)) { foreach ($value as $service => $username) { if (!empty($username)) { $output['services'][$service] = sanitize_text_field($username); } } } break; case 'title': case 'size': $output[$field] = sanitize_text_field($value); break; case 'enabled': case 'thankyou': $output[$field] = (boolean)$value; } } } if ($addDefaultConfigs) { $output = $this->addDefaultConfigs($output); } return $output; } /** * This must be public as it's used in the feature object with this tool * * This takes configs and adds default values where not present * * @param array $configs An associative array of values input for this * tools' settings * * @return array An associative array of settings specific to this tool * with added defaults where not already present. */ public function addDefaultConfigs($configs) { $configs = parent::addDefaultConfigs($configs); if (empty($configs['services'])) { $configs['services'] = new stdClass(); } return $configs; } } }