admin管理员组文章数量:1391999
I am trying to automatically clear the blog's cache when it is Archived (or Deactivated is fine) in a Multisite install. This is useful for anyone using a caching program like WP Super Cache as an archived or deactivated the blog will still show until the cache is cleared.
I have tried:
add_action( 'archive_blog', 'wp_clear_cache_custom' );
add_action( 'unarchive_blog', 'wp_clear_cache_custom');
And:
add_action( 'archive_blog', 'wp_clear_cache_custom_archive', 10, 1 );
add_action( 'unarchive_blog', 'wp_clear_cache_custom_archive', 10, 1 );
With the function:
function wp_clear_cache_custom() {
global $wpdb;
wp_cache_clear_cache( $wpdb->blogid );
}
This same setup works fine for clearing the cache when a theme is changed, etc. but not for blog status changes.
Any help is much appreciated.
This page seemed to be close but no dice: Perform action on WPMU blog deletion
I am trying to automatically clear the blog's cache when it is Archived (or Deactivated is fine) in a Multisite install. This is useful for anyone using a caching program like WP Super Cache as an archived or deactivated the blog will still show until the cache is cleared.
I have tried:
add_action( 'archive_blog', 'wp_clear_cache_custom' );
add_action( 'unarchive_blog', 'wp_clear_cache_custom');
And:
add_action( 'archive_blog', 'wp_clear_cache_custom_archive', 10, 1 );
add_action( 'unarchive_blog', 'wp_clear_cache_custom_archive', 10, 1 );
With the function:
function wp_clear_cache_custom() {
global $wpdb;
wp_cache_clear_cache( $wpdb->blogid );
}
This same setup works fine for clearing the cache when a theme is changed, etc. but not for blog status changes.
Any help is much appreciated.
This page seemed to be close but no dice: Perform action on WPMU blog deletion
Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Jan 3, 2014 at 21:15 Neverending WoesNeverending Woes 111 bronze badge1 Answer
Reset to default 0According to wpseek, there exist hooks for unarchive_blog
, archive_blog
, and deactivate_blog
. You can examine them in the source on WordPress's Trac site:
archive_blog
unarchive_blog
deactivate_blog
All of them use the $blog_id
parameter. Try changing your function to reflect that:
add_action( 'archive_blog', 'wp_clear_cache_custom' );
function wp_clear_cache_custom( $blog_id ) {
wp_cache_clear_cache( $blog_id );
}
本文标签: multisiteWPMU Hook for archive or deactivate blog
版权声明:本文标题:multisite - WPMU Hook for archive or deactivate blog? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744622701a2616123.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论