Files
wordpress-theme-aksrt/inc/helpers/aksrt-auth-ui.php
T
kate522 aaf458af1c refactor(autoload): migrate theme classes to Composer PSR-4
Move 288 types from global AKSRT_* + inc/classes manual requires into
namespace AKSRT\{Domain} under src/AKSRT/, wire composer.json psr-4,
and slim bootstrap to helpers/modules/hooks only. Split multi-class
widget/gateway files, update admin contract audit paths, and document
the layout in ADR/README.
2026-07-17 13:29:22 +08:00

82 lines
2.5 KiB
PHP

<?php
/**
* Auth frontend presentation helpers.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (!function_exists('aksrt_get_auth_agreement_view')) {
/**
* Build user-agreement checkbox contract for full-page and modal auth.
*
* @return array{enabled:bool,required:bool,label_html:string,field_name:string}
*/
function aksrt_get_auth_agreement_view(): array {
$enabled = true;
$required = true;
$page_ref = '';
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'user_agreement_settings')) {
$cfg = \AKSRT\Settings\Settings::user_agreement_settings();
$enabled = !empty($cfg['enabled']);
$required = !empty($cfg['required']);
$page_ref = (string) ($cfg['page'] ?? '');
}
$url = '';
if ($page_ref !== '') {
if (ctype_digit($page_ref)) {
$permalink = get_permalink((int) $page_ref);
if (is_string($permalink) && $permalink !== '') {
$url = $permalink;
}
} else {
$url = esc_url_raw($page_ref);
}
}
if ($url !== '') {
$label_html = sprintf(
/* translators: %s: agreement page link */
__('我已阅读并同意<a href="%s" target="_blank" rel="noopener noreferrer">用户协议</a>', 'aksrt'),
esc_url($url)
);
} else {
$label_html = esc_html__('我已阅读并同意用户协议', 'aksrt');
}
return [
'enabled' => $enabled,
'required' => $required,
'label_html' => $label_html,
'field_name' => 'agree_terms',
];
}
}
if (!function_exists('aksrt_get_auth_sign_logo_html')) {
/**
* Shared logo block for full-page sign shell.
*/
function aksrt_get_auth_sign_logo_html(): string {
$logo_url = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::user_logo_url() : '';
$home = home_url('/');
$name = get_bloginfo('name');
if ($logo_url) {
return sprintf(
'<a href="%s"><img src="%s" alt="%s"></a>',
esc_url($home),
esc_url($logo_url),
esc_attr($name)
);
}
return sprintf(
'<a href="%s" class="sign-logo__text">%s</a>',
esc_url($home),
esc_html(mb_substr((string) $name, 0, 2))
);
}
}