Skip to content

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

Open
waleedlatif1 wants to merge 5 commits into
stagingfrom
worktree-wordpress-validate
Open

feat(wordpress): add category/tag CRUD tools, fix delete-status and dead-field bugs#5360
waleedlatif1 wants to merge 5 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)

…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
@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 7:31am

Request Review

@cursor

cursor Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New delete-category/tag operations are permanent on live sites via OAuth, and delete-status semantics changed for existing workflows that relied on deleted always being true.

Overview
Expands the WordPress integration with get / update / delete tools for categories and tags, wired through the block UI, tool registry, types, and new playbook skills for taxonomy cleanup and content audits. Block copy now describes WordPress.com + OAuth only (self-hosted / application passwords removed from the description).

Bug fixes and cleanup: delete tools use deleted: data.deleted ?? true so false can surface when the API trashes instead of hard-deletes; numeric fields in delete responses use ?? where 0 matters. Delete media always calls the API with force=true and drops the unused force param and UI toggle. Removes the unwired hideEmpty input and tightens category parent mapping so empty strings are not sent as 0.

Minor: search_content perPage / page are user-or-llm like other list tools.

Reviewed by Cursor Bugbot for commit 3e54a46. 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, and fixes a longstanding ||-vs-?? bug in all six delete tools where deleted: false was unreachable.

  • New tools: wordpress_get_category, wordpress_update_category, wordpress_delete_category, wordpress_get_tag, wordpress_update_tag, wordpress_delete_tag — all correctly wired into the block UI and the tool registry.
  • Delete-status fix: data.deleted || truedata.deleted ?? true across all six delete tools (post, page, media, comment, category, tag), ensuring a false value from the API (trashed rather than force-deleted) is now faithfully reported.
  • Dead-code removal: The unused force param from delete_media and the unwired hideEmpty block input are both dropped cleanly.

Confidence Score: 5/5

Safe to merge — all six delete tools now correctly propagate the API's deleted flag, and the six new taxonomy tools are cleanly integrated with no changes to existing tool IDs or output contracts.

The changes are additive (new tools) plus targeted one-line bug fixes. No existing behavior is altered in a breaking way, the block wiring and registry registrations are complete and consistent, and the delete-status fix correctly applies ?? across every affected file.

apps/sim/tools/wordpress/update_category.ts and update_tag.ts — truthy checks on optional string params mean empty-string values are silently dropped rather than forwarded to the API.

Important Files Changed

Filename Overview
apps/sim/tools/wordpress/update_category.ts New update tool; truthy checks for description/name/slug silently drop empty-string values, and parent visibility is user-only which conflicts with the new organize-taxonomy LLM workflow.
apps/sim/tools/wordpress/update_tag.ts New update tool; same truthy-check issue as update_category.ts — description: "" will be silently dropped instead of clearing the tag description.
apps/sim/tools/wordpress/delete_category.ts New delete tool; correctly uses ?? for numeric fields (id, count, parent) and
apps/sim/tools/wordpress/delete_tag.ts New delete tool; mirrors delete_category correctly; ?? used for id/count,
apps/sim/tools/wordpress/get_category.ts New read-only get tool; straightforward mapping of API fields including parent; no issues.
apps/sim/tools/wordpress/get_tag.ts New read-only get tool; clean implementation, no issues.
apps/sim/tools/wordpress/delete_post.ts Bug fix: deleted: data.deleted
apps/sim/tools/wordpress/delete_media.ts Dead force param removed; force=true hardcoded in URL (correct since media has no trash); deleted fix applied.
apps/sim/blocks/blocks/wordpress.ts New category/tag subblocks wired correctly; force removed from delete_media condition; hideEmpty dead input removed; block param mapping complete for all 6 new operations.
apps/sim/tools/wordpress/types.ts New param/response interfaces for get/update/delete category and tag; union type updated; force removed from WordPressDeleteMediaParams.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant UI as Block UI
    participant Registry as Tool Registry
    participant WP as WordPress.com API

    Note over UI,WP: New Taxonomy CRUD Operations

    UI->>Registry: wordpress_get_category(siteId, categoryId)
    Registry->>WP: "GET /sites/{siteId}/categories/{id}"
    WP-->>Registry: "{ id, name, slug, count, parent, ... }"
    Registry-->>UI: "{ category: { ... } }"

    UI->>Registry: wordpress_update_category(siteId, categoryId, name?, slug?, ...)
    Registry->>WP: "POST /sites/{siteId}/categories/{id}"
    WP-->>Registry: "{ id, name, slug, count, parent, ... }"
    Registry-->>UI: "{ category: { ... } }"

    UI->>Registry: wordpress_delete_category(siteId, categoryId)
    Registry->>WP: "DELETE /sites/{siteId}/categories/{id}?force=true"
    WP-->>Registry: "{ deleted: true, previous: { ... } }"
    Registry-->>UI: "{ deleted: true, category: { ... } }"

    Note over UI,WP: Same pattern mirrors for Tag operations
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"}}}%%
sequenceDiagram
    participant UI as Block UI
    participant Registry as Tool Registry
    participant WP as WordPress.com API

    Note over UI,WP: New Taxonomy CRUD Operations

    UI->>Registry: wordpress_get_category(siteId, categoryId)
    Registry->>WP: "GET /sites/{siteId}/categories/{id}"
    WP-->>Registry: "{ id, name, slug, count, parent, ... }"
    Registry-->>UI: "{ category: { ... } }"

    UI->>Registry: wordpress_update_category(siteId, categoryId, name?, slug?, ...)
    Registry->>WP: "POST /sites/{siteId}/categories/{id}"
    WP-->>Registry: "{ id, name, slug, count, parent, ... }"
    Registry-->>UI: "{ category: { ... } }"

    UI->>Registry: wordpress_delete_category(siteId, categoryId)
    Registry->>WP: "DELETE /sites/{siteId}/categories/{id}?force=true"
    WP-->>Registry: "{ deleted: true, previous: { ... } }"
    Registry-->>UI: "{ deleted: true, category: { ... } }"

    Note over UI,WP: Same pattern mirrors for Tag operations
Loading

Reviews (5): Last reviewed commit: "fix(wordpress): don't clear category/tag..." | Re-trigger Greptile

…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.
@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.

…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.
@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
…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.
@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
…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.
@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.

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