Repository navigation
Show snippet run location in list and card views - #589
Open
faisalahammad wants to merge 1 commit into
Open
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
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
Adds the run location to the All Snippets list so users can see where each snippet executes without opening the editor. A new Location column shows the scope icon and label in table view, and cards show the same location line in their meta row. Labels and icons reuse the editor's existing Location options, so wording matches everywhere.
Closes #517
Changes
Location column (
TableColumns.tsx)Before: table showed activate, ID, name, type, description, tags, date columns only.
After: new
LocationColumncomponent renders an aria-hidden dashicon plus the visible scope label (Run everywhere,Only run in administration area, etc). Conditional snippets have no single run location and show an em dash, matching the editor where they have no Location field. The column is sortable and registered in Screen Options so it can be toggled and its state persists.Why: the issue asks for an always-visible, text-backed run location in the list, not color- or tooltip-only.
Card view (
ManageSnippetCard.tsx)Before: card meta row only rendered when the snippet had tags or a modified date.
After: the meta row also renders when the snippet has a location, with the location as the first item.
Why: otherwise a plain global snippet with no tags and no edits would show nothing in card view.
Shared helper (
snippets.ts)Before: scope labels only accessible as the editor's select options.
After: new
getSnippetLocation()returns the visible label for a snippet or undefined for conditional snippets. Reused by both the column and the card.Screen Options (
Manage_Menu_Screen_Options.php)Before:
locationkey missing from the server-side column list.After:
locationregistered aftertypeso the column participates in the Screen Options toggle and persistence.Styles (
_snippets-table.scss)After:
.snippet-locationuses logical properties, muted text color, and 16px dashicon sizing shared with the name and type columns. Card location takes the full meta-row width.Tests
Snippet run locationdescribe creates snippets covering global, admin, front-end, single-use, content, site-css, and site-head-js scopes, asserts table and card labels, asserts the condition snippet shows an em dash in table and nothing in card, and asserts the Screen Options toggle hides and shows the column in real time.SnippetsTestHelperaccepts an explicitscopefor CLI-created snippets.get_columns()returnsLocationfor thelocationkey.Testing
Test 1: Table view labels
Result: each row shows the icon and label matching the editor's Location options; global snippets show
Run everywhere.Test 2: Conditional snippets
Result: table shows an em dash in the Location column; card shows no location line.
Test 3: Screen Options toggle
Result: the column hides and shows in real time and the state persists across page loads.
Test 4: Card view
Result: each card shows its location in the meta row with the same wording as table view.
Test 5: Responsive
Result: the location stays visible with the other per-row fields.
Automated: PHPCS/WPCS, ESLint, and Stylelint pass. PHPUnit 355 tests, 810 assertions pass (25 pre-existing environment skips). CodeRabbit review reported no findings.
npm run buildandnpm run bundlesucceed.Screenshots
Not attached; the wp-env site was verified locally.