Abilities API: Stop HTML-escaping the ability name in WP_Error messages

Ability names are pattern-validated at registration, so `esc_html()` on them is always a no-op. Drop it from the `WP_Error` messages, which are commonly serialized to JSON where the escaping would be incorrect.

Follow-up to [62398].
See #64311.


Built from https://develop.svn.wordpress.org/trunk@62401


git-svn-id: http://core.svn.wordpress.org/trunk@61682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
gziolo
2026-05-21 10:28:39 +00:00
parent 285d71b5c0
commit ffa39fdccd
2 changed files with 5 additions and 5 deletions
@@ -561,7 +561,7 @@ class WP_Ability {
sprintf(
/* translators: 1: Ability name, 2: Exception message. */
__( 'Ability "%1$s" callback threw an exception: %2$s' ),
esc_html( $this->name ),
$this->name,
esc_html( $e->getMessage() )
)
);
@@ -590,7 +590,7 @@ class WP_Ability {
return new WP_Error(
'ability_invalid_permission_callback',
/* translators: %s ability name. */
sprintf( __( 'Ability "%s" does not have a valid permission callback.' ), esc_html( $this->name ) )
sprintf( __( 'Ability "%s" does not have a valid permission callback.' ), $this->name )
);
}
@@ -638,7 +638,7 @@ class WP_Ability {
$result = new WP_Error(
'ability_invalid_execute_callback',
/* translators: %s ability name. */
sprintf( __( 'Ability "%s" does not have a valid execute callback.' ), esc_html( $this->name ) )
sprintf( __( 'Ability "%s" does not have a valid execute callback.' ), $this->name )
);
} else {
$result = $this->invoke_callback( $this->execute_callback, $input );
@@ -783,7 +783,7 @@ class WP_Ability {
return new WP_Error(
'ability_invalid_permissions',
/* translators: %s ability name. */
sprintf( __( 'Ability "%s" does not have necessary permission.' ), esc_html( $this->name ) )
sprintf( __( 'Ability "%s" does not have necessary permission.' ), $this->name )
);
}
+1 -1
View File
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.1-alpha-62400';
$wp_version = '7.1-alpha-62401';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.