d17b9051 by Marty Penner

Format and translate various methods/classes

1 parent 212a1099
......@@ -59,11 +59,11 @@ function login($username, $password, $remember = false) {
throw new LogicException('Unable to login because headers have been sent');
}
$auth = _signon(Array(
$auth = _signon([
'user_login' => esc_sql($username)
, 'user_password' => esc_sql($password)
, 'remember' => $remember
));
]);
if (get_class($auth) == 'WP_User') {
// This is done to ensure the auth'd user is logged in; cookie is not yet readable, redirect needed
......@@ -124,7 +124,7 @@ function logout() {
* @global $wpdb
* @see wpmu_signup_user
*/
function register($username, $email, $password, $meta = Array()) {
function register($username, $email, $password, $meta = []) {
global $wpdb;
require_once(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'registration.php');
......@@ -138,11 +138,11 @@ function register($username, $email, $password, $meta = Array()) {
*/
$wpdb->query("DELETE FROM {$wpdb->signups} WHERE user_email='$email' AND active=0");
$user_data = Array(
$user_data = [
'username' => $username
, 'password' => $password
, 'email' => $email
);
];
$meta['password'] = $password;
// array_filter($user_data, 'esc_sql');
......@@ -158,7 +158,7 @@ function register($username, $email, $password, $meta = Array()) {
$key = substr(md5(time() . rand() . $email ), 0, 16);
$meta = serialize($meta);
$wpdb->insert($wpdb->signups, Array(
$wpdb->insert($wpdb->signups, [
'domain' => '',
'path' => '',
'title' => '',
......@@ -167,7 +167,7 @@ function register($username, $email, $password, $meta = Array()) {
'registered' => current_time('mysql', true),
'activation_key' => $key,
'meta' => $meta
));
]);
// do_action('ACTION_REGISTER'); ???
......@@ -209,7 +209,7 @@ function activate($key, $password_validation = null) {
throw new Exception('Unable to create user');
}
$wpdb->update($wpdb->signups, Array('active' => 1, 'activated' => current_time('mysql', true)), Array('activation_key' => $key));
$wpdb->update($wpdb->signups, ['active' => 1, 'activated' => current_time('mysql', true)], ['activation_key' => $key]);
// $user_site = get_site_option('dashboard_blog', $current_site->blog_id);
if (function_exists('add_user_to_blog')) {
......@@ -240,16 +240,18 @@ class Validation extends Common\Validation {
*/
protected function username($val) {
if (empty($val)) {
throw new Exception('<li>Username is blank</li>');
throw new Exception('<li>'.__('Username is blank', CBV_DOMAIN).'</li>');
}
require_once(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'registration.php');
if (!validate_username($val)) {
throw new Exception('<li>Username must be at least 4 characters, letters and numbers only</li>');
throw new Exception(
'<li>'.__('Username must be at least 4 characters, letters and numbers only', CBV_DOMAIN).'</li>'
);
}
if (username_exists($val)) {
throw new Exception('<li>Username already exists</li>');
throw new Exception('<li>'.__('Username already exists', CBV_DOMAIN).'</li>');
}
}
......@@ -260,15 +262,19 @@ class Validation extends Common\Validation {
*/
protected function password($val) {
if (empty($val)) {
throw new Exception('<li>Password can not be blank</li>');
throw new Exception('<li>'.__('Password can not be blank', CBV_DOMAIN).'</li>');
}
if (isset($val[PASS_MAX_LEN])) {
throw new Exception('<li>Password can not be longer than ' . PASS_MAX_LEN . ' characters.</li>');
throw new Exception(
'<li>'.sprintf(__('Password can not be longer than %d characters.', CBV_DOMAIN), PASS_MAX_LEN).'</li>'
);
}
if (preg_match('/(\\\\|\\\'|"| )+/i', $val)) {
throw new Exception('<li>Password can not contain spaces, backslashes (\) or quotes</li>');
throw new Exception(
'<li>'.__('Password can not contain spaces, backslashes (\) or quotes', CBV_DOMAIN).'</li>'
);
}
}
......@@ -278,11 +284,11 @@ class Validation extends Common\Validation {
*/
protected function email($val) {
if (!(boolean)filter_var($val, FILTER_VALIDATE_EMAIL)) {
throw new Exception('<li>Invalid email address</li>');
throw new Exception('<li>'.__('Invalid email address', CBV_DOMAIN).'</li>');
}
if (false !== email_exists($val)) {
throw new Exception('<li>Email address already registered</li>');
throw new Exception('<li>'.__('Email address already registered', CBV_DOMAIN).' </li > ');
}
}
}
......@@ -294,4 +300,3 @@ class Vars {
*/
public static $options;
}
?>
\ No newline at end of file
......