function lockr_options_validate($input) { $options = get_option('lockr_options'); $options['account_email'] = trim($input['account_email']); $options['account_password'] = trim($input['account_password']); $name = get_bloginfo('name', 'display'); if (!filter_var($options['account_email'], FILTER_VALIDATE_EMAIL)) { add_settings_error('lockr_options', 'lockr-email', $options['account_email'] . ' is not a proper email address. Please try again.', 'error'); $options['account_email'] = ''; } else { try { \Lockr\Lockr::site()->register($options['account_email'], null, $name); } catch (ClientException $e) { try { \Lockr\Lockr::site()->register($options['account_email'], $options['account_password'], $name); } catch (ClientException $e) { add_settings_error('lockr_options', 'lockr-email', 'Login credentials incorrect, please try again.', 'error'); } catch (ServerException $e) { add_settings_error('lockr_options', 'lockr-email', 'An unknown error has occurred, please try again later.', 'error'); } } catch (ServerException $e) { add_settings_error('lockr_options', 'lockr-email', 'An unknown error has occurred, please try again later.', 'error'); } } $options['account_password'] = ''; return $options; }
/** * Deletes a key from Lockr. * * @param string $key_name * The key name */ function lockr_delete_key($key_name) { \Lockr\Lockr::key()->delete($key_name); }