Skip to content

Commit 6009755

Browse files
committed
Abilities API: Code quality fixes from syncing to the main repo
1 parent 04c61fa commit 6009755

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

src/wp-includes/abilities-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function wp_register_ability( string $name, array $args ): ?WP_Ability {
274274
__FUNCTION__,
275275
sprintf(
276276
/* translators: 1: wp_abilities_api_init, 2: string value of the ability name. */
277-
esc_html__( 'Abilities must be registered on the %1$s action. The ability %2$s was not registered.' ),
277+
__( 'Abilities must be registered on the %1$s action. The ability %2$s was not registered.' ),
278278
'<code>wp_abilities_api_init</code>',
279279
'<code>' . esc_html( $name ) . '</code>'
280280
),

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,14 @@ public function is_registered( string $name ): bool {
236236
* @see wp_get_ability()
237237
*
238238
* @param string $name The name of the registered ability, with its namespace.
239-
* @return ?WP_Ability The registered ability instance, or null if it is not registered.
239+
* @return WP_Ability|null The registered ability instance, or null if it is not registered.
240240
*/
241241
public function get_registered( string $name ): ?WP_Ability {
242242
if ( ! $this->is_registered( $name ) ) {
243243
_doing_it_wrong(
244244
__METHOD__,
245245
/* translators: %s: Ability name. */
246-
sprintf( esc_html__( 'Ability "%s" not found.' ), esc_attr( $name ) ),
246+
sprintf( __( 'Ability "%s" not found.' ), esc_html( $name ) ),
247247
'6.9.0'
248248
);
249249
return null;
@@ -265,7 +265,9 @@ public static function get_instance(): ?self {
265265
_doing_it_wrong(
266266
__METHOD__,
267267
sprintf(
268-
__( 'Ability API should not be initialized before the <code>init</code> action has fired' )
268+
// translators: %s: init action.
269+
__( 'Ability API should not be initialized before the %s action has fired.' ),
270+
'<code>init</code>'
269271
),
270272
'6.9.0'
271273
);
@@ -314,6 +316,6 @@ public function __wakeup(): void {
314316
* This is a security hardening measure to prevent serialization of the registry.
315317
*/
316318
public function __sleep(): array {
317-
throw new LogicException( __CLASS__ . ' should never be serialized' );
319+
throw new LogicException( __CLASS__ . ' should never be serialized.' );
318320
}
319321
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ public static function get_instance(): ?self {
205205
_doing_it_wrong(
206206
__METHOD__,
207207
sprintf(
208-
__( 'Ability API should not be initialized before the <code>init</code> action has fired' )
208+
// translators: %s: init action.
209+
__( 'Ability API should not be initialized before the %s action has fired' ),
210+
'<code>init</code>'
209211
),
210212
'6.9.0'
211213
);
@@ -249,6 +251,6 @@ public function __wakeup(): void {
249251
* This is a security hardening measure to prevent serialization of the registry.
250252
*/
251253
public function __sleep(): array {
252-
throw new LogicException( __CLASS__ . ' should never be serialized' );
254+
throw new LogicException( __CLASS__ . ' should never be serialized.' );
253255
}
254256
}

src/wp-includes/abilities-api/class-wp-ability-category.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ final class WP_Ability_Category {
7575
public function __construct( string $slug, array $args ) {
7676
if ( empty( $slug ) ) {
7777
throw new InvalidArgumentException(
78-
esc_html__( 'The ability category slug cannot be empty.' )
78+
__( 'The ability category slug cannot be empty.' )
7979
);
8080
}
8181

@@ -211,6 +211,6 @@ public function __wakeup(): void {
211211
* This is a security hardening measure to prevent serialization of the ability category.
212212
*/
213213
public function __sleep(): array {
214-
throw new LogicException( __CLASS__ . ' should never be serialized' );
214+
throw new LogicException( __CLASS__ . ' should never be serialized.' );
215215
}
216216
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function __construct( string $name, array $args ) {
169169
__( 'Property "%1$s" is not a valid property for ability "%2$s". Please check the %3$s class for allowed properties.' ),
170170
'<code>' . esc_html( $property_name ) . '</code>',
171171
'<code>' . esc_html( $this->name ) . '</code>',
172-
'<code>' . self::class . '</code>'
172+
'<code>' . __CLASS__ . '</code>'
173173
),
174174
'6.9.0'
175175
);
@@ -445,7 +445,7 @@ public function validate_input( $input = null ) {
445445
sprintf(
446446
/* translators: %s ability name. */
447447
__( 'Ability "%s" does not define an input schema required to validate the provided input.' ),
448-
$this->name
448+
esc_html( $this->name )
449449
)
450450
);
451451
}
@@ -457,7 +457,7 @@ public function validate_input( $input = null ) {
457457
sprintf(
458458
/* translators: %1$s ability name, %2$s error message. */
459459
__( 'Ability "%1$s" has invalid input. Reason: %2$s' ),
460-
$this->name,
460+
esc_html( $this->name ),
461461
$valid_input->get_error_message()
462462
)
463463
);
@@ -514,7 +514,7 @@ protected function do_execute( $input = null ) {
514514
return new WP_Error(
515515
'ability_invalid_execute_callback',
516516
/* translators: %s ability name. */
517-
sprintf( __( 'Ability "%s" does not have a valid execute callback.' ), $this->name )
517+
sprintf( __( 'Ability "%s" does not have a valid execute callback.' ), esc_html( $this->name ) )
518518
);
519519
}
520520

@@ -542,7 +542,7 @@ protected function validate_output( $output ) {
542542
sprintf(
543543
/* translators: %1$s ability name, %2$s error message. */
544544
__( 'Ability "%1$s" has invalid output. Reason: %2$s' ),
545-
$this->name,
545+
esc_html( $this->name ),
546546
$valid_output->get_error_message()
547547
)
548548
);
@@ -581,7 +581,7 @@ public function execute( $input = null ) {
581581
return new WP_Error(
582582
'ability_invalid_permissions',
583583
/* translators: %s ability name. */
584-
sprintf( __( 'Ability "%s" does not have necessary permission.' ), $this->name )
584+
sprintf( __( 'Ability "%s" does not have necessary permission.' ), esc_html( $this->name ) )
585585
);
586586
}
587587

@@ -638,6 +638,6 @@ public function __wakeup(): void {
638638
* This is a security hardening measure to prevent serialization of the ability.
639639
*/
640640
public function __sleep(): array {
641-
throw new LogicException( __CLASS__ . ' should never be serialized' );
641+
throw new LogicException( __CLASS__ . ' should never be serialized.' );
642642
}
643643
}

0 commit comments

Comments
 (0)