Skip to content

Add link, Heartbeat, pattern directory, and AI support settings - #186

Merged
PDowney merged 2 commits into
mainfrom
extra-cleanup-options
Nov 28, 2026
Merged

PDowney merged 2 commits into
mainfrom
extra-cleanup-options

Conversation

@PDowney

@PDowney PDowney commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Six new settings. Each one shows the three-part help text from #185: what it does, its effect on the site, and its performance gain or cost.

Setting Section Mechanism
Remove REST API Link Header Cleanup Removes rest_output_link_wp_head (wp_head, 10) and rest_output_link_header (template_redirect, 11). The REST API keeps working.
Remove oEmbed Discovery Links Header Cleanup Removes wp_oembed_add_discovery_links at both priorities core uses, 4 and 10.
Remove Feed Links Header Cleanup Removes feed_links (2) and feed_links_extra (3). The feeds keep working.
Limit Heartbeat Performance Front end: wp_deregister_script( 'heartbeat' ) on wp_enqueue_scripts at priority 100. Admin: heartbeat_settings sets 120 seconds, except on post.php, post-new.php, site-editor.php and customize.php. A slower interval set by another plugin is kept.
Disable Pattern Directory Patterns Performance should_load_remote_block_patterns returns false (PHP_INT_MAX).
Disable WordPress AI Support Additional Features wp_supports_ai returns false (PHP_INT_MAX). Core reads it from init on, when it sets up its connectors.

The new filters follow the plugin's existing pattern: they return the incoming value unchanged when their option is off. Header removals now come from one table, es_optimizer_get_header_removals(). The existing options remove exactly what they removed before, and the unit tests check that.

All of this was checked against WordPress 7.0 and 7.1.5 core:

  • Core's Heartbeat default is already 60 seconds, and 120 seconds in a hidden tab, so the admin setting uses 120.
  • adjacent_posts_rel_link_wp_head() has been "No longer used in core" since 5.6, so no option was added for it.

Testing

  • composer check-all passes: PHPCS, PHPMD, Psalm and its taint analysis, PHPStan, Rector, and PHPUnit with 181 tests and 823 assertions. The new unit tests cover:
    • each removal with its priority;
    • both filters with their options on, off, and given a foreign value;
    • Heartbeat on the front end and in the admin area, including the editors, a slower foreign interval, and a non-array value;
    • the wiring.
  • Two new tests in the workflow-generated WordPress suite:
    • the removals match core's own registrations, priorities included, and the REST API stays;
    • the pattern, AI, and Heartbeat settings act through core's APIs.
  • On a disposable WordPress 7.1.5 site, with every new option off and then on:
    • REST link in the head, 1 → 0; REST Link header, 1 → 0; oEmbed links, 2 → 0; feed links, 3 → 0;
    • front-end Heartbeat, loaded by a test plugin, 4 → 0;
    • wp_supports_ai(), true → false; the pattern filter, true → false;
    • the feed and the REST API still answer with HTTP 200.
  • In a browser, the Heartbeat interval is 120 on the dashboard and the posts list, and stays at core's 60 in the post editor.
  • The settings page checks from Toggle settings only with the checkbox; explain each setting #185, now with 17 checkboxes, pass in Chromium, Firefox, and WebKit:
    • only the checkbox toggles a setting;
    • each checkbox is named by its title and described by its help;
    • axe-core finds 0 violations.
  • The Markdown lint, codespell, Plugin Check's PHPCS rulesets, the CI VIP ruleset, actionlint, yamllint, zizmor, and msgfmt -c on the regenerated POT (138 strings) are clean. gitleaks finds no leaks.

The changelog entries are under "Unreleased", and the README and readme.txt feature lists are updated.

🤖 Generated with Claude Code

Six new settings, each with the three-part help text:

- Remove REST API Link: the API address in the page head and the Link
  response header. The REST API keeps working.
- Remove oEmbed Discovery Links: removed at both priorities WordPress
  adds them (4 and 10).
- Remove Feed Links: the feed discovery links in the page head. The
  feeds keep working.
- Limit Heartbeat: deregistered on the front end; every 120 seconds
  instead of core's 60 on admin screens, except the post editor, the
  site editor, and the Customizer. A slower interval is kept.
- Disable Pattern Directory Patterns: should_load_remote_block_patterns.
- Disable WordPress AI Support: wp_supports_ai, read from init on.

The header removals are now one table, so each option lists the hook,
callback, and priority it removes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 19 complexity · 0 duplication

Metric Results
Complexity 19
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.24% coverage variation

Metric Results
Coverage variation ✅ +0.24% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d145c95) 900 870 96.67%
Head commit (58eef03) 971 (+71) 941 (+71) 96.91% (+0.24%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#186) 80 80 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

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.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to EngineScript Site Optimizer!

Before we review:

  • Have you tested your changes with WordPress 7.0+?
  • Are your changes compatible with PHP 8.3+?
  • Have you followed WordPress coding standards?
  • Did you update the CHANGELOG.md if needed?

Security Reminder
This plugin stores per-site settings and emits browser resource hints, so please ensure:

  • All user input is properly sanitized
  • All output is properly escaped
  • No security vulnerabilities are introduced

We'll review your PR soon.

The generated test_native_bootstrap_mode_and_optimizer_hooks still expected 13 fields and 11 on/off options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PDowney
PDowney merged commit d9e3fbd into main Nov 28, 2026
26 checks passed
@github-actions
github-actions Bot deleted the extra-cleanup-options branch November 28, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant