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;
}
Пример #2
0
/**
 * Returns if this site is currently registered with Lockr.
 *
 * @return bool
 * TRUE if this site is registered, FALSE if not.
 */
function lockr_check_registration()
{
    try {
        return \Lockr\Lockr::site()->exists();
    } catch (ServerException $e) {
        return FALSE;
    } catch (ClientException $e) {
        return FALSE;
    }
}