public function set_global_options($data)
{
$options = get_option('sharing-options');
// No options yet
if (!is_array($options)) {
$options = array();
}
// Defaults
$options['global'] = array('button_style' => 'icon-text', 'sharing_label' => $this->default_sharing_label, 'open_links' => 'same', 'show' => array(), 'custom' => isset($options['global']['custom']) ? $options['global']['custom'] : array());
/**
* Filters global sharing settings.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param array $options['global'] Array of global sharing settings.
*/
$options['global'] = apply_filters('sharing_default_global', $options['global']);
// Validate options and set from our data
if (isset($data['button_style']) && in_array($data['button_style'], array('icon-text', 'icon', 'text', 'official'))) {
$options['global']['button_style'] = $data['button_style'];
}
if (isset($data['sharing_label'])) {
if ($this->default_sharing_label === $data['sharing_label']) {
$options['global']['sharing_label'] = false;
} else {
$options['global']['sharing_label'] = trim(wp_kses(stripslashes($data['sharing_label']), array()));
}
}
if (isset($data['open_links']) && in_array($data['open_links'], array('new', 'same'))) {
$options['global']['open_links'] = $data['open_links'];
}
$shows = array_values(get_post_types(array('public' => true)));
$shows[] = 'index';
if (isset($data['show'])) {
if (is_scalar($data['show'])) {
switch ($data['show']) {
case 'posts':
$data['show'] = array('post', 'page');
break;
case 'index':
$data['show'] = array('index');
break;
case 'posts-index':
$data['show'] = array('post', 'page', 'index');
break;
}
}
if ($data['show'] = array_intersect($data['show'], $shows)) {
$options['global']['show'] = $data['show'];
}
}
update_option('sharing-options', $options);
return $options['global'];
}