Skip to content

feat(wordpress): add category/tag CRUD tools, fix delete-status and dead-field bugs#5360

Merged
waleedlatif1 merged 8 commits into
stagingfrom
worktree-wordpress-validate
Jul 2, 2026
Merged

feat(wordpress): add category/tag CRUD tools, fix delete-status and dead-field bugs#5360
waleedlatif1 merged 8 commits into
stagingfrom
worktree-wordpress-validate

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Add wordpress_{get,update,delete}_category and wordpress_{get,update,delete}_tag tools for full taxonomy CRUD parity (create/list already existed)
  • Fix deleted: data.deleted || true bug across all 6 delete tools (post/page/media/comment/category/tag) — the || operator meant the field could never report false, even when a delete was trashed rather than force-deleted; changed to ?? true
  • Remove dead force param from wordpress_delete_media — the endpoint always force-deletes (media has no trash), so the param had zero effect on the request; also dropped the corresponding UI toggle
  • Remove unwired hideEmpty block input (no backing subblock or tool param)
  • Normalize search_content perPage/page visibility to user-or-llm for consistency with other list tools
  • Full validation pass against the WordPress.com REST API docs across every existing tool, block wiring, and OAuth scopes — no other discrepancies found

Type of Change

  • New feature (taxonomy tools)
  • Bug fix (delete-status flag, dead param)

Testing

Tested manually. Ran bun run check:api-validation, bunx tsc --noEmit, and biome check clean on all changed/added files. Verified backward compatibility — no existing tool IDs, output fields, or required flags changed; only additions plus two confirmed-dead-code removals.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 2, 2026 5:34pm

Request Review

@cursor

cursor Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Adds destructive taxonomy delete operations and changes delete response semantics and search param mapping; workflows relying on old search type behavior or media force UI should be rechecked.

Overview
Expands the WordPress block and tools with full category and tag CRUD (get, update, delete) registered in the tool registry, plus block operations, subblocks, and param wiring for taxonomy IDs and update fields.

Bug fixes and cleanup: delete tools now use deleted: data.deleted ?? true so a false from the API is not swallowed; force is removed from media delete (always force-deletes) and from the block UI for media; the unwired hideEmpty input is dropped. Search maps the block filter to the API subtype param (attachment removed from the UI); search perPage/page visibility is user-or-llm.

API fidelity: optional numeric fields use !== undefined in request bodies so 0 is sent; block param mapping avoids coercing empty strings to numbers. Comment create gains parent/author fields; upload media gains description; list posts/pages gain filters (author, parent). Copy narrows integration to WordPress.com OAuth only. New block skills cover taxonomy organization and content audit.

Reviewed by Cursor Bugbot for commit 4bc8d28. Configure here.

Comment thread apps/sim/tools/wordpress/delete_category.ts Outdated
@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR completes taxonomy CRUD parity for the WordPress integration by adding get, update, and delete tools for both categories and tags, while also fixing a persistent ||-over-?? bug in all six delete-tool response handlers and removing dead code (the force param from media deletion and the unwired hideEmpty block input).

  • New taxonomy tools: Six new tool files (get_category, update_category, delete_category, get_tag, update_tag, delete_tag) follow the established pattern; delete tools correctly hard-code force=true in the URL since WP terms cannot be trashed.
  • Delete response fix: data.deleted || truedata.deleted ?? true across all six delete tools; zero-valued numeric fields (id, author, parent, featured_media, count) likewise migrated to ?? so falsy-but-valid values are no longer silently dropped.
  • Guard fixes for numeric inputs: !== undefined && !== '' guards replace truthy checks for featuredMedia, menuOrder, parent, and other numeric block inputs, enabling callers to explicitly send 0 (e.g. to remove a featured image or set root-level parent).

Confidence Score: 5/5

Safe to merge — all changes are additive new tools or targeted bug fixes with no breaking changes to existing tool IDs, output shapes, or required fields.

The || to ?? fix is applied consistently across all six delete tools, the new taxonomy tools mirror the established patterns for create/list, the dead-param removals are confirmed safe (media always force-deletes, hideEmpty was never wired), and the numeric guard fixes correct a real scenario where zero values were silently dropped. The searchType block input keeps its existing ID so stored workflows are unaffected; only the outgoing API key moves from type to subtype, which matches actual WP REST API search semantics. No regressions found in wiring, types, or registry registration.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/wordpress.ts Block wiring extended for 6 new tools (get/update/delete category+tag), new block inputs (listAuthor, mediaDescription, commentParent/Author fields), and correct ?? guards for numeric params; searchType maps to subtype param (semantically correct per WP REST API)
apps/sim/tools/wordpress/delete_category.ts New file; force=true baked into URL (correct — terms cannot be trashed); deleted uses ??; count/parent use ?? correctly for zero-value taxonomy fields
apps/sim/tools/wordpress/delete_tag.ts New file; mirrors delete_category pattern without parent (tags are flat); deleted/count/id use ?? correctly
apps/sim/tools/wordpress/get_category.ts New file; straightforward GET by ID, all fields mapped correctly including parent hierarchy
apps/sim/tools/wordpress/get_tag.ts New file; straightforward GET by ID, correctly omits parent (tags are flat)
apps/sim/tools/wordpress/update_category.ts New file; uses POST to update, parent guarded with !== undefined, all fields consistent with create_category pattern
apps/sim/tools/wordpress/update_tag.ts New file; uses POST to update, correct fields for flat taxonomy (no parent), consistent with create_tag pattern
apps/sim/tools/wordpress/delete_post.ts Fixes deleted ?? true and id/author/featured_media ?? fallbacks; author and featured_media correctly handle 0 values now
apps/sim/tools/wordpress/delete_media.ts Dead force param removed from params schema; force=true permanently embedded in URL; deleted ?? true fix applied
apps/sim/tools/wordpress/search_content.ts perPage/page visibility changed to user-or-llm; type/subtype descriptions corrected to match actual WP REST API search semantics
apps/sim/tools/wordpress/types.ts Adds 6 new param/response interfaces for get/update/delete category+tag; removes force from DeleteMedia; corrects search type union to post
apps/sim/tools/registry.ts Registers all 6 new tools under their correct IDs; import ordering and keys are consistent with surrounding code

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Block UI wordpress.ts] -->|operation select| B{Operation}
    B --> C[Category CRUD]
    B --> D[Tag CRUD]
    B --> E[Search Content]
    B --> F[Delete Tools]
    C --> C1[get_category GET]
    C --> C2[update_category POST]
    C --> C3[delete_category DELETE force=true]
    D --> D1[get_tag GET]
    D --> D2[update_tag POST]
    D --> D3[delete_tag DELETE force=true]
    E --> E1[searchType maps to subtype param]
    F --> F1[post/page/comment: deleted ?? true]
    F --> F2[media: force param removed, always force=true]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Block UI wordpress.ts] -->|operation select| B{Operation}
    B --> C[Category CRUD]
    B --> D[Tag CRUD]
    B --> E[Search Content]
    B --> F[Delete Tools]
    C --> C1[get_category GET]
    C --> C2[update_category POST]
    C --> C3[delete_category DELETE force=true]
    D --> D1[get_tag GET]
    D --> D2[update_tag POST]
    D --> D3[delete_tag DELETE force=true]
    E --> E1[searchType maps to subtype param]
    F --> F1[post/page/comment: deleted ?? true]
    F --> F2[media: force param removed, always force=true]
Loading

Reviews (9): Last reviewed commit: "fix(wordpress): remove invalid Attachmen..." | Re-trigger Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8cb03d7. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/blocks/blocks/wordpress.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/tools/wordpress/update_category.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3e54a46. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/blocks/blocks/wordpress.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 44a6963. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5686166. Configure here.

…ead-field bugs

- Add wordpress_{get,update,delete}_category and _tag tools for full taxonomy parity
- Fix `deleted: data.deleted || true` always evaluating true across all 6 delete tools (posts/pages/media/comments/categories/tags)
- Remove dead `force` param from delete_media (endpoint always force-deletes; param had zero effect)
- Remove unwired `hideEmpty` block input
- Normalize search_content perPage/page visibility to user-or-llm for consistency
…n delete_category/tag

count and parent can legitimately be 0 (empty term, top-level category); || was
dropping those values, same antipattern already fixed for `deleted` in this PR.
Flagged independently by Greptile and Cursor Bugbot.
…te tools

Same || antipattern already fixed for category/tag delete tools was still
present in delete_post/page/comment/media for id, author, featured_media,
menu_order, parent, post — all legitimately 0 in common cases (no featured
image, top-level page/comment). Found by a final independent validation pass.
…block param mapping

Truthy check on params.categoryParent treated a resolved numeric 0 (root-level,
no parent) as unset. Flagged by Cursor Bugbot on create_category/update_category.
…ield left blank

description used !== undefined (numeric-field convention) instead of a truthy
check (string-field convention used everywhere else in this codebase, e.g.
update_post/update_page excerpt), so an untouched empty description field
silently wiped existing text on every update. Flagged by Cursor Bugbot.
…osure gaps

- search_content.ts: type param was mislabeled with subtype's vocabulary
  (post/page/attachment); real WP type enum is post/term/post-format. Rewired
  the block's Content Type dropdown to map to subtype (which is what
  post/page/attachment actually filter), not type.
- Widened subBlock conditions so params already read by tools.config.params
  are actually reachable in the UI: commentPostId for list_comments,
  categories/tags for list_posts, parent for list_pages.
- Added missing subBlocks for tool params with no UI path: comment
  parent/authorName/authorEmail/authorUrl (create_comment), media description
  (upload_media), author filter (list_posts).
- Extended the ?? / !== undefined fix (already applied to categoryParent) to
  the same class of param across the block: featuredMedia, page parent,
  menuOrder, and the new commentParent/listAuthor mappings.
- Fixed featuredMedia/parent truthy-check inconsistency in create_post,
  update_post, create_page, update_page, create_category, create_comment
  body builders to match the !== undefined convention used elsewhere.

Found by an independent final validation pass across 3 parallel agents.
…w compat

The type/subtype fix should only change which API param the field feeds
(subtype, not type) — renaming the subBlock id to searchSubtype broke
already-saved workflows with a search content-type filter set, since the
block would stop reading the old searchType key. Reverted the id rename,
kept the underlying subtype mapping fix. Flagged by Cursor Bugbot.
…hor input type

- Search Content's "Content Type" dropdown offered Attachment, which maps to
  subtype=attachment. WP core's WP_REST_Post_Search_Handler explicitly
  excludes attachment from valid subtypes (media isn't searchable via
  /search) — selecting it guaranteed a 400 rest_invalid_param. Removed the
  option; only Post/Page (the only valid subtypes) remain.
- listAuthor was declared type: 'string' in the inputs catalog despite being
  Number()-coerced before use, inconsistent with every other ID-like field
  (postId, pageId, categoryId, commentParent, etc. are all 'number').

Found by an independent final pre-merge validation pass, requested before
merge to be certain of full API alignment.
@waleedlatif1 waleedlatif1 force-pushed the worktree-wordpress-validate branch from 5686166 to 4bc8d28 Compare July 2, 2026 17:33
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4bc8d28. Configure here.

@waleedlatif1 waleedlatif1 merged commit a08da86 into staging Jul 2, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the worktree-wordpress-validate branch July 2, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant