Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/wp-includes/abilities-api/class-wp-abilities-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ final class WP_Abilities_Registry {
* @return WP_Ability|null The registered ability instance on success, null on failure.
*/
public function register( string $name, array $args ): ?WP_Ability {
if ( ! preg_match( '/^[a-z0-9-]+\/[a-z0-9-]+$/', $name ) ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is extracted in a different PR, and is a temporary just for testing.

if ( ! preg_match( '/^[a-z0-9-]+(?:\/[a-z0-9-]+)+$/', $name ) ) {
_doing_it_wrong(
__METHOD__,
__(
'Ability name must be a string containing a namespace prefix, i.e. "my-plugin/my-ability". It can only contain lowercase alphanumeric characters, dashes and the forward slash.'
'Ability name must be a string containing a namespace prefix, e.g. "my-plugin/my-ability" or "my-plugin/my-namespace/my-ability". It can only contain lowercase alphanumeric characters, dashes and forward slashes as separators.'
),
'6.9.0'
);
Expand Down
12 changes: 12 additions & 0 deletions src/wp-includes/abilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

declare( strict_types = 1 );

require_once __DIR__ . '/abilities/class-wp-post-type-abilities.php';

/**
* Registers the core ability categories.
*
Expand All @@ -32,6 +34,14 @@ function wp_register_core_ability_categories(): void {
'description' => __( 'Abilities that retrieve or modify user information and settings.' ),
)
);

wp_register_ability_category(
'post',
array(
'label' => __( 'Post' ),
'description' => __( 'Abilities related to the creation and management of posts of all types.' ),
)
);
}

/**
Expand Down Expand Up @@ -259,4 +269,6 @@ function wp_register_core_abilities(): void {
),
)
);

WP_Post_Type_Abilities::register();
}
Loading
Loading