Skip to content

Conversation

@Ref34t
Copy link
Contributor

@Ref34t Ref34t commented Oct 26, 2025

Summary

Builds a complete admin settings screen with React UI for managing AI experimental features.

Key Components

  • Admin Settings Page - React-based UI using WordPress components
  • Settings Toggle - Global on/off switch for experimental features
  • Feature Toggles - Per-feature enable/disable functionality
  • Settings Registry - Allows features to register their own settings sections
  • Settings Service - Coordinates all settings components
  • REST API - Backend data layer for settings persistence

Architecture

  • Direct instantiation in bootstrap
  • Filter-based dependency injection for Feature_Toggles service
  • Features receive Settings_Registry as parameter
  • Render callbacks accept Settings_Toggle directly

Feature Development Pattern

Features extend Abstract_Feature and follow these rules:

  1. Implement load_feature_metadata() returning id, label, description
  2. Always register settings sections via ai_register_settings_sections hook
  3. Check is_enabled() before registering functional hooks
  4. Pass services as parameters
  5. Use Provides_Settings_Section trait for settings panels

See Example_Feature for complete reference implementation.

Files Added

  • Admin settings infrastructure (9 PHP classes)
  • React/TypeScript UI (src/ directory)
  • Feature settings trait (Provides_Settings_Section)
  • Comprehensive test suite

Resolves #25

@github-actions
Copy link

github-actions bot commented Oct 26, 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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @[email protected].

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: [email protected].

Co-authored-by: Ref34t <[email protected]>
Co-authored-by: mindctrl <[email protected]>
Co-authored-by: dkotter <[email protected]>
Co-authored-by: jeffpaul <[email protected]>
Co-authored-by: justlevine <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: felixarntz <[email protected]>

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

@Ref34t Ref34t changed the title Admin Settings Screen Implementation WIP: Admin Settings Screen Implementation Oct 27, 2025
@jeffpaul jeffpaul marked this pull request as draft October 27, 2025 19:11
@jeffpaul jeffpaul added this to the 0.1.0 milestone Oct 27, 2025
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 64.54918% with 173 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.13%. Comparing base (7e9c935) to head (c7975e9).
⚠️ Report is 6 commits behind head on trunk.

Files with missing lines Patch % Lines
includes/Asset_Loader.php 0.00% 34 Missing ⚠️
includes/Admin/Admin_Settings_Page.php 75.22% 28 Missing ⚠️
includes/Admin/Settings/Feature_Toggles.php 53.84% 24 Missing ⚠️
includes/Admin/Settings/Settings_Section.php 37.14% 22 Missing ⚠️
includes/bootstrap.php 31.03% 20 Missing ⚠️
...des/Features/Title_Generation/Title_Generation.php 45.83% 13 Missing ⚠️
includes/Feature_Loader.php 63.33% 11 Missing ⚠️
...udes/Features/Traits/Provides_Settings_Section.php 81.48% 10 Missing ⚠️
includes/Abstracts/Abstract_Feature.php 76.92% 6 Missing ⚠️
includes/Admin/Settings/Settings_Toggle.php 91.30% 4 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk      #51      +/-   ##
============================================
+ Coverage     60.94%   64.13%   +3.19%     
- Complexity       81      185     +104     
============================================
  Files            10       17       +7     
  Lines           425      870     +445     
============================================
+ Hits            259      558     +299     
- Misses          166      312     +146     
Flag Coverage Δ
unit 64.13% <64.54%> (+3.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ref34t Ref34t force-pushed the feature/admin-settings-screen-issue-25 branch from 5d3ada5 to 72b4e56 Compare November 2, 2025 14:42
@Ref34t Ref34t marked this pull request as ready for review November 2, 2025 14:54
@jeffpaul jeffpaul changed the title WIP: Admin Settings Screen Implementation Admin Settings Screen Implementation Nov 2, 2025
@jeffpaul jeffpaul requested a review from dkotter November 2, 2025 16:35
{section.description}
</p>
) : null}
</div>
Copy link
Contributor

@mindctrl mindctrl Nov 10, 2025

Choose a reason for hiding this comment

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

Just noting that the design of these controls doesn't allow for long descriptions that might detail requirements, have an HTML list of items, or anything HTML.

Screenshot
Image

The fallback method allows for much more control over what is displayed. Looking at the Content Translator demo in the screenshot... without JS, using the render_settings_section() fallback way, you would be able to do something like this example code to explain what the feature does:

		<p>
			<?php esc_html_e( 'When enabled, this feature provides a block that allows site visitors to translate page content into multiple languages using AI.', 'jp-wp-ai' ); ?>
		</p>
		<p>
			<strong><?php esc_html_e( 'Supported Languages:', 'jp-wp-ai' ); ?></strong>
		</p>
		<ul style="list-style: disc; margin-left: 20px;">
			<?php foreach ( self::SUPPORTED_LANGUAGES as $name ) : ?>
				<li><?php echo esc_html( $name ); ?></li>
			<?php endforeach; ?>
		</ul>
		<p>
			<em><?php esc_html_e( 'Add the Content Translator block to any post or page to enable front-end translation.', 'jp-wp-ai' ); ?></em>
		</p>

I can actually see it flash quickly before the React app overwrites the screen. As far as I can tell, it's not possible to do any extended description with the existing React app in its current state.

I think any experiment more than an example is going to need more space to explain things.

@jeffpaul
Copy link
Member

@Jameswlepage @JasonTheAdams @felixarntz @swissspidy @dkotter with #61 resolved and merged in, getting y'alls input / reviews / approvals on this PR will help unblock feature development in the plugin; so if you would please chime in here that would be great, thanks!

@jeffpaul
Copy link
Member

@Ref34t note there are some merge conflicts to review, likely as a result of #61 getting merged in

@swissspidy
Copy link
Member

Screenshot 2025-11-13 at 22 18 31

This... is a huge amount of code for something as simple as a settings page 😳 At first glance there's a ton of unused boilerplate code with methods that aren't used except in tests, or reimplement existing core functions such as rest_sanitize_boolean. I'd ask an agent to simplify this and then perhaps let Copilot do the initial round of review.

Mohamed Khaled added 9 commits November 14, 2025 11:55
…e-25

# Conflicts:
#	includes/Abstracts/Abstract_Feature.php
#	includes/Feature_Loader.php
#	includes/Features/Example_Feature/Example_Feature.php
#	package-lock.json
#	package.json
- Change register() to register_enabled_hooks() to avoid overriding final method
- Implement required abstract method register_enabled_hooks()
- Ensures Title_Generation follows the feature lifecycle pattern
@Ref34t
Copy link
Contributor Author

Ref34t commented Nov 14, 2025

Streamlined and refractored the boilerplate to minimize the size of the PR without losing any functionality, also resolved merge conflicts


## Architecture Overview

The plugin follows a modular, feature-based architecture:
Copy link
Contributor

Choose a reason for hiding this comment

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

why replace the tree?

@JasonTheAdams
Copy link
Member

JasonTheAdams commented Nov 17, 2025

I'm going to close this PR in favor of #84. This PR does a good job of going after a formal settings registration system, but we're simply not at the point where something like this is necessary. We need something really simple right now that we can improve on later, as we get a clearer sense of what we want the settings to become.

Thank you for your effort on this, @Ref34t! It's sincerely appreciated and helped prod the conversation.

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

7 participants