public static function object() { if (!self::$object instanceof self) { self::$object = new self(); do_action('shopp_loginname_generators'); } return self::$object; }
public static function login($result) { $Customer = ShoppOrder()->Customer; if ($Customer->loggedin()) { return $result; } $accounts = shopp_setting('account_system'); $pleaselogin = '******' . Shopp::__('If you have an account with us, please login now.'); // This specific !isset condition checks if the loginname is not provided // If no loginname is provided, but an account system is used, we need to // generate a new login name for the customer if ('wordpress' == $accounts && !isset($_POST['loginname'])) { ShoppLoginGenerator::object(); $_POST['loginname'] = ShoppLoginGenerator::name(); if (apply_filters('shopp_login_required', empty($_POST['loginname']))) { return shopp_add_error(Shopp::__('A login could not be created with the information you provided. Enter a different name or email address.') . $pleaselogin); } shopp_debug('Login set to ' . $_POST['loginname'] . ' for WordPress account creation.'); } // Validate unique email address for new account if (in_array($accounts, array('wordpress', 'shopp')) && !$Customer->session(ShoppCustomer::GUEST)) { $ShoppCustomer = new ShoppCustomer($_POST['email'], 'email'); if (apply_filters('shopp_email_exists', 'wordpress' == $accounts ? email_exists($_POST['email']) : $ShoppCustomer->exists())) { return shopp_add_error(Shopp::__('The email address you entered is already in use. Enter a different email address to create a new account.') . $pleaselogin); } } // Validate WP login if (isset($_POST['loginname'])) { if (apply_filters('shopp_login_required', empty($_POST['loginname']))) { return shopp_add_error(Shopp::__('You must enter a login name for your account.')); } if (apply_filters('shopp_login_valid', !validate_username($_POST['loginname']))) { $sanitized = sanitize_user($_POST['loginname'], true); $illegal = array_diff(str_split($_POST['loginname']), str_split($sanitized)); return shopp_add_error(Shopp::__('The login name provided includes invalid characters: %s', esc_html(join(' ', $illegal)))); } if (apply_filters('shopp_login_exists', username_exists($_POST['loginname']))) { return shopp_add_error(Shopp::__('"%s" is already in use. Enter a different login name to create a new account.', esc_html($_POST['loginname'])) . $pleaselogin); } } return $result; }