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 https://github.com/WordPress/wordpress-develop/pull/10423.

Follow-up [61063].
See #64146.


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


git-svn-id: http://core.svn.wordpress.org/trunk@60404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
gziolo
2025-10-27 09:08:28 +00:00
parent d0c71b779f
commit e075f91aec
3 changed files with 38 additions and 45 deletions

View File

@@ -8,6 +8,7 @@
*/
declare( strict_types = 1 );
/**
* Registers the core ability categories.
*
@@ -44,16 +45,41 @@ function wp_register_core_abilities(): void {
$category_site = 'site';
$category_user = 'user';
$site_info_fields = array(
'name',
'description',
'url',
'wpurl',
'admin_email',
'charset',
'language',
'version',
$site_info_properties = array(
'name' => array(
'type' => 'string',
'description' => __( 'The site title.' ),
),
'description' => array(
'type' => 'string',
'description' => __( 'The site tagline.' ),
),
'url' => array(
'type' => 'string',
'description' => __( 'The site home URL.' ),
),
'wpurl' => array(
'type' => 'string',
'description' => __( 'The WordPress installation URL.' ),
),
'admin_email' => array(
'type' => 'string',
'description' => __( 'The site administrator email address.' ),
),
'charset' => array(
'type' => 'string',
'description' => __( 'The site character encoding.' ),
),
'language' => array(
'type' => 'string',
'description' => __( 'The site language locale code.' ),
),
'version' => array(
'type' => 'string',
'description' => __( 'The WordPress version.' ),
),
);
$site_info_fields = array_keys( $site_info_properties );
wp_register_ability(
'core/get-site-info',
@@ -78,40 +104,7 @@ function wp_register_core_abilities(): void {
),
'output_schema' => array(
'type' => 'object',
'properties' => array(
'name' => array(
'type' => 'string',
'description' => __( 'The site title.' ),
),
'description' => array(
'type' => 'string',
'description' => __( 'The site tagline.' ),
),
'url' => array(
'type' => 'string',
'description' => __( 'The site home URL.' ),
),
'wpurl' => array(
'type' => 'string',
'description' => __( 'The WordPress installation URL.' ),
),
'admin_email' => array(
'type' => 'string',
'description' => __( 'The site administrator email address.' ),
),
'charset' => array(
'type' => 'string',
'description' => __( 'The site character encoding.' ),
),
'language' => array(
'type' => 'string',
'description' => __( 'The site language locale code.' ),
),
'version' => array(
'type' => 'string',
'description' => __( 'The WordPress version.' ),
),
),
'properties' => $site_info_properties,
'additionalProperties' => false,
),
'execute_callback' => static function ( $input = array() ) use ( $site_info_fields ): array {

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.9-beta1-61067';
$wp_version = '6.9-beta1-61068';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@@ -290,7 +290,7 @@ require ABSPATH . WPINC . '/abilities-api/class-wp-ability-categories-registry.p
require ABSPATH . WPINC . '/abilities-api/class-wp-ability.php';
require ABSPATH . WPINC . '/abilities-api/class-wp-abilities-registry.php';
require ABSPATH . WPINC . '/abilities-api.php';
require ABSPATH . WPINC . '/abilities/wp-core-abilities.php';
require ABSPATH . WPINC . '/abilities.php';
require ABSPATH . WPINC . '/rest-api.php';
require ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php';
require ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php';