settings = new Taxonomies_Settings( $this->options ); if ( ! empty( $this->options ) ) { add_action( 'init', [ $this, 'register_custom_taxonomies' ] ); } // Any write to the taxonomies (settings screen, import, WP-CLI) flushes // the rules on the next request. While the module is off its taxonomies // are not registered, and switching it on is caught by the Section's // toggle watcher. Flush_Rewrite::watch_option( self::OPTION_NAME, self::MODULE_ID ); } /** * Render the settings page * * @return void */ public function render_settings_page() { $this->settings->render_settings_page(); } /** * Register custom taxonomies * * @return void */ public function register_custom_taxonomies() { if ( ! empty( $this->options ) ) { foreach ( $this->options as $slug => $taxonomy_arg ) { $post_types = $taxonomy_arg['posttypes'] ?? []; unset( $taxonomy_arg['posttypes'], $taxonomy_arg['slug'], $taxonomy_arg['use_rewrite'] ); register_taxonomy( $slug, $post_types, $taxonomy_arg ); } } } }