Align search experience with settings
This commit is contained in:
+91
-52
@@ -118,8 +118,21 @@ if (!empty($aksrt_bg_styles)) {
|
||||
$aksrt_logo_url = function_exists('aksrt_get_site_logo_url') ? trim((string) aksrt_get_site_logo_url()) : '';
|
||||
$aksrt_logo_dark_url = function_exists('aksrt_get_site_logo_dark_url') ? trim((string) aksrt_get_site_logo_dark_url()) : '';
|
||||
$aksrt_logo_width = function_exists('aksrt_get_site_logo_width') ? aksrt_get_site_logo_width() : 150;
|
||||
$aksrt_search_state = function_exists('aksrt_get_search_form_state')
|
||||
? aksrt_get_search_form_state()
|
||||
: [
|
||||
'type' => 'post',
|
||||
'types' => ['post' => __('文章', 'aksrt')],
|
||||
'category_id' => 0,
|
||||
'category_enabled' => false,
|
||||
'categories' => [],
|
||||
];
|
||||
$aksrt_search_placeholder = function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索', 'aksrt');
|
||||
$aksrt_search_type = function_exists('aksrt_get_search_form_type') ? aksrt_get_search_form_type() : 'post';
|
||||
$aksrt_search_type = $aksrt_search_state['type'];
|
||||
$aksrt_search_type_options = $aksrt_search_state['types'];
|
||||
$aksrt_search_category_enabled = !empty($aksrt_search_state['category_enabled']);
|
||||
$aksrt_search_category_id = (int) ($aksrt_search_state['category_id'] ?? 0);
|
||||
$aksrt_search_categories = is_array($aksrt_search_state['categories'] ?? null) ? $aksrt_search_state['categories'] : [];
|
||||
$aksrt_search_hot_keywords = function_exists('aksrt_get_search_hot_keywords') ? aksrt_get_search_hot_keywords() : [];
|
||||
$aksrt_brand_logo_src = '';
|
||||
$aksrt_mobile_menu_location = has_nav_menu('mobile') ? 'mobile' : 'primary';
|
||||
@@ -208,8 +221,11 @@ if (!empty($aksrt_bg_styles)) {
|
||||
|
||||
<div class="nav-actions">
|
||||
<?php if (!empty($aksrt_header_settings['search_enabled'])) : ?>
|
||||
<form role="search" method="get" class="nav-searchbox" action="<?php echo esc_url(home_url('/')); ?>" data-aksrt-search-form="desktop">
|
||||
<form role="search" method="get" class="nav-searchbox" action="<?php echo esc_url(home_url('/')); ?>" data-aksrt-search-form="desktop" data-default-search-type="<?php echo esc_attr($aksrt_search_type); ?>" data-default-category="<?php echo esc_attr((string) $aksrt_search_category_id); ?>">
|
||||
<input type="hidden" name="aksrt_search_type" value="<?php echo esc_attr($aksrt_search_type); ?>">
|
||||
<?php if ($aksrt_search_category_enabled) : ?>
|
||||
<input type="hidden" name="aksrt_category" value="<?php echo esc_attr((string) $aksrt_search_category_id); ?>">
|
||||
<?php endif; ?>
|
||||
<label class="screen-reader-text" for="site-nav-search-s"><?php esc_html_e('搜索', 'aksrt'); ?></label>
|
||||
<input class="nav-searchbox__input" type="search" id="site-nav-search-s" name="s" value="<?php echo esc_attr(get_search_query()); ?>" placeholder="<?php echo esc_attr($aksrt_search_placeholder); ?>">
|
||||
<button type="submit" class="nav-searchbox__submit"><?php esc_html_e('搜索', 'aksrt'); ?></button>
|
||||
@@ -296,8 +312,11 @@ if (!empty($aksrt_bg_styles)) {
|
||||
|
||||
<?php if (!empty($aksrt_header_settings['search_enabled'])) : ?>
|
||||
<div class="nav-drawer__search">
|
||||
<form role="search" method="get" class="nav-searchbox nav-searchbox--drawer" action="<?php echo esc_url(home_url('/')); ?>" data-aksrt-search-form="drawer">
|
||||
<form role="search" method="get" class="nav-searchbox nav-searchbox--drawer" action="<?php echo esc_url(home_url('/')); ?>" data-aksrt-search-form="drawer" data-default-search-type="<?php echo esc_attr($aksrt_search_type); ?>" data-default-category="<?php echo esc_attr((string) $aksrt_search_category_id); ?>">
|
||||
<input type="hidden" name="aksrt_search_type" value="<?php echo esc_attr($aksrt_search_type); ?>">
|
||||
<?php if ($aksrt_search_category_enabled) : ?>
|
||||
<input type="hidden" name="aksrt_category" value="<?php echo esc_attr((string) $aksrt_search_category_id); ?>">
|
||||
<?php endif; ?>
|
||||
<div class="nav-searchbox__field">
|
||||
<span class="nav-searchbox__icon" aria-hidden="true">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
@@ -307,60 +326,80 @@ if (!empty($aksrt_bg_styles)) {
|
||||
<button type="submit" class="nav-searchbox__submit"><?php esc_html_e('搜索', 'aksrt'); ?></button>
|
||||
</div>
|
||||
</form>
|
||||
<?php if (!empty($aksrt_search_type_options)) : ?>
|
||||
<div class="nav-searchbox__meta">
|
||||
<div class="nav-searchbox__types" aria-label="<?php esc_attr_e('搜索类型', 'aksrt'); ?>">
|
||||
<?php foreach ($aksrt_search_type_options as $type_key => $type_label) : ?>
|
||||
<button type="button" class="nav-searchbox__type<?php echo $aksrt_search_type === $type_key ? ' is-active' : ''; ?>" data-search-type="<?php echo esc_attr($type_key); ?>"><?php echo esc_html($type_label); ?></button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($aksrt_search_category_enabled && !empty($aksrt_search_categories)) : ?>
|
||||
<div class="nav-searchbox__category-wrap">
|
||||
<label class="screen-reader-text" for="nav-drawer-search-category"><?php esc_html_e('默认分类', 'aksrt'); ?></label>
|
||||
<select class="nav-searchbox__category" id="nav-drawer-search-category" data-search-category-select>
|
||||
<option value="0"><?php esc_html_e('全部分类', 'aksrt'); ?></option>
|
||||
<?php foreach ($aksrt_search_categories as $search_category) : ?>
|
||||
<option value="<?php echo esc_attr((string) $search_category->term_id); ?>"<?php selected($aksrt_search_category_id, (int) $search_category->term_id); ?>><?php echo esc_html($search_category->name); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php aksrt_render_search_hot_keywords($aksrt_search_hot_keywords, 'aksrt-search-hot-keywords'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="nav-drawer__menu">
|
||||
<?php
|
||||
if (has_nav_menu($aksrt_mobile_menu_location)) {
|
||||
wp_nav_menu(
|
||||
[
|
||||
'theme_location' => $aksrt_mobile_menu_location,
|
||||
'container' => false,
|
||||
'menu_class' => '',
|
||||
'fallback_cb' => false,
|
||||
'depth' => 2,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
echo '<a href="' . esc_url(home_url('/')) . '">' . esc_html__('首页', 'aksrt') . '</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if ($aksrt_can_publish) : ?>
|
||||
<div class="nav-drawer__publish">
|
||||
<a class="btn-primary" href="<?php echo esc_url(admin_url('post-new.php')); ?>">
|
||||
<i class="fas fa-pen-nib" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('发布内容', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<div class="nav-drawer__menu">
|
||||
<?php
|
||||
if (has_nav_menu($aksrt_mobile_menu_location)) {
|
||||
wp_nav_menu(
|
||||
[
|
||||
'theme_location' => $aksrt_mobile_menu_location,
|
||||
'container' => false,
|
||||
'menu_class' => '',
|
||||
'fallback_cb' => false,
|
||||
'depth' => 2,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
echo '<a href="' . esc_url(home_url('/')) . '">' . esc_html__('首页', 'aksrt') . '</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (in_array('m_menu', $aksrt_theme_toggle_positions, true)) : ?>
|
||||
<div class="nav-drawer__theme-toggle">
|
||||
<button type="button" class="btn-outline theme-toggle-mobile" id="theme-toggle-mobile" title="<?php esc_attr_e('切换亮暗色', 'aksrt'); ?>">
|
||||
<i class="fas fa-adjust" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('切换主题', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<?php if ($aksrt_can_publish) : ?>
|
||||
<div class="nav-drawer__publish">
|
||||
<a class="btn-primary" href="<?php echo esc_url(admin_url('post-new.php')); ?>">
|
||||
<i class="fas fa-pen-nib" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('发布内容', 'aksrt'); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (in_array('m_menu', $aksrt_theme_toggle_positions, true)) : ?>
|
||||
<div class="nav-drawer__theme-toggle">
|
||||
<button type="button" class="btn-outline theme-toggle-mobile" id="theme-toggle-mobile" title="<?php esc_attr_e('切换亮暗色', 'aksrt'); ?>">
|
||||
<i class="fas fa-adjust" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('切换主题', 'aksrt'); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($aksrt_show_user_entry && !is_user_logged_in()) : ?>
|
||||
<div class="nav-drawer__auth">
|
||||
<a class="btn-outline" href="<?php echo esc_url(aksrt_get_login_url()); ?>"><?php esc_html_e('登录', 'aksrt'); ?></a>
|
||||
<?php if (get_option('users_can_register')) : ?>
|
||||
<a class="btn-primary" href="<?php echo esc_url(aksrt_get_register_url()); ?>"><?php esc_html_e('注册', 'aksrt'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (is_active_sidebar('mobile_nav_fluid')) : ?>
|
||||
<div class="nav-drawer__widgets">
|
||||
<?php dynamic_sidebar('mobile_nav_fluid'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($aksrt_show_user_entry && !is_user_logged_in()) : ?>
|
||||
<div class="nav-drawer__auth">
|
||||
<a class="btn-outline" href="<?php echo esc_url(aksrt_get_login_url()); ?>"><?php esc_html_e('登录', 'aksrt'); ?></a>
|
||||
<?php if (get_option('users_can_register')) : ?>
|
||||
<a class="btn-primary" href="<?php echo esc_url(aksrt_get_register_url()); ?>"><?php esc_html_e('注册', 'aksrt'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (is_active_sidebar('mobile_nav_fluid')) : ?>
|
||||
<div class="nav-drawer__widgets">
|
||||
<?php dynamic_sidebar('mobile_nav_fluid'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="fixed-body"></div>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<div class="fixed-body"></div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user