Ejemplo n.º 1
0
/**
 * Delete user interface settings.
 *
 * Deleting settings would reset them to the defaults.
 * This function has to be used before any output has started as it calls setcookie().
 *
 * @package WordPress
 * @subpackage Option
 * @since 2.7.0
 *
 * @param mixed $names The name or array of names of the setting to be deleted.
 * @return bool true if deleted successfully/false if not.
 */
function delete_user_setting($names)
{
    if (headers_sent()) {
        return false;
    }
    $all_user_settings = get_all_user_settings();
    $names = (array) $names;
    $deleted = false;
    foreach ($names as $name) {
        if (isset($all_user_settings[$name])) {
            unset($all_user_settings[$name]);
            $deleted = true;
        }
    }
    if ($deleted) {
        return wp_set_all_user_settings($all_user_settings);
    }
    return false;
}
 function set_user_setting($name, $value)
 {
     $all_user_settings = get_all_user_settings();
     $all_user_settings[$name] = $value;
     return wp_set_all_user_settings($all_user_settings);
 }