refactor: 规范化 PHP 模板文件

- header.php: 修复箭头操作符空格, 移除多余空行 (1520 -> 1481 行)
- footer.php: 修复箭头操作符空格, 移除多余空行 (177 -> 168 行)
- sidebar.php: 修复箭头操作符空格, 移除多余空行 (1311 -> 1288 行)
- single.php: 修复箭头操作符空格, 移除多余空行 (214 -> 196 行)
- comments.php: 修复箭头操作符空格
- search.php: 修复箭头操作符空格
This commit is contained in:
2026-01-16 11:26:33 +08:00
parent 233edd2441
commit 733722e7d4
6 changed files with 66 additions and 157 deletions

View File

@@ -383,16 +383,14 @@ function resetGeetestCaptcha() {
<?php <?php
$captcha_type = get_option('argon_captcha_type', 'math'); $captcha_type = get_option('argon_captcha_type', 'math');
if ($captcha_type === 'geetest') { ?> if ($captcha_type === 'geetest') { ?>
<!-- Geetest 验证码容器 --> <!-- Geetest 验证码容器 --><div id="geetest-captcha" class="mb-4"></div>
<div id="geetest-captcha" class="mb-4"></div>
<input type="hidden" id="geetest_lot_number" name="lot_number" value=""> <input type="hidden" id="geetest_lot_number" name="lot_number" value="">
<input type="hidden" id="geetest_captcha_output" name="captcha_output" value=""> <input type="hidden" id="geetest_captcha_output" name="captcha_output" value="">
<input type="hidden" id="geetest_pass_token" name="pass_token" value=""> <input type="hidden" id="geetest_pass_token" name="pass_token" value="">
<input type="hidden" id="geetest_gen_time" name="gen_time" value=""> <input type="hidden" id="geetest_gen_time" name="gen_time" value="">
<input type="hidden" id="argon_comment_nonce" value="<?php echo wp_create_nonce('argon_comment'); ?>"> <input type="hidden" id="argon_comment_nonce" value="<?php echo wp_create_nonce('argon_comment'); ?>">
<?php } else { ?> <?php } else { ?>
<!-- 原有的数学验证码 --> <!-- 原有的数学验证码 --><div class="input-group input-group-alternative mb-4 post-comment-captcha-container" captcha="<?php echo get_comment_captcha(get_comment_captcha_seed());?>">
<div class="input-group input-group-alternative mb-4 post-comment-captcha-container" captcha="<?php echo get_comment_captcha(get_comment_captcha_seed());?>">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-key"></i></span> <span class="input-group-text"><i class="fa fa-key"></i></span>
</div> </div>

View File

@@ -29,8 +29,7 @@
</div> </div>
<!-- 加载主题核心 JS --> <!-- 加载主题核心 JS --><?php $assets_version = function_exists('argon_get_assets_version') ? argon_get_assets_version() : $GLOBALS['theme_version']; ?>
<?php $assets_version = function_exists('argon_get_assets_version') ? argon_get_assets_version() : $GLOBALS['theme_version']; ?>
<script src="<?php echo $GLOBALS['assets_path']; ?>/argontheme.js?v=<?php echo $assets_version; ?>"></script> <script src="<?php echo $GLOBALS['assets_path']; ?>/argontheme.js?v=<?php echo $assets_version; ?>"></script>
<?php if (get_option('argon_math_render') == 'mathjax3') { /*Mathjax V3*/?> <?php if (get_option('argon_math_render') == 'mathjax3') { /*Mathjax V3*/?>
@@ -149,16 +148,12 @@
<?php }?> <?php }?>
<?php if (get_option('argon_enable_code_highlight') == 'true') { /*Highlight.js*/?> <?php if (get_option('argon_enable_code_highlight') == 'true') { /*Highlight.js*/?>
<link rel="stylesheet" href="<?php echo $GLOBALS['assets_path']; ?>/assets/vendor/highlight/styles/<?php echo get_option('argon_code_theme') == '' ? 'vs2015' : get_option('argon_code_theme'); ?>.css"> <link rel="stylesheet" href="<?php echo $GLOBALS['assets_path']; ?>/assets/vendor/highlight/styles/<?php echo get_option('argon_code_theme') == '' ? 'vs2015' : get_option('argon_code_theme'); ?>.css">
<?php }?> <?php }?>
</div> </div>
</div> </div>
@@ -167,10 +162,6 @@
</body> </body>
<?php echo get_option('argon_custom_html_foot'); ?> <?php echo get_option('argon_custom_html_foot'); ?>
</html> </html>

View File

@@ -196,8 +196,6 @@
<?php } ?> <?php } ?>
<?php <?php
$seo_keywords = get_seo_keywords(); $seo_keywords = get_seo_keywords();
@@ -208,8 +206,6 @@
<?php } ?> <?php } ?>
<?php <?php
if (is_single() || is_page()){ if (is_single() || is_page()){
@@ -232,8 +228,6 @@
<?php } ?> <?php } ?>
<meta name="theme-color" content="<?php echo $themecolor; ?>"> <meta name="theme-color" content="<?php echo $themecolor; ?>">
<meta name="theme-color-rgb" content="<?php echo hex2str($themecolor); ?>"> <meta name="theme-color-rgb" content="<?php echo hex2str($themecolor); ?>">
@@ -242,20 +236,12 @@
<meta name="argon-enable-custom-theme-color" content="<?php echo (get_option('argon_show_customize_theme_color_picker') != 'false' ? 'true' : 'false'); ?>"> <meta name="argon-enable-custom-theme-color" content="<?php echo (get_option('argon_show_customize_theme_color_picker') != 'false' ? 'true' : 'false'); ?>">
<meta name="theme-card-radius" content="<?php echo $cardradius; ?>"> <meta name="theme-card-radius" content="<?php echo $cardradius; ?>">
<meta name="theme-card-radius-origin" content="<?php echo $cardradius_origin; ?>"> <meta name="theme-card-radius-origin" content="<?php echo $cardradius_origin; ?>">
<meta name="theme-version" content="<?php echo $GLOBALS['theme_version']; ?>"> <meta name="theme-version" content="<?php echo $GLOBALS['theme_version']; ?>">
<link rel="profile" href="http://gmpg.org/xfn/11"> <link rel="profile" href="http://gmpg.org/xfn/11">
<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?> <?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
@@ -293,8 +279,7 @@
<?php wp_head(); ?> <?php wp_head(); ?>
<?php if (function_exists('argon_is_force_refresh_enabled') && argon_is_force_refresh_enabled()): ?> <?php if (function_exists('argon_is_force_refresh_enabled') && argon_is_force_refresh_enabled()): ?>
<!-- 强制刷新缓存 - 清除浏览器和 Service Worker 缓存 --> <!-- 强制刷新缓存 - 清除浏览器和 Service Worker 缓存 --><script>
<script>
(function() { (function() {
var forceRefreshKey = 'argon_force_refresh_version'; var forceRefreshKey = 'argon_force_refresh_version';
var currentVersion = '<?php echo get_option('argon_force_refresh_enabled_time', 0); ?>'; var currentVersion = '<?php echo get_option('argon_force_refresh_enabled_time', 0); ?>';
@@ -337,8 +322,7 @@
</script> </script>
<?php endif; ?> <?php endif; ?>
<!-- 移动端资源加载修复 - 确保 CSS 完全应用 --> <!-- 移动端资源加载修复 - 确保 CSS 完全应用 --><script>
<script>
(function() { (function() {
// 检测移动端并强制重新计算样式 // 检测移动端并强制重新计算样式
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
@@ -370,8 +354,7 @@
window.argonUserRole = '<?php echo current_user_can('administrator') ? 'administrator' : (is_user_logged_in() ? 'user' : 'guest'); ?>'; window.argonUserRole = '<?php echo current_user_can('administrator') ? 'administrator' : (is_user_logged_in() ? 'user' : 'guest'); ?>';
</script> </script>
<!-- Argon 修复补丁 - 必须在 wp_head() 之后立即执行 --> <!-- Argon 修复补丁 - 必须在 wp_head() 之后立即执行 --><script src="<?php echo get_template_directory_uri(); ?>/assets/js/argon.min.js?ver=<?php echo $assets_version; ?>"></script>
<script src="<?php echo get_template_directory_uri(); ?>/assets/js/argon.min.js?ver=<?php echo $assets_version; ?>"></script>
<?php $GLOBALS['wp_path'] = get_option('argon_wp_path') == '' ? '/' : get_option('argon_wp_path'); ?> <?php $GLOBALS['wp_path'] = get_option('argon_wp_path') == '' ? '/' : get_option('argon_wp_path'); ?>
@@ -565,8 +548,6 @@
} }
function toggleAmoledDarkMode(){ function toggleAmoledDarkMode(){
document.documentElement.classList.toggle("amoled-dark"); document.documentElement.classList.toggle("amoled-dark");
@@ -605,8 +586,6 @@
</script> </script>
<?php if (get_option('argon_enable_smoothscroll_type') == '2') { /*平滑滚动*/?> <?php if (get_option('argon_enable_smoothscroll_type') == '2') { /*平滑滚动*/?>
<script src="<?php echo $GLOBALS['assets_path']; ?>/assets/vendor/smoothscroll/smoothscroll2.js"></script> <script src="<?php echo $GLOBALS['assets_path']; ?>/assets/vendor/smoothscroll/smoothscroll2.js"></script>
@@ -627,12 +606,8 @@
</head> </head>
<?php echo get_option('argon_custom_html_head'); ?> <?php echo get_option('argon_custom_html_head'); ?>
<style id="themecolor_css"> <style id="themecolor_css">
<?php <?php
@@ -770,8 +745,6 @@ if ($animation_style == 'apple') {
<?php endif; ?> <?php endif; ?>
</style> </style>
<body <?php body_class(); ?>> <body <?php body_class(); ?>>
<?php /*wp_body_open();*/ ?> <?php /*wp_body_open();*/ ?>
@@ -1064,9 +1037,7 @@ if ($animation_style == 'apple') {
</div> </div>
<!--Banner--> <!--Banner--><section id="banner" class="banner section section-lg section-shaped">
<section id="banner" class="banner section section-lg section-shaped">
<div class="shape <?php echo get_option('argon_banner_background_hide_shapes') == 'true' ? '' : 'shape-style-1' ?> <?php echo get_option('argon_banner_background_color_type') == '' ? 'shape-primary' : get_option('argon_banner_background_color_type'); ?>"> <div class="shape <?php echo get_option('argon_banner_background_hide_shapes') == 'true' ? '' : 'shape-style-1' ?> <?php echo get_option('argon_banner_background_color_type') == '' ? 'shape-primary' : get_option('argon_banner_background_color_type'); ?>">
@@ -1090,8 +1061,6 @@ if ($animation_style == 'apple') {
</div> </div>
<?php <?php
$banner_title = get_option('argon_banner_title') == '' ? get_bloginfo('name') : get_option('argon_banner_title'); $banner_title = get_option('argon_banner_title') == '' ? get_bloginfo('name') : get_option('argon_banner_title');
@@ -1144,8 +1113,6 @@ if ($animation_style == 'apple') {
</section> </section>
<?php if (apply_filters('argon_page_background_url', get_option('argon_page_background_url')) != '') { ?> <?php if (apply_filters('argon_page_background_url', get_option('argon_page_background_url')) != '') { ?>
<style> <style>
@@ -1286,8 +1253,7 @@ if ($animation_style == 'apple') {
<?php } ?> <?php } ?>
<!-- 毛玻璃效果 - 独立于背景图片设置(无背景图时也生效) --> <!-- 毛玻璃效果 - 独立于背景图片设置(无背景图时也生效) --><?php
<?php
$card_blur_standalone = intval(get_option('argon_card_blur', '20')); $card_blur_standalone = intval(get_option('argon_card_blur', '20'));
$card_saturate_standalone = intval(get_option('argon_card_saturate', '180')); $card_saturate_standalone = intval(get_option('argon_card_saturate', '180'));
$post_bg_opacity_standalone = get_option('argon_post_background_opacity', '0.7'); $post_bg_opacity_standalone = get_option('argon_post_background_opacity', '0.7');
@@ -1328,7 +1294,6 @@ if (apply_filters('argon_page_background_url', get_option('argon_page_background
</style> </style>
<?php endif; ?> <?php endif; ?>
<?php if (get_option('argon_show_toolbar_mask') == 'true') { ?> <?php if (get_option('argon_show_toolbar_mask') == 'true') { ?>
<style> <style>
@@ -1365,8 +1330,6 @@ if (apply_filters('argon_page_background_url', get_option('argon_page_background
<?php } ?> <?php } ?>
<div id="float_action_buttons" class="float-action-buttons fabtns-unloaded"> <div id="float_action_buttons" class="float-action-buttons fabtns-unloaded">
<button id="fabtn_toggle_sides" class="btn btn-icon btn-neutral fabtn shadow-sm" type="button" aria-hidden="true" tooltip-move-to-left="<?php _e('移至左侧', 'argon'); ?>" tooltip-move-to-right="<?php _e('移至右侧', 'argon'); ?>"> <button id="fabtn_toggle_sides" class="btn btn-icon btn-neutral fabtn shadow-sm" type="button" aria-hidden="true" tooltip-move-to-left="<?php _e('移至左侧', 'argon'); ?>" tooltip-move-to-right="<?php _e('移至右侧', 'argon'); ?>">
@@ -1513,7 +1476,5 @@ if (apply_filters('argon_page_background_url', get_option('argon_page_background
</div> </div>
<div id="content" class="site-content"> <div id="content" class="site-content">

View File

@@ -15,10 +15,8 @@ $author_desc = get_option('argon_sidebar_author_description');
<aside id="leftbar" class="<?php echo $leftbar_class; ?>" role="complementary"> <aside id="leftbar" class="<?php echo $leftbar_class; ?>" role="complementary">
<!-- 移动端侧边栏 - 重新设计的布局 --> <!-- 移动端侧边栏 - 重新设计的布局 --><div id="leftbar_mobile_nav" class="leftbar-mobile-nav">
<div id="leftbar_mobile_nav" class="leftbar-mobile-nav"> <!-- 顶部用户信息区 --><div class="leftbar-mobile-profile">
<!-- 顶部用户信息区 -->
<div class="leftbar-mobile-profile">
<div class="leftbar-mobile-close" id="leftbar_close_btn"> <div class="leftbar-mobile-close" id="leftbar_close_btn">
<i class="fa fa-times"></i> <i class="fa fa-times"></i>
</div> </div>
@@ -48,8 +46,7 @@ $author_desc = get_option('argon_sidebar_author_description');
<div class="leftbar-mobile-user-desc"><?php echo esc_html($author_desc); ?></div> <div class="leftbar-mobile-user-desc"><?php echo esc_html($author_desc); ?></div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<!-- 统计数据 --> <!-- 统计数据 --><div class="leftbar-mobile-stats">
<div class="leftbar-mobile-stats">
<div class="leftbar-mobile-stat"> <div class="leftbar-mobile-stat">
<span class="stat-num"><?php echo wp_count_posts()->publish; ?></span> <span class="stat-num"><?php echo wp_count_posts()->publish; ?></span>
<span class="stat-label"><?php _e('文章', 'argon'); ?></span> <span class="stat-label"><?php _e('文章', 'argon'); ?></span>
@@ -65,16 +62,14 @@ $author_desc = get_option('argon_sidebar_author_description');
</div> </div>
</div> </div>
<!-- 搜索框 --> <!-- 搜索框 --><div class="leftbar-mobile-search">
<div class="leftbar-mobile-search">
<div class="leftbar-mobile-search-inner"> <div class="leftbar-mobile-search-inner">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
<input type="text" id="leftbar_mobile_search_input" placeholder="<?php _e('搜索...', 'argon'); ?>" autocomplete="off"> <input type="text" id="leftbar_mobile_search_input" placeholder="<?php _e('搜索...', 'argon'); ?>" autocomplete="off">
</div> </div>
</div> </div>
<!-- 导航菜单 --> <!-- 导航菜单 --><?php if ( has_nav_menu('toolbar_menu') ) : ?>
<?php if ( has_nav_menu('toolbar_menu') ) : ?>
<div class="leftbar-mobile-menu-section"> <div class="leftbar-mobile-menu-section">
<div class="leftbar-mobile-section-title"><?php _e('导航', 'argon'); ?></div> <div class="leftbar-mobile-section-title"><?php _e('导航', 'argon'); ?></div>
<ul class="leftbar-mobile-menu"> <ul class="leftbar-mobile-menu">
@@ -117,8 +112,7 @@ $author_desc = get_option('argon_sidebar_author_description');
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- 侧边栏菜单 --> <!-- 侧边栏菜单 --><?php if ( has_nav_menu('leftbar_menu') ) : ?>
<?php if ( has_nav_menu('leftbar_menu') ) : ?>
<div class="leftbar-mobile-menu-section"> <div class="leftbar-mobile-menu-section">
<div class="leftbar-mobile-section-title"><?php _e('更多', 'argon'); ?></div> <div class="leftbar-mobile-section-title"><?php _e('更多', 'argon'); ?></div>
<ul class="leftbar-mobile-menu"> <ul class="leftbar-mobile-menu">
@@ -135,8 +129,7 @@ $author_desc = get_option('argon_sidebar_author_description');
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- 文章目录折叠面板 (仅在文章页显示) --> <!-- 文章目录折叠面板 (仅在文章页显示) --><?php if (have_catalog()) : ?>
<?php if (have_catalog()) : ?>
<div class="leftbar-mobile-collapse-section"> <div class="leftbar-mobile-collapse-section">
<div class="leftbar-mobile-collapse-header" id="mobile_catalog_toggle"> <div class="leftbar-mobile-collapse-header" id="mobile_catalog_toggle">
<div class="collapse-header-left"> <div class="collapse-header-left">
@@ -151,8 +144,7 @@ $author_desc = get_option('argon_sidebar_author_description');
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- TODO折叠面板 --> <!-- TODO折叠面板 --><?php if (get_option('argon_show_todo_list', 'true') == 'true') : ?>
<?php if (get_option('argon_show_todo_list', 'true') == 'true') : ?>
<?php <?php
$mobile_todos = argon_get_todo_list(); $mobile_todos = argon_get_todo_list();
$mobile_is_author = current_user_can('publish_posts'); $mobile_is_author = current_user_can('publish_posts');
@@ -259,8 +251,7 @@ $author_desc = get_option('argon_sidebar_author_description');
</script> </script>
<?php endif; ?> <?php endif; ?>
<!-- 顶栏自定义链接 --> <!-- 顶栏自定义链接 --><?php
<?php
$toolbar_links_left = get_option('argon_toolbar_links_left', ''); $toolbar_links_left = get_option('argon_toolbar_links_left', '');
$toolbar_links_right = get_option('argon_toolbar_links_right', ''); $toolbar_links_right = get_option('argon_toolbar_links_right', '');
$has_custom_links = !empty(trim($toolbar_links_left)) || !empty(trim($toolbar_links_right)); $has_custom_links = !empty(trim($toolbar_links_left)) || !empty(trim($toolbar_links_right));
@@ -307,8 +298,7 @@ $author_desc = get_option('argon_sidebar_author_description');
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- 底部操作区 --> <!-- 底部操作区 --><div class="leftbar-mobile-footer">
<div class="leftbar-mobile-footer">
<div class="leftbar-mobile-actions"> <div class="leftbar-mobile-actions">
<button class="leftbar-mobile-action" onclick="toggleDarkmode()"> <button class="leftbar-mobile-action" onclick="toggleDarkmode()">
<i class="fa fa-moon-o"></i> <i class="fa fa-moon-o"></i>
@@ -326,8 +316,7 @@ $author_desc = get_option('argon_sidebar_author_description');
</div> </div>
</div> </div>
<!-- 桌面端原有侧边栏内容 --> <!-- 桌面端原有侧边栏内容 --><div class="leftbar-desktop-content">
<div class="leftbar-desktop-content">
<?php if (get_option('argon_sidebar_announcement') != '') { ?> <?php if (get_option('argon_sidebar_announcement') != '') { ?>
<div id="leftbar_announcement" class="card bg-white shadow-sm border-0"> <div id="leftbar_announcement" class="card bg-white shadow-sm border-0">
@@ -350,8 +339,6 @@ $author_desc = get_option('argon_sidebar_author_description');
<span class="leftbar-banner-title text-white"><?php echo get_option('argon_sidebar_banner_title') == '' ? bloginfo('name') : get_option('argon_sidebar_banner_title'); ?></span> <span class="leftbar-banner-title text-white"><?php echo get_option('argon_sidebar_banner_title') == '' ? bloginfo('name') : get_option('argon_sidebar_banner_title'); ?></span>
<?php <?php
$sidebar_subtitle = get_option('argon_sidebar_banner_subtitle'); $sidebar_subtitle = get_option('argon_sidebar_banner_subtitle');
@@ -370,12 +357,8 @@ $author_desc = get_option('argon_sidebar_author_description');
<?php } /*顶栏标题*/?> <?php } /*顶栏标题*/?>
</div> </div>
<?php <?php
/*侧栏上部菜单*/ /*侧栏上部菜单*/
@@ -661,8 +644,6 @@ $author_desc = get_option('argon_sidebar_author_description');
} }
if ( has_nav_menu('leftbar_author_links') ){ if ( has_nav_menu('leftbar_author_links') ){
echo "<div class='site-author-links'>"; echo "<div class='site-author-links'>";
@@ -719,8 +700,6 @@ $author_desc = get_option('argon_sidebar_author_description');
} }
if ( has_nav_menu('leftbar_friend_links') ){ if ( has_nav_menu('leftbar_friend_links') ){
echo "<div class='site-friend-links'> echo "<div class='site-friend-links'>
@@ -1178,9 +1157,7 @@ $author_desc = get_option('argon_sidebar_author_description');
</script> </script>
<?php endif; ?> <?php endif; ?>
</div><!-- .leftbar-desktop-content --> </div><!-- .leftbar-desktop-content --></aside>
</aside>
<div class="modal fade" id="blog_categories" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true"> <div class="modal fade" id="blog_categories" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">

View File

@@ -1,15 +1,9 @@
<?php get_header(); ?> <?php get_header(); ?>
<div class="page-information-card-container"></div> <div class="page-information-card-container"></div>
<?php get_sidebar(); ?> <?php get_sidebar(); ?>
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main" role="main"> <main id="main" class="site-main" role="main">
@@ -20,12 +14,8 @@
the_post(); the_post();
get_template_part( 'template-parts/content', 'single' ); get_template_part( 'template-parts/content', 'single' );
// 文章操作按钮(分享和评论) // 文章操作按钮(分享和评论)
get_template_part( 'template-parts/post-actions' ); get_template_part( 'template-parts/post-actions' );
@@ -33,8 +23,6 @@
comments_template(); comments_template();
} }
if ( is_singular( 'post' ) ) { if ( is_singular( 'post' ) ) {
if (get_previous_post() || get_next_post()){ if (get_previous_post() || get_next_post()){
@@ -67,8 +55,6 @@
} }
$relatedPosts = get_option('argon_related_post', 'disabled'); $relatedPosts = get_option('argon_related_post', 'disabled');
if ($relatedPosts != "disabled"){ if ($relatedPosts != "disabled"){
@@ -201,13 +187,9 @@
} }
endwhile; endwhile;
?> ?>
<?php get_footer(); ?> <?php get_footer(); ?>