CI / Tests (PHP 8.1) (pull_request) Successful in 41s
CI / Tests (PHP 8.2) (pull_request) Successful in 40s
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 2m55s
CI / PHPStan (pull_request) Successful in 3m1s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m43s
CI / Build Plugin Zip (pull_request) Skipped
Sweep the translatable strings across the frontend templates, the admin screens, the editor previews and the block inserter entry. Nothing else moves: the database columns, request parameters, form field names, CSS classes, the us_family shortcode and the us-scheduler/family block name are contracts with existing installs and with post content people have already saved, so renaming them would break sites for no user-visible gain. Two strings are reworded rather than swapped, because the direct substitution reads wrong: - The students list said "Child of Jane" and now says "Managed by Jane". "Student of Jane" would read as a teacher's pupil, which is exactly the wrong idea in a music studio. - A managed account is now "a managed student account" rather than "a student account", which would not distinguish it from the account holder. The guardian feature doc gains a short section on the split, so the next person to work on it does not read the mismatch as drift and "fix" it. Closes #144 Co-Authored-By: Claude Opus 5 <[email protected]>
108 lines
5.9 KiB
PHP
108 lines
5.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Unsupervised\Schedular\Registration\QuestionField;
|
|
|
|
if (! defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* @var list<array{id: int, name: string, date_of_birth: string, relationship: string}> $children
|
|
* @var list<\Unsupervised\Schedular\Registration\Question> $questions Account-scope questions, asked once per child.
|
|
* @var string $error Validation error from the last submission, if any.
|
|
* @var string $notice Confirmation of a completed add/edit/remove, if any.
|
|
* @var int $editingId Child whose row is open for editing; 0 for none.
|
|
*/
|
|
?>
|
|
<div class="us-family">
|
|
<h3><?php esc_html_e('Your profile', 'unsupervised-schedular'); ?></h3>
|
|
|
|
<?php if ($notice !== '') : ?>
|
|
<p class="us-success"><?php echo esc_html($notice); ?></p>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($error !== '') : ?>
|
|
<p class="us-error" role="alert"><?php echo esc_html($error); ?></p>
|
|
<?php endif; ?>
|
|
|
|
<?php if (empty($children)) : ?>
|
|
<p><?php esc_html_e('You have not added any students yet. Add one below to start booking lessons for them.', 'unsupervised-schedular'); ?></p>
|
|
<?php else : ?>
|
|
<ul class="us-family-list">
|
|
<?php foreach ($children as $child) : ?>
|
|
<li class="us-family-child">
|
|
<?php if ($editingId === $child['id']) : ?>
|
|
<form method="post" action="" class="us-family-edit">
|
|
<?php wp_nonce_field('us_family'); ?>
|
|
<input type="hidden" name="us_family_action" value="edit">
|
|
<input type="hidden" name="child_id" value="<?php echo esc_attr((string) $child['id']); ?>">
|
|
<p>
|
|
<label for="us-edit-name-<?php echo esc_attr((string) $child['id']); ?>"><?php esc_html_e('Name', 'unsupervised-schedular'); ?></label>
|
|
<input type="text" name="child_name" id="us-edit-name-<?php echo esc_attr((string) $child['id']); ?>" value="<?php echo esc_attr($child['name']); ?>" required>
|
|
</p>
|
|
<p>
|
|
<label for="us-edit-dob-<?php echo esc_attr((string) $child['id']); ?>"><?php esc_html_e('Date of birth', 'unsupervised-schedular'); ?></label>
|
|
<input type="date" name="child_dob" id="us-edit-dob-<?php echo esc_attr((string) $child['id']); ?>" value="<?php echo esc_attr($child['date_of_birth']); ?>">
|
|
</p>
|
|
<p>
|
|
<button type="submit"><?php esc_html_e('Save', 'unsupervised-schedular'); ?></button>
|
|
<a href="<?php echo esc_url((string) get_permalink()); ?>"><?php esc_html_e('Cancel', 'unsupervised-schedular'); ?></a>
|
|
</p>
|
|
</form>
|
|
<?php else : ?>
|
|
<span class="us-family-child-name"><?php echo esc_html($child['name']); ?></span>
|
|
<?php if ($child['date_of_birth'] !== '') : ?>
|
|
<span class="us-family-child-dob"><?php echo esc_html($child['date_of_birth']); ?></span>
|
|
<?php endif; ?>
|
|
<span class="us-family-child-actions">
|
|
<a href="<?php echo esc_url(add_query_arg('us_edit_child', $child['id'], (string) get_permalink())); ?>"><?php esc_html_e('Edit', 'unsupervised-schedular'); ?></a>
|
|
<form method="post" action="" class="us-family-remove">
|
|
<?php wp_nonce_field('us_family'); ?>
|
|
<input type="hidden" name="us_family_action" value="remove">
|
|
<input type="hidden" name="child_id" value="<?php echo esc_attr((string) $child['id']); ?>">
|
|
<button type="submit"><?php esc_html_e('Remove', 'unsupervised-schedular'); ?></button>
|
|
</form>
|
|
</span>
|
|
<?php endif; ?>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
|
|
<form method="post" action="" class="us-family-add">
|
|
<?php wp_nonce_field('us_family'); ?>
|
|
<input type="hidden" name="us_family_action" value="add">
|
|
|
|
<h4><?php esc_html_e('Add a student', 'unsupervised-schedular'); ?></h4>
|
|
<p>
|
|
<label for="us-child-name"><?php esc_html_e('Name', 'unsupervised-schedular'); ?></label>
|
|
<input type="text" name="child_name" id="us-child-name" required>
|
|
</p>
|
|
<p>
|
|
<label for="us-child-dob"><?php esc_html_e('Date of birth', 'unsupervised-schedular'); ?></label>
|
|
<input type="date" name="child_dob" id="us-child-dob">
|
|
</p>
|
|
<p>
|
|
<label for="us-child-relationship"><?php esc_html_e('Your relationship to them', 'unsupervised-schedular'); ?></label>
|
|
<input type="text" name="child_relationship" id="us-child-relationship" placeholder="<?php esc_attr_e('Parent', 'unsupervised-schedular'); ?>">
|
|
</p>
|
|
|
|
<?php if (! empty($questions)) : ?>
|
|
<fieldset class="us-reg-questions">
|
|
<legend><?php esc_html_e('About this student', 'unsupervised-schedular'); ?></legend>
|
|
<?php foreach ($questions as $question) : ?>
|
|
<?php
|
|
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- QuestionField::render() escapes every interpolated value.
|
|
echo QuestionField::render($question, 'us_answers[' . (int) $question->id . ']', 'us-family-q-' . (int) $question->id);
|
|
?>
|
|
<?php endforeach; ?>
|
|
</fieldset>
|
|
<?php endif; ?>
|
|
|
|
<p>
|
|
<button type="submit"><?php esc_html_e('Add student', 'unsupervised-schedular'); ?></button>
|
|
</p>
|
|
</form>
|
|
</div>
|