Some checks failed
CI / Coding Standards (push) Failing after 2m31s
CI / PHPStan (push) Failing after 50s
CI / Tests (PHP 8.1) (push) Successful in 50s
CI / Tests (PHP 8.2) (push) Successful in 48s
CI / Tests (PHP 8.3) (push) Successful in 40s
CI / No Debug Code (push) Successful in 2s
- Custom DB tables for availability slots and lesson bookings - Instructor (wp-admin) and student (front-end) roles with custom capabilities - REST API under us-scheduler/v1 for availability CRUD and booking - [us_booking] and [us_student_login] shortcodes for student front end - PHPUnit + Brain\Monkey unit test suite (29 tests) - Gitea Actions CI: lint, PHPStan, tests on PHP 8.1/8.2/8.3, no-debug check - Feature docs under docs/features/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular\Frontend;
|
|
|
|
class LoginPage
|
|
{
|
|
public function render(array $atts): string
|
|
{
|
|
if (is_user_logged_in()) {
|
|
$redirect = esc_url(get_permalink());
|
|
return sprintf(
|
|
'<p>%s <a href="%s">%s</a>.</p>',
|
|
esc_html__('You are already logged in.', 'unsupervised-schedular'),
|
|
$redirect,
|
|
esc_html__('View available lessons', 'unsupervised-schedular')
|
|
);
|
|
}
|
|
|
|
$error = '';
|
|
$redirect = sanitize_url(get_permalink() ?? '');
|
|
|
|
if (isset($_POST['us_login']) && check_admin_referer('us_student_login')) {
|
|
$credentials = [
|
|
'user_login' => sanitize_user($_POST['log'] ?? ''),
|
|
'user_password' => $_POST['pwd'] ?? '',
|
|
'remember' => isset($_POST['rememberme']),
|
|
];
|
|
|
|
$user = wp_signon($credentials, false);
|
|
|
|
if (is_wp_error($user)) {
|
|
$error = esc_html__('Invalid username or password.', 'unsupervised-schedular');
|
|
} else {
|
|
wp_safe_redirect($redirect);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
ob_start();
|
|
include USC_PLUGIN_DIR . 'templates/frontend/login-page.php';
|
|
return (string) ob_get_clean();
|
|
}
|
|
}
|