diff --git a/functions.php b/functions.php index 6a1afd9..1f496a6 100644 --- a/functions.php +++ b/functions.php @@ -68,6 +68,26 @@ function __comicpress_init() { remove_filter('comments_number','id_get_comment_number'); } + $storyline = get_option('comicpress-storyline-category-order'); + + $do_rebuild = false; + + if (empty($storyline)) { + $do_rebuild = true; + } else { + $first = array_pop(explode('/', array_shift(explode(',', $storyline)))); + + if ($first != $comicpress_options['comicpress_config']['comiccat']) { + $do_rebuild = true; + } + } + + if ($do_rebuild) { + $storyline = new ComicPressStoryline(); + + update_option('comicpress-storyline-category-order', $storyline->get_category_flattened($comicpress_options['comicpress_config']['comiccat'])); + } + do_action('comicpress_init'); if ($verified_nonce = __comicpress_verify_nonce()) { @@ -221,11 +241,6 @@ function comicpress_load_options() { update_option('comicpress_options', $comicpress_options); - $storyline = get_option('comicpress-storyline-category-order'); - if (empty($storyline)) { - update_option('comicpress-storyline-category-order', "0/$comiccat"); - } - return $comicpress_options; }