Skip to content

tooling: require the plugin prefix on post types, taxonomies, shortcodes, REST routes, cron hooks and admin pages #85

Closed

Description

@schlessera

Context

Principle 13: everything public carries the plugin's prefix. architecture.prefixedNames checks hooks, options, transients, meta keys and asset handles (prefixedNames in phpstan.neon.dist, tests/php/PHPStan/Rule/PrefixedNamesRule.php). Plugins also create names in WordPress's other shared spaces, and two plugins generated from the scaffold would clash there.

Scope

Add kinds to the rule, each with prefix, constants and allowed:

Kind Functions Name
postTypes register_post_type 1st argument, and at most 20 characters
taxonomies register_taxonomy 1st argument, and at most 32 characters
shortcodes add_shortcode 1st argument
restRoutes register_rest_route namespace, the 1st argument
cron wp_schedule_event, wp_schedule_single_event, wp_next_scheduled, wp_clear_scheduled_hook, wp_unschedule_event the hook argument
adminPages add_menu_page, add_submenu_page, add_options_page, add_management_page the menu slug
settings register_setting option group and option name
ajax add_action with a first argument starting wp_ajax_ or wp_ajax_nopriv_ the rest of the action name

The lengths are WordPress limits; verify them against register_post_type() and register_taxonomy() in the installed WordPress stubs before encoding them.

Out of scope

Acceptance criteria

  • One failing and one passing fixture call per kind, with the full message asserted; a 21-character post type fails on length.
  • The catalogue table lists the new kinds and their default prefixes; composer lint is green.

Verification

composer test
composer lint

Impact on generated plugins

Tests and tool configuration only; no interface or convention generated plugins rely on changes. Settings read the plugin's namespace and prefixes from configuration, so a generated plugin keeps the check after renaming.

Activity

  1. added
    type: test
    area: tooling
    priority: p3
    agent-ready
    on Oct 23, 2026
  2. self-assigned this
    on Oct 23, 2026
  3. schlessera commented on Oct 23, 2026

    @schlessera
    MemberAuthor

    Picking this up on branch test/85-prefix-shared-names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: toolingpriority: p3type: test

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions