Skip to content

chore: prefix rename to desktop_mode_* + Plugin Check fixes - #76

Merged
epeicher merged 4 commits into
trunkfrom
chore/phpcs-config-and-db-annotations
May 4, 2026
Merged

chore: prefix rename to desktop_mode_* + Plugin Check fixes#76
epeicher merged 4 commits into
trunkfrom
chore/phpcs-config-and-db-annotations

Conversation

@epeicher

@epeicher epeicher commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Breaking change: rename all wp_desktop_* hooks/filters (~60) and wp_register_desktop_* registration functions (3) to desktop_mode_* and desktop_mode_register_*. WordPress's reserved-prefix blocklist (wp_, wordpress_, _) cannot be overridden via PHPCS config; the rename was the only path to Plugin Check compliance.
  • Add phpcs.xml.dist declaring valid prefixes + excluding extensions/ from the parent-plugin scan (each extension is a separate plugin with its own ruleset).
  • Annotate legitimate raw $wpdb calls in includes/routines/ with caching/escape justifications.

Plugin Check impact

CleanShot 2026-05-04 at 12 56 34@2x

Report went from 207 findings → 0 real findings. The single remaining warning (missing_composer_json_file) is a false positive that only appears when scanning the source tree; it disappears against bin/package.sh-built desktop-mode.zip (which is what wp.org reviewers actually scan — composer.json is export-ignored, root vendor/ is gitignored).

Breaking change details

Before After
wp_desktop_<x> filter/action desktop_mode_<x>
wp_register_desktop_<x> function desktop_mode_register_<x>

Applied uniformly across PHP, TS, docs, and tests (39 files).

Preserved (intentionally untouched):

  • WP_DESKTOP_PRESENCE_OPTION constant (uppercase, off the regex)
  • __WP_DESKTOP_MENU_PAYLOAD__ template marker (uppercase)
  • _wp_desktop_presence DB option key (leading underscore — renaming would lose user data without a migration)
  • wp.desktop.* JS API (dot-separated, separate namespace, unaffected by the regex)

Third-party plugins that integrated against the documented wp_desktop_* filter / action names will need to update. The plugin is pre-1.0; doing this now costs less than after launch and aligns with wp.org's prefix convention going forward.

Test plan

  • npm run lint clean
  • ./node_modules/.bin/tsc --noEmit clean
  • npm run test:js clean (760/760)
  • npm run build clean
  • php -l clean across all PHP files
  • Smoke-test in wp-env: open a window, fire a routine, run a Recycle Bin restore — confirm no broken hooks
  • Re-run Plugin Check against bin/package.sh-built desktop-mode.zip and confirm 0 findings

🤖 Generated with Claude Code

Open WordPress Playground Preview

epeicher added 4 commits May 4, 2026 12:17
Add a phpcs.xml.dist at the repo root that:

  - whitelists the prefixes the codebase has used since day one
    (wp_desktop / desktop_mode / wpdc), eliminating ~96 false-positive
    NonPrefixed{Hookname,Variable,Function}Found warnings without
    renaming any documented public APIs
  - excludes /extensions/ from the parent-plugin scan since each
    extension ships as its own WP plugin with its own text domain,
    prefixes, and ruleset (cleared the remaining ~50 false positives
    that come from scanning extension internals against the parent's
    text domain)
  - sets the text-domain to "desktop-mode" so I18n checks have a
    canonical reference

Annotate the legitimate raw-DB calls on the routines runs table with
phpcs:ignore + justifications:

  - run-history.php: $wpdb->insert / get_results / query on the custom
    routine_runs table — table name interpolation is safe (built from
    $wpdb->prefix + a constant), caching deliberately skipped because
    the rows are a write-heavy log and a real-time tail
  - executor.php: rate-limit count query — fresh count every call by
    design

Annotate the slow_db_query_meta_{key,value} false positives in
seed.php where the literal strings appear as field names in an
args_schema declaration / a result envelope, not as DB-query
arguments.

After this commit the report drops from ~207 issues to a small
handful that all live inside extensions/ and disappear when each
extension is scanned independently.
…mode_*

Plugin Check's WordPress.NamingConventions.PrefixAllGlobals rule
hard-codes a blocklist of reserved prefixes (`wp_`, `wordpress_`, `_`)
that no plugin's `prefixes` allowlist can override. The codebase had
~60 hooks/filters and 3 registration functions using `wp_desktop_*`
and `wp_register_desktop_*`, all flagged by Plugin Check.

This is a breaking change to the public API — third-party plugins
that integrated against the documented `wp_desktop_*` filter / action
names need to update. The plugin is pre-1.0; doing the rename now
costs less than after launch, and it aligns with wp.org's prefix
convention going forward.

Renames applied uniformly across PHP / TS / docs / tests:

  wp_desktop_<X>          → desktop_mode_<X>
  wp_register_desktop_<X> → desktop_mode_register_<X>

Preserved (intentionally untouched, do not collide with the regex):

  WP_DESKTOP_PRESENCE_OPTION (constant — uppercase)
  __WP_DESKTOP_MENU_PAYLOAD__ (template marker — uppercase)
  _wp_desktop_presence       (DB option key — leading underscore)
  wp.desktop.*               (JS API — dot-separated, not underscore)

39 files touched: 18 PHP, 4 TS, 12 docs, 5 tests, 1 phpcs config,
plus 2 regenerated bundles under assets/js/. All checks pass —
lint, tsc --noEmit, vitest (760/760), php -l, npm run build.

Also drops the now-redundant `wp_desktop` / `wp-desktop` entries from
phpcs.xml.dist's prefix allowlist (no callsites remain).
Plugin Check flags `phpcs.xml.dist` as `application_detected` (severity
8 ERROR) when it appears in the plugin zip. It's dev tooling — same
class as `composer.json`, `package.json`, `vite.config.js`, and friends
that already live under the export-ignore list.

I forgot to add this line when introducing phpcs.xml.dist; this commit
closes the gap. Verified via `git archive --worktree-attributes HEAD`
that the file is now excluded from `bin/package.sh`-built zips.
…nd-db-annotations

# Conflicts:
#	assets/js/routines.js
#	assets/js/routines.min.js
#	docs/README.md
#	docs/examples/register-routine-trigger.md
#	docs/hooks-reference.md
#	docs/routines-roadmap.md
#	docs/routines.md
#	includes/routines/ai-generate.php
#	includes/routines/api.php
#	includes/routines/bootstrap.php
#	includes/routines/cpt.php
#	includes/routines/executor.php
#	includes/routines/run-history.php
#	includes/routines/schema.php
#	includes/routines/seed.php
#	includes/routines/steps.php
#	includes/routines/triggers.php
#	includes/routines/window.php
#	src/routines/inspector.ts
#	src/routines/picker.ts
#	tests/phpunit/tests/routines.php
@epeicher epeicher self-assigned this May 4, 2026
@epeicher
epeicher merged commit 60ceeb5 into trunk May 4, 2026
7 checks passed
@epeicher
epeicher deleted the chore/phpcs-config-and-db-annotations branch May 4, 2026 11:21
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.

1 participant