Repository navigation
Closes #1274: Add MCP option to Settings - #1349
Open
faisalahammad wants to merge 1 commit into
Open
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
- Add an MCP toggle next to Imagify Analytics in General Settings, shown only when the Abilities API is available (WP 6.9+) - Skip ability and category registration when MCP is disabled - Hide the MCP Adapter notice when MCP is disabled - Default to on for new installs and keep it on for existing sites through the upgrade routine - Add unit, integration and e2e tests Closes wp-media#1274
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| UnusedCode | 3 medium |
🟢 Metrics 0 complexity · 0 duplication
Metric Results Complexity 0 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #1274
Adds an "MCP" toggle in Settings > Imagify, next to Imagify Analytics. Users can now turn off the Imagify MCP abilities without deactivating anything else. When MCP is off, the
imagify/...abilities and category are not registered and the "install the MCP Adapter" notice is hidden. It is on by default, and existing sites stay on after the update, so current MCP users see no change.Type of change
Detailed scenario
What was tested
Manual (WP 6.9, valid API key):
"mcp":0, the toggle stays off after reload, and noimagify/...ability is registered.Automated:
composer test-unit: 607 tests OK.composer phpcson changed files andcomposer run-stan: clean.Tests/e2e/specs/settings.spec.ts(needsIMAGIFY_TESTS_API_KEY).How to test
wp option get imagify_settings --format=jsoncontains"mcp":0.wp eval 'print_r( array_keys( wp_get_abilities() ) );'. Noimagify/...ability is listed.imagify/...abilities are back.Affected Features & Quality Assurance Scope
classes/MCP/AbilitiesSubscriber.php).classes/MCP/AdapterNotice.php).inc/admin/upgrader.php).Technical description
Documentation
Imagify\MCP\SettingsSectionrendersviews/part-settings-mcp.phponimagify_settings_after_lossless(priority 20, after Analytics). It returns early whenwp_register_ability()does not exist.mcpinImagify_Options: default0, reset value1, sanitized as a boolean. This follows the same pattern aspartner_links: a missing key reads as the default, so a default of1would make the box impossible to turn off.mcp=0input before the checkbox, because an unchecked box is not posted._imagify_new_upgrade()setsmcpto1for sites below 2.3.6, only when the key is not stored yet. On a network-activated install the options are shared, so this does not undo a choice made after another site upgraded.AbilitiesSubscriber::register_categories()/register_abilities()andAdapterNotice::should_display()return early whenmcpis off.mcpkey is not added to the GetSettings / UpdateSettings abilities, so an MCP client cannot change it.New dependencies
None.
Risks
2.3.6as the next version. If the release number is different, the string ininc/admin/upgrader.phpmust be updated.imagify-analytics-*toggle CSS classes so both look the same. The analytics JS binds by id, so it is not affected.Mandatory Checklist
Code validation
Code style
Unticked items justification
None.
Additional Checks