Skip to content

Fix: Show only working View and Edit links in the logs table - #319

Merged
KingYes merged 2 commits into
masterfrom
fix/working-row-actions
Nov 22, 2026
Merged

KingYes merged 2 commits into
masterfrom
fix/working-row-actions

Conversation

@KingYes

@KingYes KingYes commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

The logs table showed dead or misleading View/Edit links for deleted, trashed or restricted items. This PR builds only working links on the server and makes the links visible and translatable in the UI.

Fixes #317

Changes

  • Posts: no links for missing or trashed posts; View only when is_post_type_viewable(); Edit only when get_edit_post_link() returns a URL.
  • Users: no Edit link when object_id is 0 (e.g. failed_login), which previously linked to the viewer's own profile via get_edit_user_link() fallback, or when the user no longer exists.
  • Comments: no link for missing or trashed comments or comments on trashed posts; Edit URL no longer contains & (works on WP 6.2+).
  • Taxonomies: unchanged (already checked).
  • array_filter() on all actions, so no null, false or '' reaches the REST response.
  • UI (log-row.js): View and Edit labels are translatable and always visible, not hover-only.

Tests

New tests/phpunit/test-log-presenter-actions.php (17 cases) covering posts, users, comments and taxonomies, including deleted, trashed, restricted and object_id 0 cases.

Changelog (2.20.0)

  • Tweak: Always show View and Edit links in the logs table and make them translatable
  • Fix: Show only working View and Edit links in the logs table for deleted, trashed or restricted items

✨ PR Description

1. Problem & Context

Prevents broken "View" and "Edit" links in the logs table by verifying object existence, status, and user permissions before rendering actions.

2. What Changed (Where)

  • classes/class-aal-log-presenter.php: Added validation logic and helper methods for object action links.
  • tests/phpunit/test-log-presenter-actions.php: New test suite covering various object states and user roles.
  • assets/js/admin/src/logs/log-row.js: Updated row actions UI for better labeling and styling.

3. How It Works

format_description now delegates link generation to type-specific helpers (actions_for_post, etc.) that check if the object exists and isn't trashed. The resulting actions array is filtered for empty values before being passed to the frontend.

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how

Co-authored-by: Yakir Sitbon <KingYes@users.noreply.github.com>
Co-authored-by: Yakir Sitbon <KingYes@users.noreply.github.com>
@KingYes
KingYes merged commit a96b908 into master Nov 22, 2026
56 checks passed
@KingYes
KingYes deleted the fix/working-row-actions branch November 22, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable buttons when they have no actions

1 participant