Multisite, Settings: Prevent saving an empty site title or network title via admin screens - #12706
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Pull request overview
This PR prevents administrators from saving an empty Site Title (blogname) or Network Title (site_name) through the relevant admin screens, aligning edit behavior with creation-time requirements (notably in Multisite).
Changes:
- Add server-side validation in
sanitize_option()to reject empty/whitespace-onlyblognameupdates (retaining the stored value and registering a settings error). - Mark Site Title / Network Title inputs as required in the General Settings and Network Settings forms.
- In Multisite site settings, carry
sanitize_option()settings errors across the redirect to display an error notice instead of a success message.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/wp-includes/formatting.php | Rejects empty Site Title updates during option sanitization and registers a settings error. |
| src/wp-admin/options-general.php | Marks “Site Title” as a required field in the General Settings UI. |
| src/wp-admin/network/site-settings.php | Persists settings errors across redirect and displays error notices when site options aren’t saved. |
| src/wp-admin/network/settings.php | Prevents saving an empty Network Title, shows an error notice, and marks the field as required. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/wp-includes/formatting.php:5003
- This change introduces new behavior for
sanitize_option( 'blogname', ... )(rejecting empty/whitespace-only values and registering a settings error), but there’s no PHPUnit coverage asserting the new validation and the expectedget_settings_errors( 'blogname' )result. Adding a unit test will help prevent regressions in both the returned value (should remain the previously stored option) and the presence/content of the settings error.
// The site title (blogname) cannot be empty.
if ( 'blogname' === $option && '' === trim( $value ) ) {
$error = __( 'The site title cannot be empty. Please enter a title for your site.' );
}
Trac ticket: https://core.trac.wordpress.org/ticket/65718