Agent Skills: Action Links

Guides implementation of structured action links on log events. Triggers: adding get_action_links() to a logger, creating navigational links on events, or when migrating inline links from get_log_row_details_output() to the action links system.

UncategorizedID: bonny/wordpress-simple-history/action-links

Install this agent skill to your local

pnpm dlx add-skill https://github.com/bonny/WordPress-Simple-History/tree/HEAD/.claude/skills/action-links

Skill Files

Browse the full folder contents for action-links.

Download Skill

Loading file tree…

.claude/skills/action-links/SKILL.md

Skill Metadata

Name
action-links
Description
'Guides implementation of structured action links on log events. Triggers: adding get_action_links() to a logger, creating navigational links on events, or when migrating inline links from get_log_row_details_output() to the action links system.'

Action Links

Structured navigational links rendered below log events. Added in 5.24.0.

UX Principle

Icons represent action type, not destination. Use a small, consistent icon vocabulary so users learn the pattern once. The label text describes where the link goes — the icon just reinforces what kind of action it is.

Action Types

Use only these four types. Do not invent new ones unless truly necessary.

| Action | Icon | When to use | | ----------- | ---------------- | --------------------------------------- | | view | Eye (visibility) | Navigate to see/inspect something | | edit | Pencil | Navigate to modify something | | preview | Preview | View a draft or unpublished item | | revisions | History clock | Compare versions or view change history |

Most links are view. When in doubt, use view.

PHP: Adding Action Links to a Logger

Override get_action_links() in your logger class. Always check capabilities.

public function get_action_links( $row ) {
    if ( ! current_user_can( 'required_capability' ) ) {
        return [];
    }

    return [
        [
            'url'    => admin_url( 'page.php' ),
            'label'  => __( 'View thing', 'simple-history' ),
            'action' => 'view',
        ],
    ];
}

Required Keys

Each link must have all three keys:

  • url — Full URL (use admin_url(), get_edit_post_link(), etc.)
  • label — Translated, human-readable text
  • action — One of: view, edit, preview, revisions

Multiple Links

Return multiple links when relevant. Order: edit first, then view, then others.

$action_links = [];

if ( current_user_can( 'edit_post', $post_id ) ) {
    $action_links[] = [
        'url'    => get_edit_post_link( $post_id, 'raw' ),
        'label'  => __( 'Edit post', 'simple-history' ),
        'action' => 'edit',
    ];
}

if ( get_post_status( $post_id ) === 'publish' ) {
    $action_links[] = [
        'url'    => get_permalink( $post_id ),
        'label'  => __( 'View post', 'simple-history' ),
        'action' => 'view',
    ];
}

return $action_links;

Migrating from Inline Links

When moving a link from get_log_row_details_output() to action links:

  1. Add get_action_links() with the link
  2. Remove the inline <a> HTML from get_log_row_details_output()
  3. Keep capability checks in the new method

Constraints

  • Each action type may appear at most once per event (used as React key).
  • Action links are gated behind experimental features (Helpers::experimental_features_is_enabled()).

Architecture

REST Controller (prepare_item_for_response)
  → Simple_History::get_action_links($row)
    → Logger::get_action_links($row)
    → filter: simple_history/get_action_links
      → REST response (action_links field)
        → EventActionLinks.jsx renders with icons

Key Files

| File | Role | | ----------------------------------------- | ---------------------------------------------- | | loggers/class-logger.php | Base class, default empty get_action_links() | | inc/class-simple-history.php | Routes to logger, applies filter | | inc/class-wp-rest-events-controller.php | REST schema and response | | src/components/EventActionLinks.jsx | Frontend rendering with icons | | css/styles.css | Icon mask-image rules for action links |

Adding a New Action Type (Rare)

Only if the four standard types truly don't fit:

  1. Add SVG to css/icons/ (Material Symbols, 48px, FILL0, wght400)
  2. Add CSS mask rule in css/styles.css under the action links section
  3. Add mapping in ACTION_ICONS in src/components/EventActionLinks.jsx
  4. Update this skill document

Examples in Codebase

  • Simple: loggers/class-site-health-logger.php — single view link
  • Simple: loggers/class-available-updates-logger.php — single view link
  • Complex: loggers/class-post-logger.php — edit, view, preview, revisions