[add]在PHP中添加拦截导航为/zh/zh_CN等中文站内容,添加新页面基础配置

dev-about
huyuanxiang 2 months ago
parent 6a461052f9
commit d72526ebee

@ -49,8 +49,9 @@
<h3 class="footer-nav-title">ABOUT US</h3> <h3 class="footer-nav-title">ABOUT US</h3>
<ul class="footer-nav-list"> <ul class="footer-nav-list">
<li><a href="/about-us">Company Profile</a></li> <li><a href="/about-us">Company Profile</a></li>
<li><a href="/contact-us">Contact Nenghui</a></li>
<li><a href="/honor">Certifications & Accreditations</a></li> <li><a href="/honor">Certifications & Accreditations</a></li>
<li><a href="/cases">Cases</a></li>
<li><a href="/news">News</a></li> <li><a href="/news">News</a></li>
</ul> </ul>
</div> </div>
@ -60,12 +61,12 @@
<ul class="footer-nav-list"> <ul class="footer-nav-list">
<li><a href="/pros/">Products</a></li> <li><a href="/pros/">Products</a></li>
<li><a href="/epc-solutions">EPC & Energy Solutions</a></li> <li><a href="/epc-solutions">EPC & Energy Solutions</a></li>
<li><a href="/cases">Cases</a></li>
</ul> </ul>
</div> </div>
<div class="footer-nav-column"> <div class="footer-nav-column">
<h3 class="footer-nav-title">CONTACT US</h3> <h3 class="footer-nav-title">CAREER</h3>
<ul class="footer-nav-list"> <ul class="footer-nav-list">
<li><a href="/contact-us">Contact Us</a></li>
<li><a href="/join-us/">Join Us</a></li> <li><a href="/join-us/">Join Us</a></li>
</ul> </ul>
</div> </div>
@ -113,6 +114,8 @@
<?php wp_footer(); ?> <?php wp_footer(); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/aos/2.3.4/aos.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/aos/2.3.4/aos.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-tilt/1.7.2/vanilla-tilt.min.js"></script>
<script> <script>
AOS.init({ AOS.init({
duration: 800, // 动画持续时间 duration: 800, // 动画持续时间

@ -469,4 +469,76 @@ function load_more_products_callback() {
wp_send_json_success(array('products' => $products)); wp_send_json_success(array('products' => $products));
} }
// 拦截导航
// 关键修改:将钩子从 'template_redirect' 提前到 'init',并保持优先级 1
add_action( 'init', 'custom_redirect_chinese_to_cn_domain', 1 );
function custom_redirect_chinese_to_cn_domain() {
// 忽略后台请求和 AJAX 请求,避免误杀管理员操作
if ( is_admin() || ( defined('DOING_AJAX') && DOING_AJAX ) ) {
return;
}
$target_domain = 'https://cn.nenghui.com';
$current_uri = $_SERVER['REQUEST_URI'];
$is_chinese_request = false;
$matched_reason = '';
// ==========================================
// 🛠️ 调试模式开关 (测试完毕后请改为 false)
// ==========================================
$debug_mode = false;
// 1. 嗅探 A严格的正则匹配匹配 /zh/, /zh_CN, /zh-cn/ 等
// 解释:(?:^|/) 开头或斜杠; (zh|zh_CN|zh-CN|zh-cn|cn) 语言代码; (/|\?|$) 结尾、参数或斜杠
if ( preg_match( '#(?:^|/)(zh|zh_CN|zh-CN|zh-cn|cn)(/|\?|$)#i', $current_uri, $matches ) ) {
$is_chinese_request = true;
$matched_reason = "URL 路径匹配成功 (检测到: " . $matches[1] . ")";
}
// 2. 嗅探 B检查 GET 参数 (?lang=zh_CN)
if ( isset( $_GET['lang'] ) && in_array( strtolower($_GET['lang']), ['zh_cn', 'zh-cn', 'zh', 'cn'] ) ) {
$is_chinese_request = true;
$matched_reason = "URL 参数匹配成功 (?lang=" . $_GET['lang'] . ")";
}
// ==========================================
// 🖥️ 可视化调试输出
// ==========================================
if ( $debug_mode && $is_chinese_request ) {
// 如果开启了调试且匹配成功,直接输出并终止
echo "<div style='background:#111; color:#13eca4; padding:30px; font-family:monospace; border:2px solid #ff6b00; margin:20px; border-radius:10px; z-index:99999; position:relative;'>";
echo "<h2 style='color:#fff; border-bottom:1px solid #333; padding-bottom:10px;'>🚀 路由跳转调试面板 (Init Hook)</h2>";
echo "<p><strong>当前请求的 URI:</strong> " . esc_html($current_uri) . "</p>";
echo "<p style='color:#ff6b00;'><strong>状态:</strong> 🟢 匹配成功!准备执行跳转。</p>";
echo "<p><strong>触发原因:</strong> " . esc_html($matched_reason) . "</p>";
echo "<p><strong>目标地址:</strong> " . esc_html(trailingslashit($target_domain)) . "</p>";
echo "<p style='margin-top:20px; color:#aaa;'><em>提示:关闭 \$debug_mode 即可真正执行 301 跳转。</em></p>";
echo "</div>";
exit;
} elseif ( $debug_mode && isset($_GET['test_redirect']) ) {
// 增加一个强制调试入口。输入 http://localhost:82/?test_redirect=1 查看未匹配原因
echo "<div style='background:#111; color:#f44336; padding:30px; font-family:monospace; border:2px solid #333; margin:20px; border-radius:10px;'>";
echo "<h2>🔴 未匹配到中文特征</h2>";
echo "<p>当前 URI: " . esc_html($current_uri) . "</p>";
echo "</div>";
exit;
}
// ==========================================
// 🚀 正式执行跳转逻辑
// ==========================================
if ( $is_chinese_request && !$debug_mode ) {
// 统一跳转到国内站首页
$final_url = trailingslashit( $target_domain );
// 必须使用 wp_safe_redirect 或 header 并在前置 hook 提前输出
wp_redirect( $final_url, 301 );
exit;
}
}
?> ?>

@ -10,11 +10,12 @@
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&amp;display=swap" rel="stylesheet"/> <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&amp;display=swap" rel="stylesheet"/>
<link href="https://fonts.googleapis.com" rel="preconnect"/> <link href="https://fonts.googleapis.com" rel="preconnect"/>
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/> <link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;700&family=Inter:wght@400;500;700;800;900&family=JetBrains+Mono:wght@500&&amp;display=swap" rel="stylesheet"/> <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;700&family=Liu+Jian+Mao+Cao:wght@400;700&family=Sacramento&family=Inter:wght@400;500;700;800;900&family=JetBrains+Mono:wght@500&&amp;display=swap" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.min.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.min.css" />
<!-- AOS Animation Library --> <!-- AOS Animation Library -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/aos/2.3.4/aos.css" rel="stylesheet"> <link href="https://cdnjs.cloudflare.com/ajax/libs/aos/2.3.4/aos.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-tilt/1.7.2/vanilla-tilt.min.js"></script>
<!-- Tailwind & Config --> <!-- Tailwind & Config -->
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script> <script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
<script id="tailwind-config"> <script id="tailwind-config">
@ -28,6 +29,7 @@
"background-dark": "#10221c", "background-dark": "#10221c",
"pearlescent": "#f0f7f5", "pearlescent": "#f0f7f5",
"silver-accent": "#e2e8f0", "silver-accent": "#e2e8f0",
"about-us": "#ff6b00"
}, },
fontFamily: { fontFamily: {
"display": ["Space Grotesk", "sans-serif"], "display": ["Space Grotesk", "sans-serif"],
@ -46,6 +48,17 @@
backgroundImage: { backgroundImage: {
'liquid-gradient': 'linear-gradient(135deg, #f8fcfa 0%, #e8f5f1 50%, #dcfce7 100%)', 'liquid-gradient': 'linear-gradient(135deg, #f8fcfa 0%, #e8f5f1 50%, #dcfce7 100%)',
'glass-gradient': 'linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.3) 100%)', 'glass-gradient': 'linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.3) 100%)',
'aurora': 'linear-gradient(135deg, rgba(19,236,164,0.1) 0%, rgba(13,166,112,0.05) 50%, rgba(248,252,250,0) 100%)',
'mesh': 'radial-gradient(at 40% 20%, rgba(19,236,164,0.08) 0px, transparent 50%), radial-gradient(at 80% 0%, rgba(16,34,28,0.05) 0px, transparent 50%), radial-gradient(at 0% 50%, rgba(19,236,164,0.05) 0px, transparent 50%)',
},
boxShadow: {
// 将光效统一映射为 primary 颜色 (13eca4 的 RGBA)
'glow': '0 0 20px rgba(19, 236, 164, 0.4)',
'glow-lg': '0 10px 30px rgba(19, 236, 164, 0.4)',
'bento': '0 20px 40px -15px rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.02)',
'bento-hover': '0 30px 60px -20px rgba(19,236,164,0.15), 0 0 0 1px rgba(19,236,164,0.3)',
'bento-dark': '0 30px 60px -15px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1)',
}, },
keyframes: { keyframes: {
fadeIn: { fadeIn: {
@ -70,6 +83,29 @@
'0%': { boxShadow: '0 0 0px rgba(19,236,164,0)' }, '0%': { boxShadow: '0 0 0px rgba(19,236,164,0)' },
'50%': { boxShadow: '0 0 50px rgba(19,236,164,0.4)', transform: 'scale(1.02)' }, '50%': { boxShadow: '0 0 50px rgba(19,236,164,0.4)', transform: 'scale(1.02)' },
'100%': { boxShadow: '0 0 0px rgba(19,236,164,0)' }, '100%': { boxShadow: '0 0 0px rgba(19,236,164,0)' },
},
// 高级交互动画
pulseGlow: {
'0%': { textShadow: '0 0 10px rgba(19, 236, 164, 0.4)' },
'100%': { textShadow: '0 0 30px #ff6b00' }
},
sweep: { '100%': { left: '200%' } },
cardFlip: {
'0%': { opacity: '0', transform: 'rotateY(-90deg) translateZ(50px)' },
'100%': { opacity: '1', transform: 'rotateY(0deg) translateZ(0)' }
},
floatY: {
'0%, 100%': { transform: 'translateY(0)' },
'50%': { transform: 'translateY(-15px)' }
},
textShimmer: {
'0%': { backgroundPosition: '0% 50%' },
'100%': { backgroundPosition: '100% 50%' },
},
blobSpin: {
'0%': { transform: 'rotate(0deg) scale(1)' },
'50%': { transform: 'rotate(180deg) scale(1.1)' },
'100%': { transform: 'rotate(360deg) scale(1)' },
} }
}, },
animation: { animation: {
@ -77,12 +113,107 @@
'scan-slow': 'scan 6s linear infinite', 'scan-slow': 'scan 6s linear infinite',
'spin-slow': 'rotateGlobe 60s linear infinite', 'spin-slow': 'rotateGlobe 60s linear infinite',
'dash-flow': 'dash 3s linear infinite', 'dash-flow': 'dash 3s linear infinite',
'globe-select': 'globePulse 0.8s ease-out' 'globe-select': 'globePulse 0.8s ease-out',
'pulse-glow': 'pulseGlow 2s infinite alternate',
'sweep': 'sweep 3s infinite',
'flip-in': 'cardFlip 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards',
'float-1': 'floatY 3s ease-in-out infinite',
'float-2': 'floatY 3s ease-in-out infinite 1s',
'float-3': 'floatY 3s ease-in-out infinite 2s',
'text-shimmer': 'textShimmer 3s ease-out infinite alternate',
'blob-spin': 'blobSpin 20s infinite cubic-bezier(0.4, 0, 0.2, 1)',
} }
}, },
}, },
} }
</script> </script>
<!-- Tailwind 基础样式注入 -->
<style type="text/tailwindcss">
@layer utilities {
/* contact us */
#contact-us .focus-group:hover > div:not(:hover) {
opacity: 0.6;
transform: scale(0.98);
filter: blur(2px);
}
#contact-us .focus-group > div {
transition: opacity 0.5s ease, transform 0.5s ease, filter 0.5s ease;
}
/* about-us */
/* 新增:专门为副标题定制的 3D 荧光挤压动画 */
.text-3d-subtitle {
color: #ff6b00; /* 保持主题色 */
animation: pulse3d 2s infinite alternate;
}
@keyframes pulse3d {
0% {
text-shadow:
/* 左上高光 */
-1px -1px 0px rgba(255, 255, 255, 0.5),
/* 右下厚度 (深翠绿色系) */
1px 1px 0px #ce6c33,
2px 2px 0px #b44914,
3px 3px 0px #75600a,
/* 基础投影 */
4px 4px 10px rgba(0, 0, 0, 0.6),
/* 较弱的呼吸背光 */
0px 0px 10px rgba(224, 114, 12, 0.3);
}
100% {
text-shadow:
-1px -1px 0px rgba(255, 255, 255, 0.7),
1px 1px 0px #cc7e19,
2px 2px 0px #e2d921,
3px 3px 0px #692a05,
5px 5px 15px rgba(0, 0, 0, 0.8),
/* 较强的呼吸背光,模拟能量溢出 */
0px 0px 30px #f2e930,
0px 0px 50px rgba(195, 159, 16, 0.6);
}
}
.text-3d {
text-shadow:
0 1px 0 #e2e8f0, /* 亮银色顶边 */
0 2px 0 #cbd5e1,
0 3px 0 #94a3b8,
0 4px 0 #64748b, /* 逐渐变暗模拟背光面 */
0 5px 0 #475569,
0 6px 0 #334155,
0 8px 10px rgba(0, 0, 0, 0.4), /* 近处接触阴影 */
0 15px 20px rgba(0, 0, 0, 0.3), /* 中距离扩散阴影 */
0 25px 40px rgba(0, 0, 0, 0.8); /* 远距离环境阴影 */
}
.text-3d-ultra {
color: #ffffff;
/* 1. 顶部左侧的亮色高光切割边 */
text-shadow:
-1px -1px 1px rgba(255, 255, 255, 0.3),
/* 2. 右下角 45度 斜向挤压厚度 (融入您的深墨绿环境色) */
1px 1px 0px #0d1e18,
2px 2px 0px #0a1813,
3px 3px 0px #08130e,
4px 4px 0px #060e0a,
5px 5px 0px #040906,
6px 6px 0px #020403,
7px 7px 0px #000000,
/* 3. 接触面的死黑投影 */
8px 8px 15px rgba(0, 0, 0, 0.8),
/* 4. 远距离大范围柔和投影 */
15px 15px 30px rgba(0, 0, 0, 0.6),
/* 5. 核心点睛之笔:在阴影反方向及底部映射出 #13eca4 (Primary) 的环境光晕 */
-5px -5px 30px rgba(19, 236, 164, 0.1),
10px 10px 40px rgba(19, 236, 164, 0.25);
}
/* Tab 状态管控:选中时变为 primary 背景与深色字体 */
#tech-landing-wrapper .tab-content { @apply hidden; }
#tech-landing-wrapper .tab-content.active { @apply grid; }
}
</style>
</head> </head>
<body <?php body_class(); ?>> <body <?php body_class(); ?>>
<nav class="main-nav"> <nav class="main-nav">

@ -1703,7 +1703,7 @@ function nenghui_products_list_shortcode($atts) {
$atts = shortcode_atts(array( $atts = shortcode_atts(array(
'id' => 'nenghui-products-list-shortcode', 'id' => 'nenghui-products-list-shortcode',
'class' => '', 'class' => '',
'per_page' => '3', 'per_page' => '20',
'category' => '', 'category' => '',
'order' => 'date', 'order' => 'date',
'orderby' => 'DESC', 'orderby' => 'DESC',

@ -89,8 +89,8 @@
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
font-weight: bold; font-weight: bold;
color: #333; /* color: #333; */
margin-bottom: 1rem; /* margin-bottom: 1rem; */
transition: all 0.3s ease; transition: all 0.3s ease;
} }
h2{ h2{

Loading…
Cancel
Save