Skip to content

Commit d95a598

Browse files
committed
Abilities API: Refactor registration for core abilities
Renames the files and adds a test cleanup so it doesn't accidentaly influence the rest of other tests. Developed in WordPress/wordpress-develop#10423. Follow-up [61063]. See #64146. Built from https://develop.svn.wordpress.org/trunk@61068 git-svn-id: https://core.svn.wordpress.org/trunk@60404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 8716c27 commit d95a598

File tree

3 files changed

+38
-45
lines changed

3 files changed

+38
-45
lines changed

wp-includes/abilities/wp-core-abilities.php

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
declare( strict_types = 1 );
11+
1112
/**
1213
* Registers the core ability categories.
1314
*
@@ -44,16 +45,41 @@ function wp_register_core_abilities(): void {
4445
$category_site = 'site';
4546
$category_user = 'user';
4647

47-
$site_info_fields = array(
48-
'name',
49-
'description',
50-
'url',
51-
'wpurl',
52-
'admin_email',
53-
'charset',
54-
'language',
55-
'version',
48+
$site_info_properties = array(
49+
'name' => array(
50+
'type' => 'string',
51+
'description' => __( 'The site title.' ),
52+
),
53+
'description' => array(
54+
'type' => 'string',
55+
'description' => __( 'The site tagline.' ),
56+
),
57+
'url' => array(
58+
'type' => 'string',
59+
'description' => __( 'The site home URL.' ),
60+
),
61+
'wpurl' => array(
62+
'type' => 'string',
63+
'description' => __( 'The WordPress installation URL.' ),
64+
),
65+
'admin_email' => array(
66+
'type' => 'string',
67+
'description' => __( 'The site administrator email address.' ),
68+
),
69+
'charset' => array(
70+
'type' => 'string',
71+
'description' => __( 'The site character encoding.' ),
72+
),
73+
'language' => array(
74+
'type' => 'string',
75+
'description' => __( 'The site language locale code.' ),
76+
),
77+
'version' => array(
78+
'type' => 'string',
79+
'description' => __( 'The WordPress version.' ),
80+
),
5681
);
82+
$site_info_fields = array_keys( $site_info_properties );
5783

5884
wp_register_ability(
5985
'core/get-site-info',
@@ -78,40 +104,7 @@ function wp_register_core_abilities(): void {
78104
),
79105
'output_schema' => array(
80106
'type' => 'object',
81-
'properties' => array(
82-
'name' => array(
83-
'type' => 'string',
84-
'description' => __( 'The site title.' ),
85-
),
86-
'description' => array(
87-
'type' => 'string',
88-
'description' => __( 'The site tagline.' ),
89-
),
90-
'url' => array(
91-
'type' => 'string',
92-
'description' => __( 'The site home URL.' ),
93-
),
94-
'wpurl' => array(
95-
'type' => 'string',
96-
'description' => __( 'The WordPress installation URL.' ),
97-
),
98-
'admin_email' => array(
99-
'type' => 'string',
100-
'description' => __( 'The site administrator email address.' ),
101-
),
102-
'charset' => array(
103-
'type' => 'string',
104-
'description' => __( 'The site character encoding.' ),
105-
),
106-
'language' => array(
107-
'type' => 'string',
108-
'description' => __( 'The site language locale code.' ),
109-
),
110-
'version' => array(
111-
'type' => 'string',
112-
'description' => __( 'The WordPress version.' ),
113-
),
114-
),
107+
'properties' => $site_info_properties,
115108
'additionalProperties' => false,
116109
),
117110
'execute_callback' => static function ( $input = array() ) use ( $site_info_fields ): array {

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.9-beta1-61067';
19+
$wp_version = '6.9-beta1-61068';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

wp-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@
290290
require ABSPATH . WPINC . '/abilities-api/class-wp-ability.php';
291291
require ABSPATH . WPINC . '/abilities-api/class-wp-abilities-registry.php';
292292
require ABSPATH . WPINC . '/abilities-api.php';
293-
require ABSPATH . WPINC . '/abilities/wp-core-abilities.php';
293+
require ABSPATH . WPINC . '/abilities.php';
294294
require ABSPATH . WPINC . '/rest-api.php';
295295
require ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php';
296296
require ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php';

0 commit comments

Comments
 (0)