feat: add settings import/export functionality#734
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
The failing JavaScript quality check is due to a conflict between eslint and typescript. While eslint prefers dot notation, typescript complains about it (TS4111). Should I suppress the eslint error? |
We do have a number of these that we already ignore with inline statements so I think that's fine |
…to feature/import-export-config
dkotter
left a comment
There was a problem hiding this comment.
Overall this looks really good, left a few comments. In addition, an E2E test here would be nice to verify the import/export options are available
| ), | ||
| 'description' => sprintf( | ||
| '<p>%s</p>', | ||
| __( 'At least one AI connector has credentials configured and is ready to use.', 'ai' ) |
There was a problem hiding this comment.
So this isn't entirely accurate. The has_ai_credentials function will tell us if a Provider has credentials set but doesn't tell us if the credentials are valid. We do have a new is_connector_configured function that we could use here instead
| content: string; | ||
| } | ||
|
|
||
| /** Shape of an AI settings export payload (matches the PHP schema). */ |
There was a problem hiding this comment.
So this file is already really large so if we can extract out any of these new functions into individual component or hook files, that would be great
| * | ||
| * @var list<string> | ||
| */ | ||
| private const SENSITIVE_PATTERNS = array( 'api_key', 'token', 'secret', 'credential', 'password', 'auth' ); // phpcs:ignore SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition |
There was a problem hiding this comment.
Worth adding just key to this list?
There was a problem hiding this comment.
Also risk here if there's a setting named author, I think that gets matched due to auth
| continue; | ||
| } | ||
|
|
||
| update_option( $option_name, $value ); |
There was a problem hiding this comment.
Slight risk here since we don't run any sort of validation or sanitization
There was a problem hiding this comment.
And would be nice to capture this in a test, ensuring if someone passes in data that is the wrong type (i.e. we expect a boolean for a certain field and someone passes in string) that the data is either sanitized properly or rejected
| ( new Dashboard_Widgets( $registry ) )->init(); | ||
| } | ||
|
|
||
| // Register Site Health integration (always, not just in admin). |
There was a problem hiding this comment.
Does this need to load everywhere or could we scope this to the admin only?
|
Thanks @dkotter for reviewing this. I will work on the feedback over the days and request a review again. |
What?
Closes #191
This PR implements the ability to export and import non-sensitive AI configuration settings and introduces a dedicated AI section in WordPress Site Health.
Why?
Allowing users to move AI configurations between environments (e.g., staging to production, multi-site etc.) improves the developer experience. By excluding sensitive credentials from the export, we ensure security while maintaining portability. The Site Health integration provides administrators with a quick overview of the plugin's status and credential health.
How?
includes/REST/Settings_IO_Controller.phpto handleGET /ai/v1/settings/exportandPOST /ai/v1/settings/import.SENSITIVE_PATTERNSfiltering to ensure API keys, tokens, and secrets are never exported or overwritten during import.includes/Admin/Site_Health.phpto provide debug information (version, enabled features, credential status) and a status test for connectivity.routes/ai-home/stage.tsx.tests/Integration/Includes/REST/Settings_IO_ControllerTest.phpandtests/Integration/Includes/Admin/Site_HealthTest.php.Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Sonnet 4.6, GPT-4o
Used for: Authoring the codebase exploration, UI components, and the integration test suite.
Testing Instructions
Screenshots or screencast
Menu Items:

Confirmation prompt before completing import:

Changelog Entry