feat(kb): functional knowledge base backed by database tables - #72
Merged
Conversation
Port the Laravel reference knowledge base to the WordPress plugin's
table-based convention, replacing the stub that queried a never-registered
`escalated_article` custom post type (so the widget always returned nothing).
- Add `escalated_article_categories` (self-referencing tree, slug/position)
and `escalated_articles` (draft/published + published_at, unique slug,
optional category/author, view/helpful counters) tables to the activator's
create_tables(); existing installs pick them up via maybe_upgrade() on the
version bump to 1.3.0.
- Add Article and ArticleCategory models using the static $wpdb helper pattern.
- Add admin CRUD REST controllers under /admin/kb/articles and
/admin/kb/categories, gated by the existing kb.* capabilities (no new
capability, so the activator capability-count assertion is unchanged).
- Wire the public widget endpoints to read published articles from the tables:
list, show (increments view count, returns related articles), and a new
/articles/{slug}/feedback endpoint recording helpful/not-helpful when enabled.
Adds Test_Knowledge_Base_Api (13 tests) covering table creation, admin create
-> public list/show, unpublished excluded, category assignment, capability
gating, view increment, and feedback. Full suite: 391 passing.
mpge
added a commit
that referenced
this pull request
Aug 2, 2026
Port the Laravel reference knowledge base to the WordPress plugin's
table-based convention, replacing the stub that queried a never-registered
`escalated_article` custom post type (so the widget always returned nothing).
- Add `escalated_article_categories` (self-referencing tree, slug/position)
and `escalated_articles` (draft/published + published_at, unique slug,
optional category/author, view/helpful counters) tables to the activator's
create_tables(); existing installs pick them up via maybe_upgrade() on the
version bump to 1.3.0.
- Add Article and ArticleCategory models using the static $wpdb helper pattern.
- Add admin CRUD REST controllers under /admin/kb/articles and
/admin/kb/categories, gated by the existing kb.* capabilities (no new
capability, so the activator capability-count assertion is unchanged).
- Wire the public widget endpoints to read published articles from the tables:
list, show (increments view count, returns related articles), and a new
/articles/{slug}/feedback endpoint recording helpful/not-helpful when enabled.
Adds Test_Knowledge_Base_Api (13 tests) covering table creation, admin create
-> public list/show, unpublished excluded, category assignment, capability
gating, view increment, and feedback. Full suite: 391 passing.
Co-authored-by: Matt Gros <mpge@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the knowledge base functional, porting the Laravel reference to this plugin's table-based convention. Previously the widget queried a
escalated_articlecustom post type that was never registered viaregister_post_type, so the public KB always returned nothing and there was no in-app authoring.What changed
Storage (new tables, created via
Activator::create_tables()/ picked up bymaybe_upgrade()on the bump to 1.3.0):escalated_article_categories— self-referencing tree (parent_id),slug,position,description.escalated_articles—title/slug(unique),body,status(draft/published),published_at, optionalcategory_id/author_id, andview_count/helpful_count/not_helpful_count.Models (
Escalated\Models\Article,Escalated\Models\ArticleCategory) using the existing static$wpdbhelper pattern (likeCannedResponse/ApiToken).Admin CRUD REST controllers, registered in
Api_Bootstraplike the others:GET/POST /escalated/v1/admin/kb/articles,GET/PUT/PATCH/DELETE /admin/kb/articles/{id}GET/POST /escalated/v1/admin/kb/categories,PUT/PATCH/DELETE /admin/kb/categories/{id}escalated_kb_view/_create/_edit/_deletecapabilities — no new capability added, so the activator capability-count assertion (54) is unchanged.Public read — the widget endpoints now read published articles from the tables (the bug fix):
/widget/articles(list),/widget/articles/{slug}(show — increments the view counter, returns related articles), plus a new/widget/articles/{slug}/feedbackrecording helpful/not-helpful whenknowledge_base_feedback_enabled. Slug/publish/category semantics match the reference.Tests
New
Test_Knowledge_Base_Api(13 tests,WP_UnitTestCase): table creation, admin create → public list/show, unpublished excluded from the public surface, category assignment, capability gating (agent can view but not create; unauthenticated 401), draft→publish stampingpublished_at, view-count increment, and helpful/not-helpful feedback.Full suite green: 391 tests / 1030 assertions, 4 pre-existing skips (up from 378), Pint clean.