mirror of
https://github.com/WordPress/WordPress.git
synced 2026-06-19 07:37:07 +00:00
Abilities API: Code quality fixes around translations
This aligns with how translations are handled across all places in the Abilities API codebase. It addresses the feedback raised during syncing back changes to Abilities API repository with https://github.com/WordPress/abilities-api/pull/126. Developed in https://github.com/WordPress/wordpress-develop/pull/10424. Follow-up [61032]. Props gziolo, jorgefilipecosta. See #64098. Built from https://develop.svn.wordpress.org/trunk@61071 git-svn-id: http://core.svn.wordpress.org/trunk@60407 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -274,7 +274,7 @@ function wp_register_ability( string $name, array $args ): ?WP_Ability {
|
||||
__FUNCTION__,
|
||||
sprintf(
|
||||
/* translators: 1: wp_abilities_api_init, 2: string value of the ability name. */
|
||||
esc_html__( 'Abilities must be registered on the %1$s action. The ability %2$s was not registered.' ),
|
||||
__( 'Abilities must be registered on the %1$s action. The ability %2$s was not registered.' ),
|
||||
'<code>wp_abilities_api_init</code>',
|
||||
'<code>' . esc_html( $name ) . '</code>'
|
||||
),
|
||||
|
||||
@@ -236,14 +236,14 @@ final class WP_Abilities_Registry {
|
||||
* @see wp_get_ability()
|
||||
*
|
||||
* @param string $name The name of the registered ability, with its namespace.
|
||||
* @return ?WP_Ability The registered ability instance, or null if it is not registered.
|
||||
* @return WP_Ability|null The registered ability instance, or null if it is not registered.
|
||||
*/
|
||||
public function get_registered( string $name ): ?WP_Ability {
|
||||
if ( ! $this->is_registered( $name ) ) {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
/* translators: %s: Ability name. */
|
||||
sprintf( esc_html__( 'Ability "%s" not found.' ), esc_attr( $name ) ),
|
||||
sprintf( __( 'Ability "%s" not found.' ), esc_html( $name ) ),
|
||||
'6.9.0'
|
||||
);
|
||||
return null;
|
||||
@@ -265,7 +265,9 @@ final class WP_Abilities_Registry {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
sprintf(
|
||||
__( 'Ability API should not be initialized before the <code>init</code> action has fired' )
|
||||
// translators: %s: init action.
|
||||
__( 'Ability API should not be initialized before the %s action has fired.' ),
|
||||
'<code>init</code>'
|
||||
),
|
||||
'6.9.0'
|
||||
);
|
||||
@@ -314,6 +316,6 @@ final class WP_Abilities_Registry {
|
||||
* This is a security hardening measure to prevent serialization of the registry.
|
||||
*/
|
||||
public function __sleep(): array {
|
||||
throw new LogicException( __CLASS__ . ' should never be serialized' );
|
||||
throw new LogicException( __CLASS__ . ' should never be serialized.' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,9 @@ final class WP_Ability_Categories_Registry {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
sprintf(
|
||||
__( 'Ability API should not be initialized before the <code>init</code> action has fired' )
|
||||
// translators: %s: init action.
|
||||
__( 'Ability API should not be initialized before the %s action has fired.' ),
|
||||
'<code>init</code>'
|
||||
),
|
||||
'6.9.0'
|
||||
);
|
||||
@@ -249,6 +251,6 @@ final class WP_Ability_Categories_Registry {
|
||||
* This is a security hardening measure to prevent serialization of the registry.
|
||||
*/
|
||||
public function __sleep(): array {
|
||||
throw new LogicException( __CLASS__ . ' should never be serialized' );
|
||||
throw new LogicException( __CLASS__ . ' should never be serialized.' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ final class WP_Ability_Category {
|
||||
public function __construct( string $slug, array $args ) {
|
||||
if ( empty( $slug ) ) {
|
||||
throw new InvalidArgumentException(
|
||||
esc_html__( 'The ability category slug cannot be empty.' )
|
||||
__( 'The ability category slug cannot be empty.' )
|
||||
);
|
||||
}
|
||||
|
||||
@@ -211,6 +211,6 @@ final class WP_Ability_Category {
|
||||
* This is a security hardening measure to prevent serialization of the ability category.
|
||||
*/
|
||||
public function __sleep(): array {
|
||||
throw new LogicException( __CLASS__ . ' should never be serialized' );
|
||||
throw new LogicException( __CLASS__ . ' should never be serialized.' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class WP_Ability {
|
||||
__( 'Property "%1$s" is not a valid property for ability "%2$s". Please check the %3$s class for allowed properties.' ),
|
||||
'<code>' . esc_html( $property_name ) . '</code>',
|
||||
'<code>' . esc_html( $this->name ) . '</code>',
|
||||
'<code>' . self::class . '</code>'
|
||||
'<code>' . __CLASS__ . '</code>'
|
||||
),
|
||||
'6.9.0'
|
||||
);
|
||||
@@ -445,7 +445,7 @@ class WP_Ability {
|
||||
sprintf(
|
||||
/* translators: %s ability name. */
|
||||
__( 'Ability "%s" does not define an input schema required to validate the provided input.' ),
|
||||
$this->name
|
||||
esc_html( $this->name )
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -457,7 +457,7 @@ class WP_Ability {
|
||||
sprintf(
|
||||
/* translators: %1$s ability name, %2$s error message. */
|
||||
__( 'Ability "%1$s" has invalid input. Reason: %2$s' ),
|
||||
$this->name,
|
||||
esc_html( $this->name ),
|
||||
$valid_input->get_error_message()
|
||||
)
|
||||
);
|
||||
@@ -514,7 +514,7 @@ class WP_Ability {
|
||||
return new WP_Error(
|
||||
'ability_invalid_execute_callback',
|
||||
/* translators: %s ability name. */
|
||||
sprintf( __( 'Ability "%s" does not have a valid execute callback.' ), $this->name )
|
||||
sprintf( __( 'Ability "%s" does not have a valid execute callback.' ), esc_html( $this->name ) )
|
||||
);
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ class WP_Ability {
|
||||
sprintf(
|
||||
/* translators: %1$s ability name, %2$s error message. */
|
||||
__( 'Ability "%1$s" has invalid output. Reason: %2$s' ),
|
||||
$this->name,
|
||||
esc_html( $this->name ),
|
||||
$valid_output->get_error_message()
|
||||
)
|
||||
);
|
||||
@@ -581,7 +581,7 @@ class WP_Ability {
|
||||
return new WP_Error(
|
||||
'ability_invalid_permissions',
|
||||
/* translators: %s ability name. */
|
||||
sprintf( __( 'Ability "%s" does not have necessary permission.' ), $this->name )
|
||||
sprintf( __( 'Ability "%s" does not have necessary permission.' ), esc_html( $this->name ) )
|
||||
);
|
||||
}
|
||||
|
||||
@@ -638,6 +638,6 @@ class WP_Ability {
|
||||
* This is a security hardening measure to prevent serialization of the ability.
|
||||
*/
|
||||
public function __sleep(): array {
|
||||
throw new LogicException( __CLASS__ . ' should never be serialized' );
|
||||
throw new LogicException( __CLASS__ . ' should never be serialized.' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.9-beta1-61070';
|
||||
$wp_version = '6.9-beta1-61071';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user