Skip to content

Posts: add bulk restore action for trashed posts and pages - #864

Merged
AllTerrainDeveloper merged 5 commits into
WordPress:trunkfrom
CookieDarb:fix/posts-pages-trash-restore
Oct 9, 2026
Merged

AllTerrainDeveloper merged 5 commits into
WordPress:trunkfrom
CookieDarb:fix/posts-pages-trash-restore

Conversation

@CookieDarb

@CookieDarb CookieDarb commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #863

Adds a Restore bulk action to the native Posts and Pages windows when filtering items by the Trash status, allowing users to restore selected posts and pages directly from the window's bulk action bar.

Why?

Previously, selecting items while viewing the Trash filter in the Posts and Pages windows only displayed the "Move to trash" button in the bulk action bar. Trashing an already-trashed item is non-functional, and users had no way to restore items from within the list itself without opening the separate Recycle Bin app.

How?

  • apps/posts/parts/query.php:
    • Added openstation_posts_app_restore() to untrash selected IDs using native wp_untrash_post().
  • apps/posts/posts.os.php & apps/pages/pages.os.php:
    • Registered the restore action on the desktop-mode-posts and desktop-mode-pages app manifests.
  • apps/posts/parts/columns.ts:
    • Extended defaultBulkActions() to include the restore bulk action.
  • apps/posts/parts/app.ts:
    • Updated bulkBar to wire the restore action dispatch (( ids ) => ctx.dispatch( 'restore', { ids } )).
    • Dynamically partitions actions: displays restore when ctx.state.status === 'trash' and trash in all other views.
  • apps/posts/parts/types.ts:
    • Updated BulkAction JSDoc comments to document both default actions.
  • docs/hooks-reference.md & docs/examples/native-posts.md:
    • Updated reference docs and examples to describe openstation.postsWindow.bulkActions shipping both trash and restore actions.
  • apps/posts/posts.test.ts:
    • Added unit tests verifying restore action.
  • tests/phpunit/tests/postsApp.php:
    • Added PHPUnit tests verifying restore server action.

Testing Instructions

  1. Open the native Posts window (or Pages window) in Desktop Mode.
  2. Ensure there is at least one trashed post (or trash a post).
  3. Click on the Trash status segment tab in the toolbar.
  4. Select one or more trashed posts using the checkboxes.
  5. Verify that the bottom bulk action bar shows the Restore button instead of "Move to trash".
  6. Click Restore:
    • Verify that no confirmation modal prompts (instant execution).
    • Verify that the selection is cleared and the posts are restored.

Screencast

Restore-Demo.mov

Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: For suggesting changes and adding tests. Final decisions and edits were made by me.

Open WordPress Playground Preview

@AllTerrainDeveloper

Copy link
Copy Markdown
Collaborator

I will solve conflicts :) Sorry, we have been busier than usual

Resolve conflicts with the new `{ mode }` argument on the
`openstation.postsWindow.bulkActions` filter: pass `mode` to
resolveBulkActions() alongside the new restore dispatch, and fold both
changes into the BulkAction JSDoc and the hooks/example docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AllTerrainDeveloper
AllTerrainDeveloper merged commit 69d378e into WordPress:trunk Oct 9, 2026
7 checks passed
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.

Posts & Pages: Bulk action bar displays "Move to trash" when viewing already trashed items

2 participants