mirror of
https://github.com/yunluo/gdk.git
synced 2024-05-04 23:43:23 +02:00
优化网站地图代码,优化缓存
导航页面换了JQ
This commit is contained in:
parent
d02abdb658
commit
8b3271b9e7
|
@ -389,3 +389,30 @@ if (gdk_option('gdk_weauth_oauth') && gdk_option('gdk_weauth_force')) {
|
|||
add_filter('login_url', 'force_weauth_login_url', 10, 3);
|
||||
add_filter('register_url', 'change_my_register_url');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 清除文章相关的缓存
|
||||
*/
|
||||
function gdk_clear_post_cache()
|
||||
{
|
||||
delete_transient('gdk-sitemap');
|
||||
delete_transient('gdk-sitemap-html');
|
||||
}
|
||||
add_action('save_post', 'gdk_clear_post_cache' );
|
||||
add_action('deleted_post', 'gdk_clear_post_cache' );
|
||||
add_action('publish_post', 'gdk_clear_post_cache');
|
||||
add_action('publish_page', 'gdk_clear_post_cache');
|
||||
add_action('save_post', 'gdk_clear_post_cache');
|
||||
|
||||
/**
|
||||
* 清除链接缓存
|
||||
*/
|
||||
function gdk_clear_link_cache()
|
||||
{
|
||||
delete_transient('gdk-daohang-html');
|
||||
}
|
||||
add_action('edit_link', 'gdk_clear_link_cache' );
|
||||
add_action('add_link', 'gdk_clear_link_cache' );
|
||||
add_action('set_object_terms', 'gdk_clear_link_cache');
|
|
@ -135,7 +135,7 @@ $linkcats1 = get_terms('link_category', 'orderby=count&hide_empty=1&exclude='. g
|
|||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/zepto@1.2.0/dist/zepto.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
/*
|
||||
|
|
|
@ -68,11 +68,3 @@ function gdk_create_sitemap()
|
|||
$sitemap .= '</urlset>';
|
||||
return $sitemap;
|
||||
}
|
||||
|
||||
function gdk_clear_sitemap_cache()
|
||||
{
|
||||
delete_transient('gdk-sitemap');
|
||||
}
|
||||
add_action('publish_post', 'gdk_clear_sitemap_cache');
|
||||
add_action('publish_page', 'gdk_clear_sitemap_cache');
|
||||
add_action('save_post', 'gdk_clear_sitemap_cache');
|
||||
|
|
|
@ -24,9 +24,8 @@ function gdk_sitemap_html_api_handlers($template)
|
|||
$sitemap = gdk_create_html_sitemap();
|
||||
set_transient('gdk-sitemap-html', $sitemap);
|
||||
}
|
||||
|
||||
$sitemap;
|
||||
return;
|
||||
|
||||
return $sitemap;
|
||||
}
|
||||
|
||||
return $template;
|
||||
|
@ -89,24 +88,11 @@ $myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC');
|
|||
<br />
|
||||
<div style="text-align: center; font-size: 11px">
|
||||
Latest Update:
|
||||
<?php
|
||||
global $wpdb;
|
||||
$last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");
|
||||
$last = date('Y-m-d G:i:s', strtotime($last[0]->MAX_m));
|
||||
echo $last;
|
||||
?>
|
||||
<?php echo date( 'Y年n月j日 H:i:s', strtotime( get_lastpostmodified('blog'))); ?>
|
||||
<br />
|
||||
<br />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
|
||||
function gdk_clear_sitemap_html_cache()
|
||||
{
|
||||
delete_transient('gdk-sitemap-html');
|
||||
}
|
||||
add_action('publish_post', 'gdk_clear_sitemap_html_cache');
|
||||
add_action('publish_page', 'gdk_clear_sitemap_html_cache');
|
||||
add_action('save_post', 'gdk_clear_sitemap_html_cache');
|
||||
}
|
Loading…
Reference in a new issue