Skip to content

Commit 5881244

Browse files
use raw option names
1 parent 493c07b commit 5881244

1 file changed

Lines changed: 4 additions & 26 deletions

File tree

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

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,7 @@ private static function get_available_slugs(): array {
113113
continue;
114114
}
115115

116-
$rest_name = $option_name;
117-
if ( is_array( $args['show_in_rest'] ) && ! empty( $args['show_in_rest']['name'] ) ) {
118-
$rest_name = $args['show_in_rest']['name'];
119-
}
120-
121-
$slugs[] = $rest_name;
116+
$slugs[] = $option_name;
122117
}
123118

124119
sort( $slugs );
@@ -147,11 +142,6 @@ private static function build_output_schema(): array {
147142

148143
$group = $args['group'] ?? 'general';
149144

150-
$rest_name = $option_name;
151-
if ( is_array( $args['show_in_rest'] ) && ! empty( $args['show_in_rest']['name'] ) ) {
152-
$rest_name = $args['show_in_rest']['name'];
153-
}
154-
155145
$setting_schema = array(
156146
'type' => $args['type'] ?? 'string',
157147
);
@@ -166,10 +156,6 @@ private static function build_output_schema(): array {
166156
$setting_schema['description'] = $args['label'];
167157
}
168158

169-
if ( isset( $args['default'] ) ) {
170-
$setting_schema['default'] = $args['default'];
171-
}
172-
173159
if ( ! isset( $group_properties[ $group ] ) ) {
174160
$group_properties[ $group ] = array(
175161
'type' => 'object',
@@ -183,7 +169,7 @@ private static function build_output_schema(): array {
183169
);
184170
}
185171

186-
$group_properties[ $group ]['properties'][ $rest_name ] = $setting_schema;
172+
$group_properties[ $group ]['properties'][ $option_name ] = $setting_schema;
187173
}
188174

189175
ksort( $group_properties );
@@ -291,19 +277,11 @@ public static function execute_get_settings( $input = array() ): array {
291277
continue;
292278
}
293279

294-
$rest_name = $option_name;
295-
if ( is_array( $args['show_in_rest'] ) && ! empty( $args['show_in_rest']['name'] ) ) {
296-
$rest_name = $args['show_in_rest']['name'];
297-
}
298-
299-
if ( $filter_slugs && ! in_array( $rest_name, $filter_slugs, true ) ) {
280+
if ( $filter_slugs && ! in_array( $option_name, $filter_slugs, true ) ) {
300281
continue;
301282
}
302283

303284
$default = $args['default'] ?? null;
304-
if ( is_array( $args['show_in_rest'] ) && isset( $args['show_in_rest']['schema']['default'] ) ) {
305-
$default = $args['show_in_rest']['schema']['default'];
306-
}
307285

308286
$value = get_option( $option_name, $default );
309287
$value = self::cast_value( $value, $args['type'] ?? 'string' );
@@ -312,7 +290,7 @@ public static function execute_get_settings( $input = array() ): array {
312290
$settings_by_group[ $group ] = array();
313291
}
314292

315-
$settings_by_group[ $group ][ $rest_name ] = $value;
293+
$settings_by_group[ $group ][ $option_name ] = $value;
316294
}
317295

318296
ksort( $settings_by_group );

0 commit comments

Comments
 (0)