public function save_profile_settings($user_id, $args = array(), $sites = null)
{
$available = $this->get_available_settings();
if ($sites === null) {
$sites = array(get_current_blog_id());
}
foreach ($available as $type => $options) {
foreach ($sites as $site) {
$key = $this->key_for_setting('notifications.' . $type, $site);
// PHP strips '.' out of POST data as a relic from the
// register_globals days, so we need to take that into account
$request_key = str_replace('.', '_', $key);
if (!isset($args[$request_key])) {
continue;
}
$value = $args[$request_key];
// Check the value is valid
$options = array_keys($options);
if (!in_array($value, $options)) {
continue;
}
// Actually set it!
if (!update_user_meta($user_id, wp_slash($key), wp_slash($value))) {
// TODO: Log this?
continue;
}
}
}
}