admin管理员组文章数量:1435859
I'm developing a plugin, and noticed that my custom rewrite rules are lost after WP updates its core.
It's no big deal, it works again if I disable/reactivate my plugin.
But since I would like to share the plugin on the WP repo at the end, I would like to fix this bug. Can someone help ? Here's how my code works. I guess there is something that is incompatible with WP updating.
class WP_SoundSystem {
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new WP_SoundSystem;
self::$instance->setup_globals();
self::$instance->includes();
self::$instance->setup_actions();
}
return self::$instance;
}
private function __construct() { /* Do nothing here */ }
function setup_globals() {
//...
}
function includes(){
//...
}
function setup_actions(){
// activation
register_activation_hook( $this->file, array( $this, 'activate_wpsstm'));
// deactivation
register_deactivation_hook( $this->file, array( $this, 'deactivate_wpsstm'));
//...
}
function activate_wpsstm() {
$this->debug_log('activation');
$this->init_post_types();
$this->add_custom_capabilites();
$this->init_rewrite();
flush_rewrite_rules();
}
function deactivate_wpsstm() {
$this->debug_log('deactivation');
$this->remove_custom_capabilities();
flush_rewrite_rules();
}
/*
Hook for rewrite rules.
*/
function init_rewrite(){
$this->debug_log('set rewrite rules');
//files included in includes() above will hook on this to add rewrite rules
do_action('wpsstm_init_rewrite');
}
}
function wpsstm() {
return WP_SoundSystem::instance();
}
wpsstm();
Thanks.
本文标签: plugin rewrite rules are lost when WP updates
版权声明:本文标题:plugin: rewrite rules are lost when WP updates 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745675641a2669834.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论