Skip to content

feat(commands): add Command Palette commands for editing existing SCF data structures#516

Open
faisalahammad wants to merge 2 commits into
WordPress:trunkfrom
faisalahammad:fix/138-command-palette-edit-cpt-instance
Open

feat(commands): add Command Palette commands for editing existing SCF data structures#516
faisalahammad wants to merge 2 commits into
WordPress:trunkfrom
faisalahammad:fix/138-command-palette-edit-cpt-instance

Conversation

@faisalahammad

@faisalahammad faisalahammad commented Jul 21, 2026

Copy link
Copy Markdown

Summary

Adds Command Palette (Cmd+K / Ctrl+K) commands for editing existing SCF data structures: field groups, taxonomies, and options pages.

Previously, users could only list and add new data structures via the Command Palette. This adds per-item edit commands that navigate directly to the edit screen for each existing item.

Fixes #137

Changes

REST API: Taxonomy endpoint (class-acf-rest-types-endpoint.php)

Before: No REST field for taxonomy SCF internal post IDs.
After: New scf_taxonomy_id field on /wp/v2/taxonomies, mirroring existing scf_post_id on /wp/v2/types. Capability-gated: only exposed to users who can edit the taxonomy definition.
Why: Enables the JS Command Palette to detect SCF-managed taxonomies and gate edit commands on the same capability check used for post types.

Taxonomy commands (custom-post-type-commands.js)

Before: No taxonomy commands.
After: Per-taxonomy commands:

  • scf/tax-{slug} — View Terms (gated on canUser('edit', 'taxonomy', slug))
  • scf/edit-tax-{slug} — Edit Taxonomy definition (gated on scf_taxonomy_id presence)
    Why: Completes taxonomy coverage in the Command Palette, matching the existing CPT pattern.

Field group commands (admin-commands.js + admin-commands.php)

Before: No way to edit existing field groups from Command Palette.
After: Per-field-group scf/edit-field-group-{key} commands with label "Edit field group: {title}". Data injected via wp_localize_script since acf-field-group posts are not REST-accessible. Gated on current_user_can('edit_post', ID).
Why: Field groups lack a REST endpoint, so PHP-side data injection is the only path.

Options page commands (admin-commands.js + admin-commands.php)

Before: No way to edit existing options pages from Command Palette.
After: Per-options-page scf/edit-options-page-{slug} commands with label "Edit options page: {title}". Data injected via wp_localize_script since acf-ui-options-page posts are not REST-accessible. Gated on current_user_can('edit_post', ID).
Why: Same REST limitation as field groups; PHP injection is the only path.

Testing

Test 1: Taxonomy commands

  1. Create a taxonomy via SCF (Taxonomies > Add New)
  2. Open Command Palette (Cmd+K / Ctrl+K)
  3. Search for the taxonomy name
  4. Verify "View Terms" and "Edit Taxonomy: {name}" commands appear
  5. Click each, verify correct navigation

Test 2: Field group commands

  1. Create a field group via SCF (Field Groups > Add New)
  2. Open Command Palette
  3. Search for the field group title
  4. Verify "Edit field group: {title}" command appears
  5. Click it, verify navigation to the edit screen

Test 3: Options page commands

  1. Register an options page via SCF code (add_action)
  2. Open Command Palette
  3. Search for the options page title
  4. Verify "Edit options page: {title}" command appears
  5. Click it, verify navigation to the edit screen

Test 4: Capability checks

  1. Log in as a user without edit_posts capability
  2. Open Command Palette
  3. Verify edit commands do not appear for items the user cannot edit

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props faisalahammad, priethor.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

The loader registered for each CPT was checking postType.visibility?.show_in_rest,
but the WordPress core /wp/v2/types response does not include a visibility object.
The show_in_rest signal is inferred from a non-empty rest_base.

Derived hasRestSupport from rest_base && rest_namespace to gate the loader,
and wrapped per-CPT registration in an async IIFE so one failure does not
kill the rest. Added wp-core-data dependency for getEntityRecords resolution.
E2E test seeds a published post and asserts the edit result navigates to the
post editor.

Fixes WordPress#138
@faisalahammad
faisalahammad force-pushed the fix/138-command-palette-edit-cpt-instance branch from 77aea75 to df544a2 Compare July 21, 2026 17:26
Adds 'Edit' commands for field groups, taxonomies, and options pages in the
WordPress Command Palette (Cmd+K / Ctrl+K).

- Taxonomy commands: new scf_taxonomy_id REST field on /wp/v2/taxonomies
  mirrors existing scf_post_id pattern, enabling per-taxonomy 'View Terms'
  and 'Edit Taxonomy' commands with capability checks
- Field group commands: per-field-group 'Edit field group: {title}' commands
  using PHP-injected data (acf-field-group has no REST endpoint)
- Options page commands: per-options-page 'Edit options page: {title}' commands
  using PHP-injected data (acf-ui-options-page has no REST endpoint)

Fixes WordPress#137
@faisalahammad faisalahammad changed the title fix(commands): add command palette loader to edit existing CPT instances feat(commands): add Command Palette commands for editing existing SCF data structures Jul 21, 2026
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.

Add Command Palette commands for SCF data structures

1 participant