diff --git a/bracketpress.php b/bracketpress.php index a2cec0a..f99b6db 100644 --- a/bracketpress.php +++ b/bracketpress.php @@ -311,10 +311,17 @@ function activate() { $this->update_option('edit_id', wp_insert_post($post)); } + // The init hook does not run during plugin activation, so register the + // custom post type before flushing rewrites. Otherwise WordPress flushes + // rules without the bracket permalink structure and bracket links can 404 + // until the site owner manually saves permalinks. + $this->register_posts(); flush_rewrite_rules(); } - function deactivate() { } + function deactivate() { + flush_rewrite_rules(); + } function register_posts() {