settings = Settings::get_instance(); add_action( 'init', [ $this, 'register' ] ); } public function register() { $this->register_taxonomies(); $this->register_post_type(); } private function register_taxonomies() { // Knowledge Base Taxonomy (Conditional) if ( $this->settings->get( 'enable_multiple_kb', false ) ) { $kb_slug = $this->settings->get( 'kb_slug', 'knowledge-base-group' ); $kb_labels = [ 'name' => _x( 'Knowledge Bases', 'taxonomy general name', 'acumenon' ), 'singular_name' => _x( 'Knowledge Base', 'taxonomy singular name', 'acumenon' ), 'search_items' => __( 'Search Knowledge Bases', 'acumenon' ), 'all_items' => __( 'All Knowledge Bases', 'acumenon' ), 'parent_item' => __( 'Parent Knowledge Base', 'acumenon' ), 'parent_item_colon' => __( 'Parent Knowledge Base:', 'acumenon' ), 'edit_item' => __( 'Edit Knowledge Base', 'acumenon' ), 'update_item' => __( 'Update Knowledge Base', 'acumenon' ), 'add_new_item' => __( 'Add New Knowledge Base', 'acumenon' ), 'new_item_name' => __( 'New Knowledge Base Name', 'acumenon' ), 'menu_name' => __( 'Knowledge Bases', 'acumenon' ), ]; $kb_args = [ 'hierarchical' => true, 'labels' => $kb_labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => [ 'slug' => $kb_slug ], 'show_in_rest' => true, ]; register_taxonomy( $this->knowledge_base, null, $kb_args ); } // Category Taxonomy $cat_slug = $this->settings->get( 'category_slug', 'kb-category' ); $cat_labels = [ 'name' => _x( 'Categories', 'taxonomy general name', 'acumenon' ), 'singular_name' => _x( 'Category', 'taxonomy singular name', 'acumenon' ), 'search_items' => __( 'Search Categories', 'acumenon' ), 'all_items' => __( 'All Categories', 'acumenon' ), 'parent_item' => __( 'Parent Category', 'acumenon' ), 'parent_item_colon' => __( 'Parent Category:', 'acumenon' ), 'edit_item' => __( 'Edit Category', 'acumenon' ), 'update_item' => __( 'Update Category', 'acumenon' ), 'add_new_item' => __( 'Add New Category', 'acumenon' ), 'new_item_name' => __( 'New Category Name', 'acumenon' ), 'menu_name' => __( 'Categories', 'acumenon' ), ]; $cat_args = [ 'hierarchical' => true, 'labels' => $cat_labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => [ 'slug' => $cat_slug ], 'show_in_rest' => true, ]; register_taxonomy( $this->category, null, $cat_args ); // Tag Taxonomy $tag_slug = $this->settings->get( 'tag_slug', 'kb-tag' ); $tag_labels = [ 'name' => _x( 'Tags', 'taxonomy general name', 'acumenon' ), 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'acumenon' ), 'search_items' => __( 'Search Tags', 'acumenon' ), 'popular_items' => __( 'Popular Tags', 'acumenon' ), 'all_items' => __( 'All Tags', 'acumenon' ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Edit Tag', 'acumenon' ), 'update_item' => __( 'Update Tag', 'acumenon' ), 'add_new_item' => __( 'Add New Tag', 'acumenon' ), 'new_item_name' => __( 'New Tag Name', 'acumenon' ), 'separate_items_with_commas' => __( 'Separate tags with commas', 'acumenon' ), 'add_or_remove_items' => __( 'Add or remove tags', 'acumenon' ), 'choose_from_most_used' => __( 'Choose from the most used tags', 'acumenon' ), 'not_found' => __( 'No tags found.', 'acumenon' ), 'menu_name' => __( 'Tags', 'acumenon' ), ]; $tag_args = [ 'hierarchical' => false, 'labels' => $tag_labels, 'show_ui' => true, 'show_admin_column' => true, 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'rewrite' => [ 'slug' => $tag_slug ], 'show_in_rest' => true, ]; register_taxonomy( $this->tag, null, $tag_args ); } private function register_post_type() { $docs_slug = $this->settings->get( 'docs_slug', 'knowledge-base' ); $labels = [ 'name' => _x( 'Docs', 'Post type general name', 'acumenon' ), 'singular_name' => _x( 'Doc', 'Post type singular name', 'acumenon' ), 'menu_name' => _x( 'Acumenon', 'Admin Menu text', 'acumenon' ), 'name_admin_bar' => _x( 'Doc', 'Add New on Toolbar', 'acumenon' ), 'add_new' => __( 'Add New', 'acumenon' ), 'add_new_item' => __( 'Add New Doc', 'acumenon' ), 'new_item' => __( 'New Doc', 'acumenon' ), 'edit_item' => __( 'Edit Doc', 'acumenon' ), 'view_item' => __( 'View Doc', 'acumenon' ), 'all_items' => __( 'All Docs', 'acumenon' ), 'search_items' => __( 'Search Docs', 'acumenon' ), 'parent_item_colon' => __( 'Parent Docs:', 'acumenon' ), 'not_found' => __( 'No docs found.', 'acumenon' ), 'not_found_in_trash' => __( 'No docs found in Trash.', 'acumenon' ), ]; $args = [ 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => [ 'slug' => $docs_slug ], 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => [ 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'revisions' ], 'taxonomies' => $this->settings->get( 'enable_multiple_kb', false ) ? [ $this->knowledge_base, $this->category, $this->tag ] : [ $this->category, $this->tag ], 'show_in_rest' => true, // Enables Gutenberg ]; register_post_type( $this->post_type, $args ); } }