fix(frontend): align search and header components with reference
This commit is contained in:
1 parent
4c13ef478c
commit
542daca457
34 files changed
+803
-705
No files matched your search
+49
-23
@@ -9,7 +9,7 @@ defined('ABSPATH') || exit;
|
||||
|
||||
global $wp_query;
|
||||
|
||||
$search_query = trim(wp_strip_all_tags(get_search_query()));
|
||||
$search_query = trim(wp_strip_all_tags(get_search_query(false)));
|
||||
$search_type = function_exists('aksrt_get_search_form_type') ? aksrt_get_search_form_type() : 'post';
|
||||
$search_types = function_exists('aksrt_get_search_type_options') ? aksrt_get_search_type_options() : ['post' => __('文章', 'aksrt')];
|
||||
$search_category = isset($_REQUEST['trem']) ? absint(wp_unslash($_REQUEST['trem'])) : 0;
|
||||
@@ -44,9 +44,10 @@ if ($search_query !== '' && $search_total > 0 && $paged <= 1 && function_exists(
|
||||
|
||||
get_header();
|
||||
|
||||
if (is_active_sidebar('search_top_fluid')) {
|
||||
if (is_active_sidebar('all_top_fluid') || is_active_sidebar('search_top_fluid')) {
|
||||
echo '<div class="fluid-widget-wrap">';
|
||||
dynamic_sidebar('search_top_fluid');
|
||||
if (is_active_sidebar('all_top_fluid')) dynamic_sidebar('all_top_fluid');
|
||||
if (is_active_sidebar('search_top_fluid')) dynamic_sidebar('search_top_fluid');
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
@@ -73,62 +74,87 @@ if (is_active_sidebar('search_top_fluid')) {
|
||||
if ($search_type === $key) {
|
||||
$tab_nav .= '<li class="active"><a class="focus-color" href="javascript:;">' . esc_html($label) . '</a></li>';
|
||||
} else {
|
||||
$tab_nav .= '<li><a ajax-replace="true" route="1" class="ajax-next" href="' . esc_url(add_query_arg('type', $key, $base_url)) . '">' . esc_html($label) . '</a></li>';
|
||||
$route_title = $search_query . ' ' . __('搜索', 'aksrt') . $label . ' - ' . get_bloginfo('name');
|
||||
$tab_nav .= '<li><a ajax-replace="true" route="1" route-title="' . esc_attr($route_title) . '" class="ajax-next" href="' . esc_url(add_query_arg('type', $key, $base_url)) . '">' . esc_html($label) . '</a></li>';
|
||||
}
|
||||
}
|
||||
$tab_nav = '<div class="list-inline scroll-x mini-scrollbar tab-nav-theme">' . $tab_nav . '</div>';
|
||||
$description = sprintf(
|
||||
$search_scope_parts = [];
|
||||
if ($search_user > 0) {
|
||||
$filtered_user = get_userdata($search_user);
|
||||
if ($filtered_user) {
|
||||
$user_home = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($search_user) : get_author_posts_url($search_user);
|
||||
$search_scope_parts[] = __('用户', 'aksrt') . ' <a class="focus-color" href="' . esc_url($user_home) . '"><b>' . esc_html($filtered_user->display_name) . '</b></a>';
|
||||
}
|
||||
}
|
||||
if ($search_category > 0) {
|
||||
$filtered_term = get_term($search_category);
|
||||
if ($filtered_term && !is_wp_error($filtered_term)) {
|
||||
$term_url = get_term_link($filtered_term);
|
||||
if (!is_wp_error($term_url)) {
|
||||
$taxonomy = get_taxonomy($filtered_term->taxonomy);
|
||||
$taxonomy_label = $taxonomy && !empty($taxonomy->labels->singular_name) ? $taxonomy->labels->singular_name : __('分类', 'aksrt');
|
||||
$search_scope_parts[] = esc_html($taxonomy_label) . ' <a class="focus-color" href="' . esc_url($term_url) . '"><b>' . esc_html($filtered_term->name) . '</b></a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$description = ($search_scope_parts ? sprintf(__('在%s中,', 'aksrt'), implode(__('、', 'aksrt'), $search_scope_parts)) : '')
|
||||
. sprintf(
|
||||
__('搜索 %1$s ,共找到 %2$s 个%3$s', 'aksrt'),
|
||||
'<b class="search-key focus-color">' . esc_html($search_query) . '</b>',
|
||||
'<b class="focus-color">' . esc_html(number_format_i18n($search_total)) . '</b>',
|
||||
esc_html($search_types[$search_type] ?? __('内容', 'aksrt'))
|
||||
);
|
||||
?>
|
||||
<?php if ($search_query === '') : ?>
|
||||
<div class="aksrt-panel search-content"><?php echo function_exists('aksrt_get_ajax_null') ? aksrt_get_ajax_null(__('请输入搜索关键词', 'aksrt'), 60, 'null-search.svg', 300) : '<div class="ajax-item text-center muted-2-color padding-20">' . esc_html__('请输入搜索关键词', 'aksrt') . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php else : ?>
|
||||
<div class="ajaxpager search-page-ajaxpager">
|
||||
<div class="ajax-item-header type-<?php echo esc_attr($search_type); ?>">
|
||||
<div class="search-desc-text mb10 mt10 muted-2-color"><?php echo wp_kses_post($description); ?></div>
|
||||
<div class="search-tab-header aksrt-panel relative padding-h10"><div><?php echo $tab_nav; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div><div class="search-tab-filter"><?php echo function_exists('aksrt_get_search_tab_nav_filter') ? aksrt_get_search_tab_nav_filter($search_type) : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div></div>
|
||||
</div>
|
||||
<?php if ($search_query === '') : ?>
|
||||
<div class="aksrt-panel search-content"><div class="text-center muted-2-color padding-20"><?php esc_html_e('请输入搜索关键词', 'aksrt'); ?></div></div>
|
||||
<?php elseif ($user_query instanceof WP_User_Query && $user_query->get_results()) : ?>
|
||||
<div class="aksrt-panel">
|
||||
<?php if ($user_query instanceof WP_User_Query && $user_query->get_results()) : ?>
|
||||
<?php foreach ($user_query->get_results() as $result_user) :
|
||||
$user_id = (int) $result_user->ID;
|
||||
$user_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($user_id) : get_author_posts_url($user_id);
|
||||
?>
|
||||
<a class="author-minicard radius8 flex ac ajax-item" href="<?php echo esc_url($user_url); ?>">
|
||||
<span class="avatar-img mr10"><?php echo function_exists('aksrt_get_avatar_html') ? aksrt_get_avatar_html($user_id, 48) : get_avatar($user_id, 48); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
|
||||
<span class="flex1"><b><?php echo esc_html($result_user->display_name); ?></b><span class="muted-2-color em09 block text-ellipsis"><?php echo esc_html(wp_trim_words((string) $result_user->description, 16)); ?></span></span>
|
||||
</a>
|
||||
<?php echo function_exists('aksrt_author_minicard') ? aksrt_author_minicard($user_id, 'ajax-item', false, $search_query) : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
$user_pages = (int) ceil($search_total / 12);
|
||||
if ($user_pages > 1) {
|
||||
echo '<div class="text-center theme-pagination ajax-pag">' . paginate_links(['base' => esc_url_raw(add_query_arg('user_paged', '%#%')), 'current' => $user_page, 'total' => $user_pages, 'prev_text' => '<i class="fa fas fa-angle-left"></i>', 'next_text' => '<i class="fa fas fa-angle-right"></i>']) . '</div>';
|
||||
if (function_exists('aksrt_get_ajax_next_paginate')) {
|
||||
$user_next_url = add_query_arg([
|
||||
's' => $search_query,
|
||||
'type' => 'user',
|
||||
'orderby' => $orderby,
|
||||
'user_paged' => $user_page + 1,
|
||||
], home_url('/'));
|
||||
echo aksrt_get_ajax_next_paginate($search_total, $user_page, 12, $user_next_url, 'text-center theme-pagination ajax-pag', 'next-page ajax-next'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
?>
|
||||
<?php elseif ($search_type === 'post' && $wp_query->have_posts()) : ?>
|
||||
<?php
|
||||
$config = function_exists('aksrt_archive_get_render_config') ? aksrt_archive_get_render_config(['context' => 'search', 'highlight_query' => $search_query]) : ['context' => 'search', 'mode' => 'list'];
|
||||
aksrt_render_post_list(array_merge($config, ['wrapper_class' => 'mtn6']), $wp_query);
|
||||
$config = function_exists('aksrt_archive_get_render_config') ? aksrt_archive_get_render_config(['context' => 'search', 'highlight_query' => $search_query, 'no_margin' => false]) : ['context' => 'search', 'mode' => 'list'];
|
||||
aksrt_render_post_list(array_merge($config, ['skip_wrapper' => true]), $wp_query);
|
||||
?>
|
||||
<?php aksrt_render_pagination($wp_query, ['query_context' => 'search', 'render_config' => $config]); ?>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-panel search-content"><div class="text-center muted-2-color padding-20"><?php esc_html_e('未找到相关内容', 'aksrt'); ?></div></div>
|
||||
<?php echo function_exists('aksrt_get_ajax_null')
|
||||
? aksrt_get_ajax_null($search_type === 'user' ? __('未找到相关用户', 'aksrt') : __('暂无内容', 'aksrt'), $search_type === 'user' ? 75 : 100, $search_type === 'user' ? 'null-user.svg' : 'null-post.svg')
|
||||
: '<div class="ajax-item text-center muted-2-color padding-20">' . esc_html($search_type === 'user' ? __('未找到相关用户', 'aksrt') : __('暂无内容', 'aksrt')) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif; ?>
|
||||
<div class="post_ajax_loader search-loader"><?php echo function_exists('aksrt_render_placeholder') ? aksrt_render_placeholder('list', 6) : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- 固定骨架结构。 ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (is_active_sidebar('search_bottom_content')) dynamic_sidebar('search_bottom_content'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php get_sidebar(); ?>
|
||||
</main>
|
||||
<?php
|
||||
if (is_active_sidebar('search_bottom_fluid')) {
|
||||
if (is_active_sidebar('search_bottom_fluid') || is_active_sidebar('all_bottom_fluid')) {
|
||||
echo '<div class="fluid-widget-wrap">';
|
||||
dynamic_sidebar('search_bottom_fluid');
|
||||
if (is_active_sidebar('search_bottom_fluid')) dynamic_sidebar('search_bottom_fluid');
|
||||
if (is_active_sidebar('all_bottom_fluid')) dynamic_sidebar('all_bottom_fluid');
|
||||
echo '</div>';
|
||||
}
|
||||
get_footer();
|
||||
Reference in new issue
Block a user