feat: 增加热更新功能
- 新增热更新开关设置(位于高级设置-杂项) - 主题文件更新后自动清理所有缓存(对象缓存、主题更新缓存、transient缓存) - 后台显示更新通知,提示版本变化 - 可选在前台显示更新通知(仅管理员可见) - 提供手动清理缓存按钮 - 保留最近10条更新历史记录
This commit is contained in:
86
settings.php
86
settings.php
@@ -4635,6 +4635,88 @@ window.pjaxLoaded = function(){
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
<th><label><?php _e('热更新', 'argon');?></label></th>
|
||||
|
||||
<td>
|
||||
|
||||
<?php $argon_enable_hot_reload = get_option('argon_enable_hot_reload', 'false'); ?>
|
||||
|
||||
<label>
|
||||
|
||||
<input type="checkbox" name="argon_enable_hot_reload" value="true" <?php if ($argon_enable_hot_reload=='true'){echo 'checked';}?>/>
|
||||
|
||||
<?php _e('启用热更新功能', 'argon');?>
|
||||
|
||||
</label>
|
||||
|
||||
<p class="description"><?php _e('启用后,当主题文件被更新时,将自动清理所有缓存并显示更新通知。', 'argon');?></p>
|
||||
|
||||
|
||||
|
||||
<?php $argon_hot_reload_frontend_notice = get_option('argon_hot_reload_frontend_notice', 'false'); ?>
|
||||
|
||||
<label style="display:block;margin-top:10px;">
|
||||
|
||||
<input type="checkbox" name="argon_hot_reload_frontend_notice" value="true" <?php if ($argon_hot_reload_frontend_notice=='true'){echo 'checked';}?>/>
|
||||
|
||||
<?php _e('在前台显示更新通知(仅管理员可见)', 'argon');?>
|
||||
|
||||
</label>
|
||||
|
||||
|
||||
|
||||
<div style="margin-top:15px;">
|
||||
|
||||
<button type="button" class="button" id="argon_clear_cache_btn"><?php _e('手动清理缓存', 'argon');?></button>
|
||||
|
||||
<span id="argon_clear_cache_result" style="margin-left:10px;color:#46b450;display:none;"><?php _e('缓存已清理', 'argon');?></span>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
$('#argon_clear_cache_btn').on('click', function() {
|
||||
|
||||
var btn = $(this);
|
||||
|
||||
btn.prop('disabled', true).text('<?php _e('清理中...', 'argon');?>');
|
||||
|
||||
$.post(ajaxurl, {
|
||||
|
||||
action: 'argon_clear_cache',
|
||||
|
||||
nonce: '<?php echo wp_create_nonce('argon_clear_cache'); ?>'
|
||||
|
||||
}, function(response) {
|
||||
|
||||
btn.prop('disabled', false).text('<?php _e('手动清理缓存', 'argon');?>');
|
||||
|
||||
if (response.success) {
|
||||
|
||||
$('#argon_clear_cache_result').fadeIn().delay(2000).fadeOut();
|
||||
|
||||
} else {
|
||||
|
||||
alert(response.data || '<?php _e('清理失败', 'argon');?>');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
<th><label><?php _e('页脚附加内容', 'argon');?></label></th>
|
||||
@@ -5322,6 +5404,10 @@ function argon_update_themeoptions(){
|
||||
|
||||
argon_update_option('argon_update_source');
|
||||
|
||||
argon_update_option_checkbox('argon_enable_hot_reload');
|
||||
|
||||
argon_update_option_checkbox('argon_hot_reload_frontend_notice');
|
||||
|
||||
argon_update_option('argon_enable_into_article_animation');
|
||||
|
||||
argon_update_option('argon_disable_pjax_animation');
|
||||
|
||||
Reference in New Issue
Block a user