Skip to content

Commit b2e95b9

Browse files
Abilities API: scope the WP_Settings_Abilities class.
Make WP_Settings_Abilities final and tighten member visibility so the intended surface is enforced rather than only documented via @access private. Only the externally-invoked entry points remain public (register(), execute_get_settings(), has_permission()); register_get_settings() and the shared helpers become private, and CATEGORY becomes a private const. Method bodies and the static cache are unchanged.
1 parent 6eea893 commit b2e95b9

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎src/wp-includes/abilities/class-wp-settings-abilities.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
*
2525
* @access private
2626
*/
27-
class WP_Settings_Abilities {
27+
final class WP_Settings_Abilities {
2828

2929
/**
3030
* The ability category used for settings abilities.
3131
*
3232
* @since 7.1.0
3333
* @var string
3434
*/
35-
const CATEGORY = 'site';
35+
private const CATEGORY = 'site';
3636

3737
/**
3838
* Settings exposed through the Abilities API, computed once at registration.
@@ -68,7 +68,7 @@ public static function register(): void {
6868
*
6969
* @since 7.1.0
7070
*/
71-
public static function register_get_settings(): void {
71+
private static function register_get_settings(): void {
7272
// Compute once; execute_get_settings() reuses this exact structure.
7373
self::$exposed_settings = self::get_exposed_settings();
7474

@@ -173,7 +173,7 @@ public static function has_permission(): bool {
173173
* @param list<string> $field_names Available exposed setting names.
174174
* @return array<string, mixed> The input JSON Schema.
175175
*/
176-
protected static function get_settings_input_schema( array $groups, array $field_names ): array {
176+
private static function get_settings_input_schema( array $groups, array $field_names ): array {
177177
return array(
178178
'type' => 'object',
179179
// Object (not array()) so the serialized schema default is {}, consistent with type:object.
@@ -209,7 +209,7 @@ protected static function get_settings_input_schema( array $groups, array $field
209209
*
210210
* @return array<string, array{option: string, group: string, default: mixed, schema: array<string, mixed>}> Settings keyed by exposed name.
211211
*/
212-
protected static function get_exposed_settings(): array {
212+
private static function get_exposed_settings(): array {
213213
$settings = array();
214214

215215
foreach ( get_registered_settings() as $option_name => $args ) {
@@ -241,7 +241,7 @@ protected static function get_exposed_settings(): array {
241241
* @param bool|array<string, mixed> $show The setting's `show_in_abilities` value.
242242
* @return array<string, mixed> The value JSON Schema.
243243
*/
244-
protected static function value_schema( array $args, $show ): array {
244+
private static function value_schema( array $args, $show ): array {
245245
$schema = array(
246246
'type' => isset( $args['type'] ) && is_string( $args['type'] ) ? $args['type'] : 'string',
247247
);
@@ -269,7 +269,7 @@ protected static function value_schema( array $args, $show ): array {
269269
* @param string $type The registered setting type.
270270
* @return mixed The value cast to the declared type.
271271
*/
272-
protected static function cast_value( $value, string $type ) {
272+
private static function cast_value( $value, string $type ) {
273273
switch ( $type ) {
274274
case 'boolean':
275275
return (bool) $value;

0 commit comments

Comments
 (0)