WordPress程序修改集锦

1.修改代码高亮的图标

  • 文件位置:wp-content/themes/argon/argontheme.js
  • 代码位置2476行:
 <i class="fa fa-copy"></i>

2.全屏背景

  • 相关文件:index/wp-content/themes/argon/header.php(405)和index/wp-content/themes/argon/style.css(4714)
  • 注释代码:
 <?php /* echo get_option('argon_banner_background_color_type') == '' ? 'shape-primary' : get_option('argon_banner_background_color_type'); */ ?>
/* html.darkmode .banner {
background-color: var(--color-darkmode-banner);
} */

3.修改Argon主题中右侧边栏评价列表对齐

  • 修改文件:index/wp-content/themes/argon/style.css(5240)
 /*自定义样式*/
.wp-block-latest-comments{ padding-inline-start: 0px!important;}

4.修改Argon主题中右侧边栏搜索框

  • 修改文件:index/wp-content/themes/argon/style.css(5240)
.wp-block-search__input{
border-radius: 4px;
border: 1px solid #adb5bd;
}
.wp-block-search__button{border-radius: 3px;}

5.在文章中添加返回按钮

  • 修改文件:index/wp-content/themes/argon/template-parts/share.php
  • 添加代码:
<a target="_blank" class="no-pjax icon-copy-link" id="share_copy_back" tooltip="<?php _e('返回', 'argon'); ?>">
   <button class="btn btn-icon btn-default">
      <span class="btn-inner--icon"><i class="fa fa-reply"></i></span>
   </button>
</a>
……
<button id="back_button" class="btn btn-icon btn-primary" tooltip="返回上一页">
<span class="btn-inner--icon"><i class="fa fa-reply"></i></span>
</button>
<script type="text/javascript">
// 添加点击事件监听器
document.getElementById('back_button').onclick = function() {
window.history.back(); // 返回上一页
};
</script>
  • 添加css样式
/*文章下面的返回按钮*/
#back_button {
position: absolute;
right: 60px;
top: 0;
opacity: 1;
}
#share_container.opened #back_button {
top: -50px;
opacity: 0;
pointer-events: none;
}
#back_button:before {
pointer-events: none;
position: absolute;
top: -50px;
right: 0px;
line-height: 25px;
width: max-content;
width: -moz-max-content;
text-align: center;
font-weight: normal;
color: #fff;
background: #32325d;
padding: 3px 10px;
font-size: 14px;
border-radius: 3px;
z-index: 3;
transition: all 0.3s ease;
transform: translateY(5px);
opacity: 0;
}
#back_button:hover:before {
transform: translateY(0);
opacity: 0.7;
}
#back_button:before {
content: attr(tooltip);
top: -40px;
height: max-content;
height: -moz-max-content;
text-transform: none;
}
  • 添加隐藏分享按钮的js:
$("#share_copy_back")[0].onclick = function() {
$("#share_container").removeClass("opened");
};

6.把边栏悬浮菜单的向左更换为返回

  • 修改文件:index/wp-content/themes/argon/header.php()
<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'); ?>">
<span class="btn-inner--icon fabtn-show-on-right"><i class="fa fa-caret-left"></i></span>
<span class="btn-inner--icon fabtn-show-on-left"><i class="fa fa-caret-right"></i></span>
</button>

改为:

<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'); ?>">
<span class="btn-inner--icon fabtn-show-on-right"><i class="fa fa-reply"></i></span>
<span class="btn-inner--icon fabtn-show-on-left"><i class="fa fa-caret-right"></i></span>
</button>
  • 修改文件:index/wp-content/themes/argon/argontheme.js(566)
/*
$toggleSidesBtn.on("click" , function(){
$fabtns.addClass("fabtns-unloaded");
setTimeout(function(){
$fabtns.toggleClass("fabtns-float-left");
if ($fabtns.hasClass("fabtns-float-left")){
localStorage['Argon_fabs_Floating_Status'] = "left";
}else{
localStorage['Argon_fabs_Floating_Status'] = "right";
}
$fabtns.removeClass("fabtns-unloaded");
} , 300);
});
*/
$toggleSidesBtn.on("click" , function(){
window.history.back(); // 返回上一页
});

7.添加博客网龄

  • 修改文件:index/wp-content/themes/argon/argontheme.js
  • 添加代码:
 
function calculateTime() {
	// 设置博客上线日期
	var launchDate = new Date("2017-09-19");

	// 获取当前日期和时间
	var now = new Date();

	// 计算时间差(以毫秒为单位)
	var timeDiff = now - launchDate;

	// 计算年数
	var yearsRunning = now.getFullYear() - launchDate.getFullYear();

	// 计算天数(考虑年份的影响)
	var daysRunning = Math.floor(timeDiff / (1000 * 60 * 60 * 24)) % 365;

	// 计算小时数
	var hoursRunning = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));

	// 计算分钟数
	var minutesRunning = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));

	// 计算秒数
	var secondsRunning = Math.floor((timeDiff % (1000 * 60)) / 1000);

	// 显示结果
	document.getElementById("time").innerHTML = "老丁博客的网龄: " + yearsRunning + " 年 " + daysRunning + " 天 " + hoursRunning + " 时 " + minutesRunning + " 分 " + secondsRunning + " 秒";
};

// 页面加载时运行
window.onload = function() {
	calculateTime();
	// 每秒自动更新一次
	setInterval(calculateTime, 1000); // 1000 毫秒 = 1秒
};
  • 修改文件:index/wp-content/themes/argon/footer.php(5)
  • 添加代码:
<div><span id="time"></span></div>

8.增加农历和节气

  • 修改文件:index/wp-content/themes/argon/functions.php
  • 增加代码:农历代码
  • 修改文件:index/wp-content/themes/argon/header.php(421)
  • 修改代码

 

<div id="banner_container" class="banner-container container text-center">
<?php if ($enable_banner_title_typing_effect != "true"){?>
<div class="banner-title text-white" style="text-align: right;"><span class="banner-title-inner"><!--<?php echo apply_filters('argon_banner_title_html', $banner_title); ?>--><?php echo get_lunar_date(); ?></span>
<!--<?php echo get_option('argon_banner_subtitle') == '' ? '' : '<span class="banner-subtitle d-block">' . get_option('argon_banner_subtitle') . '</span>'; ?>-->
<span class="banner-subtitle d-block"><?php echo get_jieqi_info(); ?></span>
</div>
<?php } else {?>
<div class="banner-title text-white" data-interval="<?php echo get_option('argon_banner_typing_effect_interval', 100); ?>"><span data-text="<?php echo $banner_title; ?>" class="banner-title-inner">&nbsp;</span>
<?php echo get_option('argon_banner_subtitle') == '' ? '' : '<span data-text="' . get_option('argon_banner_subtitle') . '" class="banner-subtitle d-block">&nbsp;</span>'; ?><?php echo get_jieqi_info(); ?></div>
<?php }?>
</div>

9.取消文章页页头背景

  • 修改文件:index/wp-content/themes/argon/template-parts/content-single.php
  • 修改代码:
('argon_show_thumbnail_in_banner_in_content_page') != 'true')

修改为:

 ('argon_show_thumbnail_in_banner_in_content_page') == 'true')

注释代码:

<?php
/*
if (argon_has_post_thumbnail() && get_option('argon_show_thumbnail_in_banner_in_content_page') != 'true'){
$thumbnail_url = argon_get_post_thumbnail();
echo "<img class='post-thumbnail' src='" . $thumbnail_url . "'></img>";
echo "<div class='post-header-text-container'>";
}
if (argon_has_post_thumbnail() && get_option('argon_show_thumbnail_in_banner_in_content_page') == 'true'){
$thumbnail_url = argon_get_post_thumbnail();
echo "
<style>
body section.banner {
background-image: url(" . $thumbnail_url . ") !important;
}
</style>";
}
*/
?>

 

评论

  1. 博主
    Windows Chrome 129.0.0.0
    2 月前
    2024-9-30 15:51:38

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇