Repository navigation
Fix: Show only working View and Edit links in the logs table - #319
Merged
Merged
Conversation
Co-authored-by: Yakir Sitbon <KingYes@users.noreply.github.com>
Co-authored-by: Yakir Sitbon <KingYes@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
is_post_type_viewable(); Edit only whenget_edit_post_link()returns a URL.object_idis 0 (e.g.failed_login), which previously linked to the viewer's own profile viaget_edit_user_link()fallback, or when the user no longer exists.&(works on WP 6.2+).array_filter()on all actions, so nonull,falseor''reaches the REST response.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 andobject_id0 cases.Changelog (2.20.0)
✨ 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_descriptionnow 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