Make WordPress Core


Ignore:
Timestamp:
02/09/2026 04:59:52 PM (2 months ago)
Author:
jorgefilipecosta
Message:

Abilities API: Allow nested namespace ability names (2-4 segments).

Expand ability name validation from exactly 2 segments (namespace/ability) to 2-4 segments, enabling names like my-plugin/resource/find and my-plugin/resource/sub/find.
This allows plugins to organize abilities into logical resource groups. The validation regex changes from /^[a-z0-9-]+\/[a-z0-9-]+$/ to /^[a-z0-9-]+(?:\/[a-z0-9-]+){1,3}$/, which accepts the first segment plus 1-3 additional slash-delimited segments.
Updates the validation regex, error messages, docblocks, and adds corresponding unit and REST API tests.

Props jorgefilipecosta, justlevine, jorbin.
Fixes #64596.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/abilities-api/class-wp-ability.php

    r61505 r61602  
    5353    /**
    5454     * The name of the ability, with its namespace.
    55      * Example: `my-plugin/my-ability`.
     55     * Examples: `my-plugin/my-ability`, `my-plugin/resource/find`.
    5656     *
    5757     * @since 6.9.0
     
    341341    /**
    342342     * Retrieves the name of the ability, with its namespace.
    343      * Example: `my-plugin/my-ability`.
     343     * Examples: `my-plugin/my-ability`, `my-plugin/resource/find`.
    344344     *
    345345     * @since 6.9.0
Note: See TracChangeset for help on using the changeset viewer.