feat(navigation): hard-switch to Zibll navigation and Font Awesome 5
This commit is contained in:
1 parent
3c3ddac8be
commit
a0b84977a2
630 files changed
+101647
-11293
No files matched your search
@@ -12,12 +12,11 @@ if (!function_exists('aksrt_ajax_menu_search')) :
|
||||
* AJAX: HTML panel for navbar inline search (history + hot + posts).
|
||||
*/
|
||||
function aksrt_ajax_menu_search(): void {
|
||||
// Prefer public nonce; also accept no nonce for same-origin remote-box first paint like zibll.
|
||||
if (!empty($_REQUEST['nonce'])) {
|
||||
$nonce = sanitize_text_field(wp_unslash((string) $_REQUEST['nonce']));
|
||||
if (!wp_verify_nonce($nonce, 'aksrt_public_nonce')) {
|
||||
wp_die('0');
|
||||
}
|
||||
$nonce = isset($_REQUEST['nonce'])
|
||||
? sanitize_text_field(wp_unslash((string) $_REQUEST['nonce']))
|
||||
: '';
|
||||
if (!wp_verify_nonce($nonce, 'aksrt_public_nonce')) {
|
||||
wp_die('0');
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_get_search_box')) {
|
||||
@@ -56,26 +55,75 @@ if (!function_exists('aksrt_ajax_menu_search')) :
|
||||
}
|
||||
endif;
|
||||
|
||||
// Panel builder retained as thin alias for any external callers.
|
||||
if (!function_exists('aksrt_get_menu_search_panel_html')) :
|
||||
if (!function_exists('aksrt_ajax_search_box')) :
|
||||
/**
|
||||
* @return string Inner HTML (without dropdown wrapper).
|
||||
* AJAX: full Zibll search box loaded into the footer shell on first open.
|
||||
*/
|
||||
function aksrt_get_menu_search_panel_html(): string {
|
||||
if (!function_exists('aksrt_get_search_box')) {
|
||||
return '';
|
||||
function aksrt_ajax_search_box(): void {
|
||||
$nonce = isset($_REQUEST['nonce'])
|
||||
? sanitize_text_field(wp_unslash((string) $_REQUEST['nonce']))
|
||||
: '';
|
||||
if (!wp_verify_nonce($nonce, 'aksrt_public_nonce') || !function_exists('aksrt_get_search_box')) {
|
||||
wp_die('0');
|
||||
}
|
||||
return (string) aksrt_get_search_box([
|
||||
'show_form' => false,
|
||||
'show_keywords' => true,
|
||||
'show_history' => true,
|
||||
'show_posts' => true,
|
||||
|
||||
echo aksrt_get_search_box([ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'show_form' => true,
|
||||
'show_keywords' => !class_exists('\\AKSRT\\Settings\\Settings') || \AKSRT\Settings\Settings::hot_search_enabled(),
|
||||
'show_history' => !class_exists('\\AKSRT\\Settings\\Settings') || \AKSRT\Settings\Settings::search_history_enabled(),
|
||||
'show_posts' => !class_exists('\\AKSRT\\Settings\\Settings') || \AKSRT\Settings\Settings::search_posts_enabled(),
|
||||
'show_type' => !class_exists('\\AKSRT\\Settings\\Settings') || (bool) \AKSRT\Settings\Settings::get_value('search_type', true),
|
||||
'show_input_cat' => !class_exists('\\AKSRT\\Settings\\Settings') || \AKSRT\Settings\Settings::search_cat_enabled(),
|
||||
]);
|
||||
wp_die();
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_footer_navbar_search')) :
|
||||
/**
|
||||
* Zibll footer search shell. The heavy search body is loaded once via remote-box.
|
||||
*/
|
||||
function aksrt_footer_navbar_search(): void {
|
||||
$show_on_404 = class_exists('\\AKSRT\\Settings\\Settings')
|
||||
? (bool) \AKSRT\Settings\Settings::get_value('404_search_s', true)
|
||||
: true;
|
||||
if (is_search() || (is_404() && $show_on_404)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$remote = aksrt_get_remote_box([
|
||||
'type' => 'load',
|
||||
'class' => '',
|
||||
'loader' => '<div class="search-input"><p><i class="placeholder s1 mr6"></i><i class="placeholder s1 mr6"></i><i class="placeholder s1 mr6"></i></p><p class="placeholder k2"></p><p class="placeholder t1"></p><p><i class="placeholder s1 mr6"></i><i class="placeholder s1 mr6"></i><i class="placeholder s1 mr6"></i><i class="placeholder s1 mr6"></i></p><p class="placeholder k1"></p><p class="placeholder t1"></p><p></p><p class="placeholder k1" style="height:80px;"></p></div>',
|
||||
'query' => [
|
||||
'action' => 'search_box',
|
||||
'nonce' => wp_create_nonce('aksrt_public_nonce'),
|
||||
],
|
||||
]);
|
||||
|
||||
echo '<div mini-touch="nav_search" touch-direction="top" class="main-search fixed-body main-bg box-body navbar-search nopw-sm">';
|
||||
echo '<div class="container">';
|
||||
echo '<div class="mb20 search-close-box"><button type="button" class="but cir" data-toggle-class data-target=".navbar-search" aria-label="'
|
||||
. esc_attr__('关闭搜索', 'aksrt') . '"><svg class="ic-close" aria-hidden="true"><use xlink:href="#icon-close"></use></svg></button></div>';
|
||||
echo $remote; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '</div></div>';
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_ajax_zibll_current_user_ping')) :
|
||||
/** Satisfy the reference runtime's one-shot user-state refresh request. */
|
||||
function aksrt_ajax_zibll_current_user_ping(): void {
|
||||
wp_send_json_success([
|
||||
'logged_in' => is_user_logged_in(),
|
||||
'user_id' => get_current_user_id(),
|
||||
]);
|
||||
}
|
||||
endif;
|
||||
|
||||
add_action('wp_ajax_aksrt_menu_search', 'aksrt_ajax_menu_search');
|
||||
add_action('wp_ajax_nopriv_aksrt_menu_search', 'aksrt_ajax_menu_search');
|
||||
// Alias for zibll-compatible remote-box query action name used in markup.
|
||||
add_action('wp_ajax_menu_search', 'aksrt_ajax_menu_search');
|
||||
add_action('wp_ajax_nopriv_menu_search', 'aksrt_ajax_menu_search');
|
||||
add_action('wp_ajax_search_box', 'aksrt_ajax_search_box');
|
||||
add_action('wp_ajax_nopriv_search_box', 'aksrt_ajax_search_box');
|
||||
add_action('wp_ajax_get_current_user', 'aksrt_ajax_zibll_current_user_ping');
|
||||
add_action('wp_ajax_nopriv_get_current_user', 'aksrt_ajax_zibll_current_user_ping');
|
||||
add_action('wp_footer', 'aksrt_footer_navbar_search', 10);
|
||||
@@ -23,8 +23,7 @@ if (!function_exists('aksrt_nav_mobile_shell')) :
|
||||
|
||||
$touch_attr = '';
|
||||
if ($align !== 'top') {
|
||||
// mini-touch.js reads data-mini-touch; direction via data-touch-direction.
|
||||
$touch_attr = ' data-mini-touch="mobile-nav" data-touch-direction="' . esc_attr($align) . '"';
|
||||
$touch_attr = ' mini-touch="mobile-nav" touch-direction="' . esc_attr($align) . '"';
|
||||
}
|
||||
|
||||
echo '<div class="mobile-header">';
|
||||
@@ -41,9 +40,9 @@ if (!function_exists('aksrt_nav_mobile_shell')) :
|
||||
: '<span class="navbar-logo-text">' . esc_html($brand_name) . '</span>';
|
||||
|
||||
echo '<div class="flex jsb ac mb20">';
|
||||
echo '<div class="navbar-logo"><a href="' . esc_url(home_url('/')) . '">' . $logo_inner . '</a></div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="navbar-logo">' . $logo_inner . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<button type="button" data-toggle-class="mobile-navbar-show" data-target="body" class="close" aria-label="'
|
||||
. esc_attr__('关闭菜单', 'aksrt') . '"><i class="fas fa-times" aria-hidden="true"></i></button>';
|
||||
. esc_attr__('关闭菜单', 'aksrt') . '"><svg class="ic-close" aria-hidden="true"><use xlink:href="#icon-close"></use></svg></button>';
|
||||
echo '</div>';
|
||||
|
||||
aksrt_nav_mobile_content($ctx, $m_layout);
|
||||
@@ -72,13 +71,12 @@ if (!function_exists('aksrt_nav_mobile_content')) :
|
||||
if (in_array('m_menu', (array) ($ctx['theme_positions'] ?? []), true)) {
|
||||
$top_btns .= '<a href="javascript:;" class="toggle-theme toggle-radius" id="theme-toggle-mobile" title="'
|
||||
. esc_attr__('切换亮暗色', 'aksrt') . '">';
|
||||
$top_btns .= '<i class="fas fa-moon theme-icon-moon" aria-hidden="true"></i>';
|
||||
$top_btns .= '<i class="fas fa-sun theme-icon-sun" aria-hidden="true"></i>';
|
||||
$top_btns .= '<i class="fa fas fa-toggle-theme" aria-hidden="true"></i>';
|
||||
$top_btns .= '</a>';
|
||||
}
|
||||
if ($m_layout !== 'center' && !empty($ctx['search_enabled'])) {
|
||||
$top_btns .= '<a href="javascript:;" class="toggle-radius main-search-btn" data-toggle-class="show" data-target=".navbar-search" aria-label="'
|
||||
. esc_attr__('打开搜索', 'aksrt') . '"><i class="fas fa-search" aria-hidden="true"></i></a>';
|
||||
if ($m_layout !== 'center') {
|
||||
$top_btns .= '<a href="javascript:;" class="toggle-radius main-search-btn" aria-label="'
|
||||
. esc_attr__('打开搜索', 'aksrt') . '"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-search"></use></svg></a>';
|
||||
}
|
||||
if (function_exists('aksrt_get_translate_language_btn')) {
|
||||
$top_btns .= aksrt_get_translate_language_btn('pull-right');
|
||||
@@ -89,11 +87,7 @@ if (!function_exists('aksrt_nav_mobile_content')) :
|
||||
|
||||
$location = has_nav_menu('mobile') ? 'mobile' : 'primary';
|
||||
$walker = class_exists('\AKSRT\Frontend\NavWalker')
|
||||
? new \AKSRT\Frontend\NavWalker(
|
||||
function_exists('aksrt_get_menu_decoration_settings')
|
||||
? aksrt_get_menu_decoration_settings()
|
||||
: []
|
||||
)
|
||||
? new \AKSRT\Frontend\NavWalker()
|
||||
: null;
|
||||
|
||||
$args = [
|
||||
@@ -124,8 +118,6 @@ if (!function_exists('aksrt_nav_mobile_content')) :
|
||||
}
|
||||
|
||||
// User box at bottom of drawer.
|
||||
if (!empty($ctx['user_menu'])) {
|
||||
echo aksrt_header_user_box_html($ctx); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
echo aksrt_header_user_box_html($ctx); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
endif;
|
||||
@@ -17,11 +17,7 @@ if (!function_exists('aksrt_menu_items')) :
|
||||
*/
|
||||
function aksrt_menu_items(string $location = 'primary', bool $echo = true) {
|
||||
$walker = class_exists('\AKSRT\Frontend\NavWalker')
|
||||
? new \AKSRT\Frontend\NavWalker(
|
||||
function_exists('aksrt_get_menu_decoration_settings')
|
||||
? aksrt_get_menu_decoration_settings()
|
||||
: []
|
||||
)
|
||||
? new \AKSRT\Frontend\NavWalker()
|
||||
: null;
|
||||
|
||||
$args = [
|
||||
@@ -76,10 +72,10 @@ if (!function_exists('aksrt_navbar_header')) :
|
||||
. esc_attr__('打开菜单', 'aksrt') . '">';
|
||||
$button .= '<i class="em12 css-icon i-menu"><i></i></i></button>';
|
||||
|
||||
if (($ctx['mobile_layout'] ?? 'center') === 'center' && !empty($ctx['search_enabled'])) {
|
||||
$button .= '<button type="button" class="navbar-toggle main-search-btn nav-search-btn" data-toggle-class="show" data-target=".navbar-search" aria-label="'
|
||||
if (($ctx['mobile_layout'] ?? 'center') === 'center') {
|
||||
$button .= '<a href="javascript:;" class="navbar-toggle main-search-btn" aria-label="'
|
||||
. esc_attr__('打开搜索', 'aksrt') . '">';
|
||||
$button .= '<i class="fas fa-search" aria-hidden="true"></i></button>';
|
||||
$button .= '<svg class="icon" aria-hidden="true"><use xlink:href="#icon-search"></use></svg></a>';
|
||||
}
|
||||
|
||||
echo '<div class="navbar-header">';
|
||||
@@ -102,22 +98,26 @@ if (!function_exists('aksrt_get_menu_search')) :
|
||||
$placeholder = (string) ($ctx['search_placeholder'] ?? __('搜索内容', 'aksrt'));
|
||||
|
||||
// zibll: form + input + remote-box (action=menu_search).
|
||||
echo '<form method="get" class="navbar-form navbar-left hover-show" action="' . esc_url(home_url('/')) . '" role="search" data-aksrt-search-form="inline">';
|
||||
echo '<form method="get" class="navbar-form navbar-left hover-show" action="' . esc_url(home_url('/')) . '">';
|
||||
echo '<div class="form-group relative dropdown">';
|
||||
echo '<input type="text" class="form-control search-input focus-show" name="s" value="'
|
||||
. esc_attr(get_search_query()) . '" placeholder="' . esc_attr($placeholder) . '" autocomplete="off">';
|
||||
echo '<div class="abs-right muted-3-color"><button type="submit" class="null" aria-label="'
|
||||
. esc_attr__('搜索', 'aksrt') . '"><i class="fas fa-search" aria-hidden="true"></i></button></div>';
|
||||
. esc_attr__('搜索', 'aksrt') . '"><i class="fa fas fa-search" aria-hidden="true"></i></button></div>';
|
||||
if (function_exists('aksrt_get_remote_box')) {
|
||||
echo aksrt_get_remote_box([ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'class' => '',
|
||||
'loader' => ' ',
|
||||
'query' => [
|
||||
'action' => 'menu_search',
|
||||
'nonce' => wp_create_nonce('aksrt_public_nonce'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
$remote_url = add_query_arg(['action' => 'menu_search'], admin_url('admin-ajax.php'));
|
||||
$remote_url = add_query_arg([
|
||||
'action' => 'menu_search',
|
||||
'nonce' => wp_create_nonce('aksrt_public_nonce'),
|
||||
], admin_url('admin-ajax.php'));
|
||||
echo '<div class="lazyload" remote-box="' . esc_url($remote_url) . '" lazyload-action="ias">';
|
||||
echo '<i class="loading-spot"><i></i></i></div>';
|
||||
}
|
||||
@@ -137,11 +137,6 @@ if (!function_exists('aksrt_header_user_box_html')) :
|
||||
return $html;
|
||||
}
|
||||
|
||||
if (empty($ctx['user_menu'])) {
|
||||
$html = '';
|
||||
return $html;
|
||||
}
|
||||
|
||||
$user_id = (int) ($ctx['user_id'] ?? 0);
|
||||
$con = '';
|
||||
|
||||
@@ -186,7 +181,7 @@ if (!function_exists('aksrt_header_user_box_html')) :
|
||||
$msg_icon = '';
|
||||
if ($msg_url !== '') {
|
||||
$msg_icon = '<a class="abs-right" href="' . esc_url($msg_url) . '" title="' . esc_attr__('消息中心', 'aksrt') . '">';
|
||||
$msg_icon .= '<i class="fas fa-bell" aria-hidden="true"></i>';
|
||||
$msg_icon .= '<i class="fa fas fa-bell" aria-hidden="true"></i>';
|
||||
if ($unread > 0) {
|
||||
$msg_icon .= '<span class="aksrt-notification-badge">' . esc_html((string) min(99, $unread)) . '</span>';
|
||||
}
|
||||
@@ -195,44 +190,44 @@ if (!function_exists('aksrt_header_user_box_html')) :
|
||||
|
||||
$href = '<div class="flex jsa header-user-href">';
|
||||
$href .= '<a rel="nofollow" href="' . esc_url(function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/')) . '">';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-blue"><i class="fas fa-user" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-blue"><i class="fa fas fa-user" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="c-blue">' . esc_html__('用户中心', 'aksrt') . '</div></a>';
|
||||
|
||||
$orders = (string) ($ctx['orders_url'] ?? '');
|
||||
if ($orders !== '') {
|
||||
$href .= '<a rel="nofollow" href="' . esc_url($orders) . '">';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-purple"><i class="fas fa-shopping-bag" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-purple"><i class="fa fas fa-shopping-bag" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="c-purple">' . esc_html__('我的订单', 'aksrt') . '</div></a>';
|
||||
}
|
||||
|
||||
if (!empty($ctx['can_publish'])) {
|
||||
$all = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
|
||||
$pub_text = (string) ($all['header_user_newposts_text'] ?? '');
|
||||
$pub_text = (string) ($all['nav_user_newposts_btn_text'] ?? '');
|
||||
if ($pub_text === '') {
|
||||
$pub_text = __('发布内容', 'aksrt');
|
||||
}
|
||||
$pub_url = (string) $ctx['publish_url'];
|
||||
$href .= '<a rel="nofollow" href="' . esc_url($pub_url) . '">';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-green"><i class="fas fa-pen" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-green"><i class="fa fas fa-edit" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="c-green">' . esc_html($pub_text) . '</div></a>';
|
||||
}
|
||||
|
||||
$href .= '<a href="javascript:;" data-toggle="modal" data-target="#modal_signout">';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-red"><i class="fas fa-sign-out-alt" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-red"><i class="fa fas fa-sign-out-alt" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="c-red">' . esc_html__('退出登录', 'aksrt') . '</div></a>';
|
||||
$href .= '</div>';
|
||||
|
||||
if (is_super_admin()) {
|
||||
$href .= '<div class="flex jsa header-user-href">';
|
||||
$href .= '<a rel="nofollow" target="_blank" href="' . esc_url((string) $ctx['theme_settings_url']) . '">';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-yellow"><i class="fas fa-sliders-h" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-yellow"><i class="fa fas fa-sliders-h" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="c-yellow">' . esc_html__('主题设置', 'aksrt') . '</div></a>';
|
||||
// zibll: 模块布局 → widgets.
|
||||
$href .= '<a rel="nofollow" target="_blank" href="' . esc_url(admin_url('widgets.php')) . '">';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-yellow"><i class="fas fa-chart-pie" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-yellow"><i class="fa fas fa-chart-pie" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="c-yellow">' . esc_html__('模块布局', 'aksrt') . '</div></a>';
|
||||
$href .= '<a rel="nofollow" target="_blank" href="' . esc_url(admin_url()) . '">';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-yellow"><i class="fas fa-cog" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="badg mb6 toggle-radius c-yellow"><i class="fa fas fa-cog" aria-hidden="true"></i></div>';
|
||||
$href .= '<div class="c-yellow">' . esc_html__('后台管理', 'aksrt') . '</div></a>';
|
||||
$href .= '</div>';
|
||||
}
|
||||
@@ -258,20 +253,20 @@ if (!function_exists('aksrt_header_user_box_html')) :
|
||||
$vs = \AKSRT\Settings\Settings::get_payment_vip_settings();
|
||||
if (!empty($vs['enabled'])) {
|
||||
$vip_guest = '<div><a class="em09 signin-loader but jb-red radius4 payvip-icon btn-block mt10" href="javascript:;">'
|
||||
. '<i class="fas fa-gem" aria-hidden="true"></i> '
|
||||
. '<i class="fa fas fa-gem" aria-hidden="true"></i> '
|
||||
. esc_html__('开通会员 尊享会员权益', 'aksrt') . '</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
$href = $vip_guest;
|
||||
$href .= '<div class="flex jsa header-user-href">';
|
||||
$href .= '<a href="javascript:;" class="signin-loader"><div class="badg mb6 toggle-radius c-blue"><i class="fas fa-sign-in-alt" aria-hidden="true"></i></div><div class="c-blue">'
|
||||
$href .= '<a href="javascript:;" class="signin-loader"><div class="badg mb6 toggle-radius c-blue"><i class="fa fas fa-sign-in-alt" aria-hidden="true"></i></div><div class="c-blue">'
|
||||
. esc_html__('登录', 'aksrt') . '</div></a>';
|
||||
if (get_option('users_can_register')) {
|
||||
$href .= '<a href="javascript:;" class="signup-loader"><div class="badg mb6 toggle-radius c-green"><i class="fas fa-user-plus" aria-hidden="true"></i></div><div class="c-green">'
|
||||
$href .= '<a href="javascript:;" class="signup-loader"><div class="badg mb6 toggle-radius c-green"><i class="fa fas fa-user-plus" aria-hidden="true"></i></div><div class="c-green">'
|
||||
. esc_html__('注册', 'aksrt') . '</div></a>';
|
||||
}
|
||||
$href .= '<a rel="nofollow" href="' . esc_url(wp_lostpassword_url(home_url('/'))) . '"><div class="badg mb6 toggle-radius c-purple"><i class="fas fa-key" aria-hidden="true"></i></div><div class="c-purple">'
|
||||
$href .= '<a rel="nofollow" href="' . esc_url(wp_lostpassword_url(home_url('/'))) . '"><div class="badg mb6 toggle-radius c-purple"><i class="fa fas fa-key" aria-hidden="true"></i></div><div class="c-purple">'
|
||||
. esc_html__('找回密码', 'aksrt') . '</div></a>';
|
||||
$href .= '</div>';
|
||||
|
||||
@@ -303,7 +298,10 @@ if (!function_exists('aksrt_menu_button')) :
|
||||
|
||||
// Publish + VIP (respect nav_pay_vip).
|
||||
if (function_exists('aksrt_render_header_menu_buttons')) {
|
||||
$button .= aksrt_render_header_menu_buttons();
|
||||
$action_buttons = aksrt_render_header_menu_buttons();
|
||||
if ($action_buttons !== '') {
|
||||
$button .= '<div class="navbar-form navbar-right navbar-but">' . $action_buttons . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Theme toggle.
|
||||
@@ -311,8 +309,7 @@ if (!function_exists('aksrt_menu_button')) :
|
||||
if (in_array('pc_nav', (array) ($ctx['theme_positions'] ?? []), true)) {
|
||||
$radius_but .= '<a href="javascript:;" class="toggle-theme toggle-radius" id="theme-toggle-desktop" title="'
|
||||
. esc_attr__('切换亮暗色', 'aksrt') . '">';
|
||||
$radius_but .= '<i class="fas fa-moon theme-icon-moon" aria-hidden="true"></i>';
|
||||
$radius_but .= '<i class="fas fa-sun theme-icon-sun" aria-hidden="true"></i>';
|
||||
$radius_but .= '<i class="fa fas fa-toggle-theme" aria-hidden="true"></i>';
|
||||
$radius_but .= '</a>';
|
||||
}
|
||||
if (function_exists('aksrt_get_translate_language_btn')) {
|
||||
@@ -324,37 +321,29 @@ if (!function_exists('aksrt_menu_button')) :
|
||||
|
||||
// User + search.
|
||||
$sign_but = '';
|
||||
$user_sub = '';
|
||||
if (!empty($ctx['user_menu'])) {
|
||||
$user_sub = '<div class="padding-10">' . aksrt_header_user_box_html($ctx) . '</div>';
|
||||
if ('2' === $layout) {
|
||||
if ($user_id > 0) {
|
||||
$avatar = aksrt_get_avatar_html($user_id, 36, ['class' => 'avatar']);
|
||||
$sign_but = '<li><a href="javascript:;" class="navbar-avatar">' . $avatar . '</a><ul class="sub-menu">'
|
||||
. $user_sub . '</ul></li>';
|
||||
} else {
|
||||
$sign_but = '<li><a href="javascript:;" class="signin-loader">' . esc_html__('登录', 'aksrt') . '</a></li>';
|
||||
if (get_option('users_can_register')) {
|
||||
$sign_but .= '<li><a href="javascript:;" class="signup-loader">' . esc_html__('注册', 'aksrt') . '</a></li>';
|
||||
}
|
||||
}
|
||||
$user_sub = '<div class="padding-10">' . aksrt_header_user_box_html($ctx) . '</div>';
|
||||
if ('2' === $layout) {
|
||||
if ($user_id > 0) {
|
||||
$avatar = aksrt_get_avatar_html($user_id, 36, ['class' => 'avatar']);
|
||||
$sign_but = '<li><a href="javascript:;" class="navbar-avatar">' . $avatar . '</a><ul class="sub-menu">'
|
||||
. $user_sub . '</ul></li>';
|
||||
} else {
|
||||
$trigger = $user_id > 0
|
||||
? aksrt_get_avatar_html($user_id, 36)
|
||||
: '<i class="fas fa-user" aria-hidden="true"></i>';
|
||||
$cls = $user_id > 0 ? 'navbar-avatar' : 'btn signin-loader';
|
||||
$dot = ($user_id > 0 && (int) ($ctx['unread_count'] ?? 0) > 0)
|
||||
? '<span class="nav-user__dot" aria-hidden="true"></span>'
|
||||
: '';
|
||||
$sign_but = '<li class="relative"><a href="javascript:;" class="' . esc_attr($cls) . '">'
|
||||
. $trigger . $dot . '</a><ul class="sub-menu">' . $user_sub . '</ul></li>';
|
||||
$sign_but = '<li><a href="javascript:;" class="signin-loader">' . esc_html__('登录', 'aksrt') . '</a></li>';
|
||||
if (get_option('users_can_register')) {
|
||||
$sign_but .= '<li><a href="javascript:;" class="signup-loader">' . esc_html__('注册', 'aksrt') . '</a></li>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$cls = 'btn' . ($user_id > 0 ? '' : ' signin-loader');
|
||||
$sign_but = '<li><a href="javascript:;" class="' . esc_attr($cls) . '">'
|
||||
. '<svg class="icon" aria-hidden="true"><use xlink:href="#icon-user"></use></svg></a>'
|
||||
. '<ul class="sub-menu">' . $user_sub . '</ul></li>';
|
||||
}
|
||||
|
||||
$search_but = '';
|
||||
if ('2' !== $layout && !empty($ctx['search_enabled'])) {
|
||||
$search_but = '<li class="relative"><a href="javascript:;" class="btn nav-search-btn main-search-btn" data-toggle-class="show" data-target=".navbar-search" aria-label="'
|
||||
. esc_attr__('打开搜索', 'aksrt') . '"><i class="fas fa-search" aria-hidden="true"></i></a></li>';
|
||||
if ('2' !== $layout) {
|
||||
$search_but = '<li class="relative"><a href="javascript:;" class="btn nav-search-btn main-search-btn" aria-label="'
|
||||
. esc_attr__('打开搜索', 'aksrt') . '"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-search"></use></svg></a></li>';
|
||||
}
|
||||
|
||||
$right_but = '<div class="navbar-form navbar-right'
|
||||
@@ -364,7 +353,7 @@ if (!function_exists('aksrt_menu_button')) :
|
||||
|
||||
$fold = '<div class="navbar-form navbar-right hide show-nav-but" style="margin-right:-10px;">'
|
||||
. '<a data-toggle-class data-target=".nav.navbar-nav" href="javascript:;" class="but" aria-label="'
|
||||
. esc_attr__('展开菜单', 'aksrt') . '"><i class="fas fa-bars" aria-hidden="true"></i></a></div>';
|
||||
. esc_attr__('展开菜单', 'aksrt') . '"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-menu_2"></use></svg></a></div>';
|
||||
|
||||
$html = $fold;
|
||||
if ('3' === $layout) {
|
||||
|
||||
@@ -20,22 +20,21 @@ if (!function_exists('aksrt_get_header_nav_context')) :
|
||||
}
|
||||
|
||||
$settings = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_header_nav_settings()
|
||||
: [
|
||||
'fixed' => true,
|
||||
'search_enabled' => true,
|
||||
'user_menu' => true,
|
||||
'publish_btn' => true,
|
||||
'mobile_drawer' => true,
|
||||
'nav_style' => 'default',
|
||||
'max_width' => 1200,
|
||||
'scroll_down_hide' => true,
|
||||
'layout' => '1',
|
||||
'mobile_layout' => 'center',
|
||||
'mobile_align' => 'left',
|
||||
'nav_pay_vip' => true,
|
||||
'nav_user_pay_vip' => true,
|
||||
];
|
||||
? \AKSRT\Settings\Settings::get_all()
|
||||
: [];
|
||||
$layout = sanitize_key((string) ($settings['header_layout'] ?? '1'));
|
||||
if (!in_array($layout, ['1', '2', '3'], true)) {
|
||||
$layout = '1';
|
||||
}
|
||||
$mobile_layout = sanitize_key((string) ($settings['mobile_header_layout'] ?? 'center'));
|
||||
if (!in_array($mobile_layout, ['center', 'left'], true)) {
|
||||
$mobile_layout = 'center';
|
||||
}
|
||||
$mobile_align = sanitize_key((string) ($settings['mobile_navbar_align'] ?? 'left'));
|
||||
if (!in_array($mobile_align, ['top', 'left', 'right'], true)) {
|
||||
$mobile_align = 'left';
|
||||
}
|
||||
$nav_fixed = !isset($settings['nav_fixed']) || !empty($settings['nav_fixed']);
|
||||
|
||||
$site_name = get_bloginfo('name');
|
||||
$brand_name = function_exists('aksrt_get_site_logo_text') ? aksrt_get_site_logo_text() : $site_name;
|
||||
@@ -57,7 +56,7 @@ if (!function_exists('aksrt_get_header_nav_context')) :
|
||||
? \AKSRT\Settings\Settings::get_theme_mode_button_positions()
|
||||
: ['pc_nav', 'm_menu'];
|
||||
|
||||
$can_publish = !empty($settings['publish_btn']) && (
|
||||
$can_publish = (!isset($settings['nav_newposts']) || !empty($settings['nav_newposts'])) && (
|
||||
current_user_can('manage_options')
|
||||
|| (class_exists('\AKSRT\Core\FrontSubmit') && \AKSRT\Core\FrontSubmit::get_instance()->can_submit())
|
||||
);
|
||||
@@ -75,17 +74,13 @@ if (!function_exists('aksrt_get_header_nav_context')) :
|
||||
|
||||
$ctx = [
|
||||
'settings' => $settings,
|
||||
'layout' => (string) ($settings['layout'] ?? '1'),
|
||||
'mobile_layout' => (string) ($settings['mobile_layout'] ?? 'center'),
|
||||
'mobile_align' => (string) ($settings['mobile_align'] ?? 'left'),
|
||||
'fixed' => !empty($settings['fixed']),
|
||||
'scroll_down_hide' => !empty($settings['scroll_down_hide']) && !empty($settings['fixed']),
|
||||
'search_enabled' => !empty($settings['search_enabled']),
|
||||
'user_menu' => !empty($settings['user_menu']),
|
||||
'mobile_drawer' => !empty($settings['mobile_drawer']),
|
||||
'layout' => $layout,
|
||||
'mobile_layout' => $mobile_layout,
|
||||
'mobile_align' => $mobile_align,
|
||||
'fixed' => $nav_fixed,
|
||||
'scroll_down_hide' => (!isset($settings['nav_scroll_down_hide']) || !empty($settings['nav_scroll_down_hide'])) && $nav_fixed,
|
||||
'nav_pay_vip' => !isset($settings['nav_pay_vip']) || !empty($settings['nav_pay_vip']),
|
||||
'nav_user_pay_vip' => !isset($settings['nav_user_pay_vip']) || !empty($settings['nav_user_pay_vip']),
|
||||
'max_width' => (int) ($settings['max_width'] ?? 1200),
|
||||
'brand_name' => $brand_name,
|
||||
'logo_html' => $logo_html,
|
||||
'has_logo' => $logo_html !== '',
|
||||
@@ -148,35 +143,22 @@ if (!function_exists('aksrt_header')) :
|
||||
}
|
||||
|
||||
$nav_class = [
|
||||
'navbar',
|
||||
'navbar-top',
|
||||
$ctx['mobile_layout'],
|
||||
];
|
||||
$style_key = sanitize_key((string) ($ctx['settings']['nav_style'] ?? 'default'));
|
||||
if (in_array($style_key, ['transparent', 'blur'], true)) {
|
||||
$header_class[] = 'nav-style-' . $style_key;
|
||||
$nav_class[] = 'nav-style-' . $style_key;
|
||||
}
|
||||
|
||||
$nav_style = '';
|
||||
if ((int) $ctx['max_width'] > 0) {
|
||||
$nav_style = ' style="--nav-max-width:' . (int) $ctx['max_width'] . 'px"';
|
||||
}
|
||||
'navbar',
|
||||
'navbar-top',
|
||||
$ctx['mobile_layout'],
|
||||
];
|
||||
|
||||
echo '<header class="' . esc_attr(implode(' ', array_map('sanitize_html_class', $header_class))) . '">';
|
||||
echo '<nav class="' . esc_attr(implode(' ', array_map('sanitize_html_class', $nav_class))) . '"' . $nav_style . '>';
|
||||
echo '<nav class="' . esc_attr(implode(' ', array_map('sanitize_html_class', $nav_class))) . '">';
|
||||
echo '<div class="container-fluid container-header">';
|
||||
|
||||
aksrt_navbar_header($ctx);
|
||||
|
||||
// Do NOT use Bootstrap's `.collapse` here — BS5 hides `.collapse:not(.show)`
|
||||
// which would wipe the whole PC top bar (menu / CTA / user / search).
|
||||
// Zibll uses a plain `.navbar-collapse` flex row; mobile uses the drawer.
|
||||
echo '<div class="navbar-collapse">';
|
||||
echo '<div class="collapse navbar-collapse">';
|
||||
if ('3' !== $layout) {
|
||||
aksrt_menu_items('primary', true);
|
||||
}
|
||||
if ('2' === $layout && !empty($ctx['search_enabled'])) {
|
||||
if ('2' === $layout) {
|
||||
aksrt_get_menu_search($ctx);
|
||||
}
|
||||
aksrt_menu_button($ctx);
|
||||
@@ -187,17 +169,11 @@ $nav_style = '';
|
||||
}
|
||||
echo '</div></div></nav></header>';
|
||||
|
||||
if (!empty($ctx['mobile_drawer'])) {
|
||||
aksrt_nav_mobile_shell($ctx);
|
||||
}
|
||||
aksrt_nav_mobile_shell($ctx);
|
||||
|
||||
// Layout 1/3 search slide (zibll .navbar-search). Layout-2 uses inline menu_search.
|
||||
if (!empty($ctx['search_enabled'])) {
|
||||
$navbar_search = locate_template('templates/parts/navbar-search.php');
|
||||
if ($navbar_search) {
|
||||
include $navbar_search;
|
||||
}
|
||||
}
|
||||
if (!empty($ctx['show_slide']) && function_exists('aksrt_header_slide')) {
|
||||
aksrt_header_slide();
|
||||
}
|
||||
|
||||
if (function_exists('aksrt_render_signout_modal')) {
|
||||
aksrt_render_signout_modal();
|
||||
|
||||
Reference in new issue
Block a user