Skip to content

Add CSV/JSON export for redirects#452

Open
nhrrob wants to merge 2 commits into
10up:developfrom
nhrrob:feature/export-feature
Open

Add CSV/JSON export for redirects#452
nhrrob wants to merge 2 commits into
10up:developfrom
nhrrob:feature/export-feature

Conversation

@nhrrob
Copy link
Copy Markdown

@nhrrob nhrrob commented May 23, 2026

Description of the Change

Adds the ability to export all redirect rules from the wp-admin redirect list
table as either a CSV or JSON file.

A format dropdown and an Export button appear in the top toolbar of the
Redirects screen. Selecting a format and clicking Export downloads the file
immediately. Each exported record includes: ID, Redirect From, Redirect To,
HTTP Status Code, Enable Regex, Force HTTPS, Message, and Status.

The export is protected by a nonce and a capability check using the existing
srm_restrict_to_capability filter, so only authorized users can trigger a
download. CSV output is also protected against formula injection attacks.

Closes #
Partially related to #43
After adding the Export feature, we can add the .htaccess export support too. PR is designed to be able to easily extend any future export types.

How to test the Change

  1. Go to the Redirects list table in wp-admin (Admin Dashboard -> Tools -> Safe Redirect Manager).
  2. Confirm an Export feature (CSV / JSON dropdown and "Export" button) appear at the top of the table.
  3. Select CSV → click Export → verify a .csv file downloads with all
    redirect data and correct column headers.
  4. Select JSON → click Export → verify a .json file downloads as a
    valid JSON array with the same data.
  5. Confirm the existing Filter button still works normally.
  6. Log in as a user without redirect management permissions and confirm the
    Export button is not shown.

Changelog Entry

Added - Export redirect rules as CSV or JSON from the admin redirect list table.

Credits

Props @nhrrob

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • [] I have added Critical Flows, Test Cases, and/or End-to-End Tests to cover my change. [Note: I see only 1 test file for the core feature. I tried to keep the PR as minimal as possible. If the code looks good and test cases are needed I will add the test cases. My initial thought was, big PR is difficult to get merged. Do suggest if I need to add tests. Thank you.]
  • All new and existing tests pass.

Notes:

export-csv-json-for-redirects

@nhrrob nhrrob requested review from dkotter and jeffpaul as code owners May 23, 2026 17:37
@jeffpaul jeffpaul requested a review from peterwilsoncc May 26, 2026 14:18
@jeffpaul jeffpaul added this to the 2.3.0 milestone May 26, 2026
@jeffpaul jeffpaul moved this to Code Review in Open Source Practice May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Code Review

Development

Successfully merging this pull request may close these issues.

2 participants