Skip to content

Commit ff227c6

Browse files
committed
Use consistently ability category/categories
1 parent 7f6911c commit ff227c6

13 files changed

+157
-157
lines changed

src/wp-includes/abilities-api.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @type string $label The human-readable label for the ability.
3030
* @type string $description A detailed description of what the ability does.
31-
* @type string $category The category slug this ability belongs to.
31+
* @type string $category The ability category slug this ability belongs to.
3232
* @type callable $execute_callback A callback function to execute when the ability is invoked.
3333
* Receives optional mixed input and returns mixed result or WP_Error.
3434
* @type callable $permission_callback A callback function to check permissions before execution.
@@ -109,60 +109,60 @@ function wp_get_abilities(): array {
109109
*
110110
* @since 6.9.0
111111
*
112-
* @see WP_Abilities_Category_Registry::register()
112+
* @see WP_Ability_Categories_Registry::register()
113113
*
114-
* @param string $slug The unique slug for the category. Must contain only lowercase
114+
* @param string $slug The unique slug for the ability category. Must contain only lowercase
115115
* alphanumeric characters and dashes.
116116
* @param array<string, mixed> $args {
117-
* An associative array of arguments for the category.
117+
* An associative array of arguments for the ability category.
118118
*
119-
* @type string $label The human-readable label for the category.
120-
* @type string $description A description of the category.
121-
* @type array<string, mixed> $meta Optional. Additional metadata for the category.
119+
* @type string $label The human-readable label for the ability category.
120+
* @type string $description A description of the ability category.
121+
* @type array<string, mixed> $meta Optional. Additional metadata for the ability category.
122122
* }
123-
* @return WP_Ability_Category|null The registered category instance on success, null on failure.
123+
* @return WP_Ability_Category|null The registered ability category instance on success, null on failure.
124124
*/
125125
function wp_register_ability_category( string $slug, array $args ): ?WP_Ability_Category {
126-
return WP_Abilities_Category_Registry::get_instance()->register( $slug, $args );
126+
return WP_Ability_Categories_Registry::get_instance()->register( $slug, $args );
127127
}
128128

129129
/**
130130
* Unregisters an ability category.
131131
*
132132
* @since 6.9.0
133133
*
134-
* @see WP_Abilities_Category_Registry::unregister()
134+
* @see WP_Ability_Categories_Registry::unregister()
135135
*
136-
* @param string $slug The slug of the registered category.
137-
* @return WP_Ability_Category|null The unregistered category instance on success, null on failure.
136+
* @param string $slug The slug of the registered ability category.
137+
* @return WP_Ability_Category|null The unregistered ability category instance on success, null on failure.
138138
*/
139139
function wp_unregister_ability_category( string $slug ): ?WP_Ability_Category {
140-
return WP_Abilities_Category_Registry::get_instance()->unregister( $slug );
140+
return WP_Ability_Categories_Registry::get_instance()->unregister( $slug );
141141
}
142142

143143
/**
144144
* Retrieves a registered ability category.
145145
*
146146
* @since 6.9.0
147147
*
148-
* @see WP_Abilities_Category_Registry::get_registered()
148+
* @see WP_Ability_Categories_Registry::get_registered()
149149
*
150-
* @param string $slug The slug of the registered category.
151-
* @return WP_Ability_Category|null The registered category instance, or null if it is not registered.
150+
* @param string $slug The slug of the registered ability category.
151+
* @return WP_Ability_Category|null The registered ability category instance, or null if it is not registered.
152152
*/
153153
function wp_get_ability_category( string $slug ): ?WP_Ability_Category {
154-
return WP_Abilities_Category_Registry::get_instance()->get_registered( $slug );
154+
return WP_Ability_Categories_Registry::get_instance()->get_registered( $slug );
155155
}
156156

157157
/**
158158
* Retrieves all registered ability categories.
159159
*
160160
* @since 6.9.0
161161
*
162-
* @see WP_Abilities_Category_Registry::get_all_registered()
162+
* @see WP_Ability_Categories_Registry::get_all_registered()
163163
*
164-
* @return WP_Ability_Category[] The array of registered categories.
164+
* @return WP_Ability_Category[] The array of registered ability categories.
165165
*/
166166
function wp_get_ability_categories(): array {
167-
return WP_Abilities_Category_Registry::get_instance()->get_all_registered();
167+
return WP_Ability_Categories_Registry::get_instance()->get_all_registered();
168168
}

src/wp-includes/abilities-api/class-wp-abilities-registry.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ final class WP_Abilities_Registry {
5151
*
5252
* @type string $label The human-readable label for the ability.
5353
* @type string $description A detailed description of what the ability does.
54-
* @type string $category The category slug this ability belongs to.
54+
* @type string $category The ability category slug this ability belongs to.
5555
* @type callable $execute_callback A callback function to execute when the ability is invoked.
5656
* Receives optional mixed input and returns mixed result or WP_Error.
5757
* @type callable $permission_callback A callback function to check permissions before execution.
@@ -100,7 +100,7 @@ public function register( string $name, array $args ): ?WP_Ability {
100100
*
101101
* @type string $label The human-readable label for the ability.
102102
* @type string $description A detailed description of what the ability does.
103-
* @type string $category The category slug this ability belongs to.
103+
* @type string $category The ability category slug this ability belongs to.
104104
* @type callable $execute_callback A callback function to execute when the ability is invoked.
105105
* Receives optional mixed input and returns mixed result or WP_Error.
106106
* @type callable $permission_callback A callback function to check permissions before execution.
@@ -119,9 +119,9 @@ public function register( string $name, array $args ): ?WP_Ability {
119119
*/
120120
$args = apply_filters( 'wp_register_ability_args', $args, $name );
121121

122-
// Validate category exists if provided (will be validated as required in WP_Ability).
122+
// Validate ability category exists if provided (will be validated as required in WP_Ability).
123123
if ( isset( $args['category'] ) ) {
124-
$category_registry = WP_Abilities_Category_Registry::get_instance();
124+
$category_registry = WP_Ability_Categories_Registry::get_instance();
125125
if ( ! $category_registry->is_registered( $args['category'] ) ) {
126126
_doing_it_wrong(
127127
__METHOD__,
@@ -261,9 +261,9 @@ public static function get_instance(): self {
261261
if ( null === self::$instance ) {
262262
self::$instance = new self();
263263

264-
// Ensure category registry is initialized first to allow categories to be registered
264+
// Ensure ability category registry is initialized first to allow categories to be registered
265265
// before abilities that depend on them.
266-
WP_Abilities_Category_Registry::get_instance();
266+
WP_Ability_Categories_Registry::get_instance();
267267

268268
/**
269269
* Fires when preparing abilities registry.

src/wp-includes/abilities-api/class-wp-abilities-category-registry.php renamed to src/wp-includes/abilities-api/class-wp-ability-categories-registry.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Abilities API
44
*
5-
* Defines WP_Abilities_Category_Registry class.
5+
* Defines WP_Ability_Categories_Registry class.
66
*
77
* @package WordPress
88
* @subpackage Abilities API
@@ -17,7 +17,7 @@
1717
* @since 6.9.0
1818
* @access private
1919
*/
20-
final class WP_Abilities_Category_Registry {
20+
final class WP_Ability_Categories_Registry {
2121
/**
2222
* The singleton instance of the registry.
2323
*
@@ -27,40 +27,40 @@ final class WP_Abilities_Category_Registry {
2727
private static $instance = null;
2828

2929
/**
30-
* Holds the registered categories.
30+
* Holds the registered ability categories.
3131
*
3232
* @since 6.9.0
3333
* @var WP_Ability_Category[]
3434
*/
3535
private $registered_categories = array();
3636

3737
/**
38-
* Registers a new category.
38+
* Registers a new ability category.
3939
*
4040
* Do not use this method directly. Instead, use the `wp_register_ability_category()` function.
4141
*
4242
* @since 6.9.0
4343
*
4444
* @see wp_register_ability_category()
4545
*
46-
* @param string $slug The unique slug for the category. Must contain only lowercase
46+
* @param string $slug The unique slug for the ability category. Must contain only lowercase
4747
* alphanumeric characters and dashes.
4848
* @param array<string, mixed> $args {
49-
* An associative array of arguments for the category.
49+
* An associative array of arguments for the ability category.
5050
*
51-
* @type string $label The human-readable label for the category.
52-
* @type string $description A description of the category.
53-
* @type array<string, mixed> $meta Optional. Additional metadata for the category.
51+
* @type string $label The human-readable label for the ability category.
52+
* @type string $description A description of the ability category.
53+
* @type array<string, mixed> $meta Optional. Additional metadata for the ability category.
5454
* }
55-
* @return WP_Ability_Category|null The registered category instance on success, null on failure.
55+
* @return WP_Ability_Category|null The registered ability category instance on success, null on failure.
5656
*/
5757
public function register( string $slug, array $args ): ?WP_Ability_Category {
5858
if ( ! doing_action( 'wp_abilities_api_categories_init' ) ) {
5959
_doing_it_wrong(
6060
__METHOD__,
6161
sprintf(
62-
/* translators: 1: abilities_api_categories_init, 2: category slug. */
63-
__( 'Categories must be registered during the %1$s action. The category %2$s was not registered.' ),
62+
/* translators: 1: abilities_api_categories_init, 2: ability category slug. */
63+
__( 'Ability categories must be registered during the %1$s action. The category %2$s was not registered.' ),
6464
'<code>wp_abilities_api_categories_init</code>',
6565
'<code>' . esc_html( $slug ) . '</code>'
6666
),
@@ -72,8 +72,8 @@ public function register( string $slug, array $args ): ?WP_Ability_Category {
7272
if ( $this->is_registered( $slug ) ) {
7373
_doing_it_wrong(
7474
__METHOD__,
75-
/* translators: %s: Category slug. */
76-
sprintf( __( 'Category "%s" is already registered.' ), esc_html( $slug ) ),
75+
/* translators: %s: Ability category slug. */
76+
sprintf( __( 'Ability category "%s" is already registered.' ), esc_html( $slug ) ),
7777
'6.9.0'
7878
);
7979
return null;
@@ -82,25 +82,25 @@ public function register( string $slug, array $args ): ?WP_Ability_Category {
8282
if ( ! preg_match( '/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $slug ) ) {
8383
_doing_it_wrong(
8484
__METHOD__,
85-
__( 'Category slug must contain only lowercase alphanumeric characters and dashes.' ),
85+
__( 'Ability category slug must contain only lowercase alphanumeric characters and dashes.' ),
8686
'6.9.0'
8787
);
8888
return null;
8989
}
9090

9191
/**
92-
* Filters the category arguments before they are validated and used to instantiate the category.
92+
* Filters the ability category arguments before they are validated and used to instantiate the ability category.
9393
*
9494
* @since 6.9.0
9595
*
9696
* @param array<string, mixed> $args {
97-
* The arguments used to instantiate the category.
97+
* The arguments used to instantiate the ability category.
9898
*
99-
* @type string $label The human-readable label for the category.
100-
* @type string $description A description of the category.
101-
* @type array<string, mixed> $meta Optional. Additional metadata for the category.
99+
* @type string $label The human-readable label for the ability category.
100+
* @type string $description A description of the ability category.
101+
* @type array<string, mixed> $meta Optional. Additional metadata for the ability category.
102102
* }
103-
* @param string $slug The slug of the category.
103+
* @param string $slug The slug of the ability category.
104104
*/
105105
$args = apply_filters( 'wp_register_ability_category_args', $args, $slug );
106106

@@ -121,16 +121,16 @@ public function register( string $slug, array $args ): ?WP_Ability_Category {
121121
}
122122

123123
/**
124-
* Unregisters a category.
124+
* Unregisters a ability category.
125125
*
126126
* Do not use this method directly. Instead, use the `wp_unregister_ability_category()` function.
127127
*
128128
* @since 6.9.0
129129
*
130130
* @see wp_unregister_ability_category()
131131
*
132-
* @param string $slug The slug of the registered category.
133-
* @return WP_Ability_Category|null The unregistered category instance on success, null on failure.
132+
* @param string $slug The slug of the registered ability category.
133+
* @return WP_Ability_Category|null The unregistered ability category instance on success, null on failure.
134134
*/
135135
public function unregister( string $slug ): ?WP_Ability_Category {
136136
if ( ! $this->is_registered( $slug ) ) {
@@ -150,43 +150,43 @@ public function unregister( string $slug ): ?WP_Ability_Category {
150150
}
151151

152152
/**
153-
* Retrieves the list of all registered categories.
153+
* Retrieves the list of all registered ability categories.
154154
*
155155
* Do not use this method directly. Instead, use the `wp_get_ability_categories()` function.
156156
*
157157
* @since 6.9.0
158158
*
159159
* @see wp_get_ability_categories()
160160
*
161-
* @return array<string, WP_Ability_Category> The array of registered categories.
161+
* @return array<string, WP_Ability_Category> The array of registered ability categories.
162162
*/
163163
public function get_all_registered(): array {
164164
return $this->registered_categories;
165165
}
166166

167167
/**
168-
* Checks if a category is registered.
168+
* Checks if a ability category is registered.
169169
*
170170
* @since 6.9.0
171171
*
172-
* @param string $slug The slug of the category.
173-
* @return bool True if the category is registered, false otherwise.
172+
* @param string $slug The slug of the ability category.
173+
* @return bool True if the ability category is registered, false otherwise.
174174
*/
175175
public function is_registered( string $slug ): bool {
176176
return isset( $this->registered_categories[ $slug ] );
177177
}
178178

179179
/**
180-
* Retrieves a registered category.
180+
* Retrieves a registered ability category.
181181
*
182182
* Do not use this method directly. Instead, use the `wp_get_ability_category()` function.
183183
*
184184
* @since 6.9.0
185185
*
186186
* @see wp_get_ability_category()
187187
*
188-
* @param string $slug The slug of the registered category.
189-
* @return WP_Ability_Category|null The registered category instance, or null if it is not registered.
188+
* @param string $slug The slug of the registered ability category.
189+
* @return WP_Ability_Category|null The registered ability category instance, or null if it is not registered.
190190
*/
191191
public function get_registered( string $slug ): ?WP_Ability_Category {
192192
if ( ! $this->is_registered( $slug ) ) {
@@ -208,7 +208,7 @@ public function get_registered( string $slug ): ?WP_Ability_Category {
208208
*
209209
* @since 6.9.0
210210
*
211-
* @return WP_Abilities_Category_Registry The main registry instance.
211+
* @return WP_Ability_Categories_Registry The main registry instance.
212212
*/
213213
public static function get_instance(): self {
214214
if ( null === self::$instance ) {
@@ -217,11 +217,11 @@ public static function get_instance(): self {
217217
/**
218218
* Fires when preparing ability categories registry.
219219
*
220-
* Categories should be registered on this action to ensure they're available when needed.
220+
* Ability categories should be registered on this action to ensure they're available when needed.
221221
*
222222
* @since 6.9.0
223223
*
224-
* @param WP_Abilities_Category_Registry $instance Categories registry object.
224+
* @param WP_Ability_Categories_Registry $instance Ability categories registry object.
225225
*/
226226
do_action( 'wp_abilities_api_categories_init', self::$instance );
227227
}

0 commit comments

Comments
 (0)