Skip to content

Conversation

@JasonTheAdams
Copy link
Member

@JasonTheAdams JasonTheAdams commented Nov 14, 2025

What?

Closes #25

This introduces a basic settings screen for discovering Experiments, disabling the whole thing, and enabling individual Experiments. It's simple by design, as this is just meant to be a basic starting point as we build things out.

Experiment Settings

It's possible for an experiment to render its own content within its settings card. The Abstract_Experiment class has two methods that can be overloaded: register_settings() and render_settings_fields(). In the former is when to use the WordPress register_setting function, while the latter takes echoed output and places it in the appropriate card, which can include inputs. There's a Abstract_Experiment::get_field_option_name() method for registering settings and rendering inputs, as well.

Why?

Users will need a way of toggling which Experiments they want to use, and configuring Experiment settings.

How?

This solves this as simply as possible. Later we can do things like differentiate between user-intended and dev-intended Experiments, make the UI much prettier with modern elements, and so forth.

Testing Instructions

  1. Go to Settings > AI Experiments
  2. Enable Experiments
  3. Toggle individual Experiments
  4. In the code, add Experiment settings and try rendering them

Screenshots or screencast

Global settings disabled

image

Enabled with Experiments toggled

image

Experiment with no settings but extra content

image

Experiment with unique setting (saved and persisting)

image

Test using WordPress Playground

The changes in this pull request can be previewed and tested using this WordPress Playground instance:

Click here to test this pull request.

@github-actions
Copy link

github-actions bot commented Nov 14, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: JasonTheAdams <jason_the_adams@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>
Co-authored-by: mehul0810 <mehul0810@git.wordpress.org>
Co-authored-by: mindctrl <mindctrl@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: Ref34t <mokhaled@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@JasonTheAdams JasonTheAdams self-assigned this Nov 14, 2025
@JasonTheAdams JasonTheAdams changed the title Adds basic setting screen Adds basic settings screen Nov 14, 2025
Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JasonTheAdams Looks great! A few minor points of feedback.

@jeffpaul jeffpaul added this to the 0.1.0 milestone Nov 17, 2025
Comment on lines +167 to +186
public function register_settings(): void {
// Default implementation does nothing.
// Child classes can override to register custom settings.
}

/**
* Renders experiment-specific settings fields.
*
* Override this method in child classes to render custom settings UI
* that will appear within the experiment's card on the settings page.
* This is called after the experiment's main toggle control.
*
* @since 0.1.0
*
* @return void
*/
public function render_settings_fields(): void {
// Default implementation does nothing.
// Child classes can override to render custom settings UI.
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking out loud here, not trying to seek perfection, but this made me think of the idea of Experiments providing a settings schema, via something like settings_schema(), and then having Settings_Page register and render any provided settings, so the Experiments themselves wouldn't have to handle all the registration and display logic. Would provide more consistency in rendering, and the Experiment would only need to provide the data structure.

At any rate, I really like the simplified architecture here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh for sure! I think something like that is very much worth considering. This PR is erring on the side of speed. I didn't want to make any schemas that we're committing to until we have a better idea of what we want the settings to ultimately become.

@jeffpaul
Copy link
Member

In closing out #51 in favor of this PR, let's make sure whoever makes the merge commit here that we capture the co-authored by details in the comment above as well as those credited for the effort in #51 (comment):

Unlinked contributors: mohamed.khaled@9hdigital.com.

Co-authored-by: Ref34t <mokhaled@git.wordpress.org>
Co-authored-by: mindctrl <mindctrl@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: justlevine <justlevine@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JasonTheAdams Excellent, LGTM!

@JasonTheAdams JasonTheAdams merged commit eb12ac2 into trunk Nov 18, 2025
21 checks passed
@JasonTheAdams JasonTheAdams deleted the basic-settings-screen branch November 18, 2025 01:01
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.

Create a basic admin settings screen

6 participants