Fix hot reload infinite loop and graceful degradation for Duolingo badge API block

This commit is contained in:
User
2026-03-12 16:05:56 +08:00
parent 3eaef5b06a
commit 0387c7d9e5
3 changed files with 11 additions and 10 deletions

View File

@@ -522,7 +522,7 @@ function argon_frontend_hot_reload_notice() {
<div style="display:flex;align-items:center;margin-bottom:8px;">
<span style="background:var(--themecolor,#5e72e4);color:#fff;padding:2px 8px;border-radius:4px;font-size:12px;margin-right:8px;"><?php _e('热更新', 'argon'); ?></span>
<strong><?php _e('主题已更新', 'argon'); ?></strong>
<span onclick="document.getElementById('argon-hot-reload-frontend-notice').remove();jQuery.post(ajaxurl,{action:'argon_dismiss_update_notice',nonce:'<?php echo wp_create_nonce('argon_dismiss_update_notice'); ?>',index:-1});" style="margin-left:auto;cursor:pointer;opacity:0.5;font-size:18px;">&times;</span>
<span onclick="document.getElementById('argon-hot-reload-frontend-notice').remove();jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>',{action:'argon_dismiss_update_notice',nonce:'<?php echo wp_create_nonce('argon_dismiss_update_notice'); ?>',index:-1});" style="margin-left:auto;cursor:pointer;opacity:0.5;font-size:18px;">&times;</span>
</div>
<p style="margin:0;color:#666;font-size:14px;">
<?php echo sprintf(
@@ -5285,14 +5285,10 @@ function argon_get_duolingo_data() {
'headers' => $headers
));
// 如果返回了诸如 401/403 错误JWT 过期或无效),尝试移除 JWT 重新获取,确保基础连胜可见
if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) !== 200 && !empty($jwt)) {
unset($headers['Authorization']);
$response = wp_remote_get($url, array(
'timeout' => 15,
'headers' => $headers
));
$jwt = ''; // 标记为无效,后续不请求私有好友连胜数据
// 如果返回了诸如 401/403 错误,说明可能遭到了 Cloudflare 拦截或者是 JWT 无效
// 我们直接返回缓存,而不是剥离 JWT 去重试,因为当前服务器 IP 很可能就是被封的
if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) !== 200) {
return $cached !== false ? $cached : false;
}
if (is_wp_error($response)) {