抽出 sign.css,统一全页登录/注册与找回/绑定视觉;中文文案与用户协议契约对齐 Auth_Service;弹层字段与 logo 同步。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
82 lines
2.5 KiB
PHP
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') && method_exists('AKSRT_Settings', 'user_agreement_settings')) {
|
|
$cfg = AKSRT_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') ? AKSRT_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))
|
|
);
|
|
}
|
|
}
|