33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* Home Module · Text Title
|
|
*
|
|
* config: { title, subtitle?, align?, tag? }
|
|
*
|
|
* 纯文本标题模块,用于页面分隔和标题引导。
|
|
*/
|
|
defined('ABSPATH') || exit;
|
|
|
|
$cfg = get_query_var('aksrt_module_config', []);
|
|
if (!is_array($cfg)) $cfg = [];
|
|
|
|
$title = (string) ($cfg['title'] ?? '');
|
|
$subtitle = (string) ($cfg['subtitle'] ?? '');
|
|
$align = sanitize_key((string) ($cfg['align'] ?? 'left'));
|
|
$tag = sanitize_key((string) ($cfg['tag'] ?? 'h2'));
|
|
|
|
if ($title === '' && $subtitle === '') return;
|
|
|
|
$valid_tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
if (!in_array($tag, $valid_tags, true)) $tag = 'h2';
|
|
?>
|
|
|
|
<section class="home-module home-module--text-title container" style="text-align:<?php echo esc_attr($align); ?>">
|
|
<?php if ($title !== '') : ?>
|
|
<<?php echo esc_attr($tag); ?> class="home-module__title"><?php echo esc_html($title); ?></<?php echo esc_attr($tag); ?>>
|
|
<?php endif; ?>
|
|
<?php if ($subtitle !== '') : ?>
|
|
<p class="home-module__subtitle"><?php echo esc_html($subtitle); ?></p>
|
|
<?php endif; ?>
|
|
</section>
|