Skip to content

Refactor and simplify plugin to reduce code size and improve structure #31

@lex127

Description

@lex127

Goal

The plugin currently has about 2,000 lines of code. A lot of it is hard to follow and change safely:

  • webspellchecker.php is a 798-line class with 18+ mixed responsibilities (bootstrap, context detection, enqueue, AJAX, content cleanup, config builder, etc.).
  • should_enable_in_context() is 116 lines with 41 conditionals and the same arrays of screen IDs repeated three times.
  • A 620-line vendored Settings API (WeDevs) ships inside vendor/ and contains a deprecated create_function() call — see Fix deprecated create_function() call (fatal on PHP 8.0+) #30.
  • Service endpoints (svc.webspellchecker.net, spellcheck31/api, the bundle URL) are hard-coded in five places across PHP and JS. On-premises customers cannot point the plugin at a private WSC instance without editing the source.
  • Content cleanup runs a regex over HTML with a length-ratio safety check — fragile.
  • Four JavaScript files with duplicated constants and no module structure.

Plan

  • 6–8 small classes with a single responsibility each.

Non-goals

  • No new features.
  • No PHP version bump (stays 7.4).
  • No Composer, no React admin page, no build step for PHP.
  • No breaking changes to the wsc_proofreader option or public filter names.

Related

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions