wppaste
WordPress

wp_register_core_abilities()

Since
6.9.0
Source
wp-includes/abilities.php:42
Registers the default core abilities.

Compatibility

WordPress
since 6.9.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 3 of the 5 tracked releases, added in 6.9.0, and compiles on PHP 7.4 through 8.6-dev.

Performance profile

How much work a call to wp_register_core_abilities() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_user_by().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
5

Executed per call on PHP 8.5. The body compiles to 504.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()one call below wp_register_core_abilities()
  • optionnetwork optionget_site_option()one call below wp_register_core_abilities()
  • querycontent queryget_user_by()one call below wp_register_core_abilities()

Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 1 distinct outcome

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_register_core_abilities() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always5current_user_can()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev504511
8.5504511
8.45045113 fewer instructions than PHP 8.3
8.3507511
8.2507511
8.15075115 fewer instructions than PHP 7.4
7.4512511

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 9

Source code

function wp_register_core_abilities(): void {	$category_site = 'site';	$category_user = 'user'; 	$site_info_properties = array(		'name'        => array(			'type'        => 'string',			'title'       => __( 'Site Title' ),			'description' => __( 'The site title.' ),		),		'description' => array(			'type'        => 'string',			'title'       => __( 'Tagline' ),			'description' => __( 'The site tagline.' ),		),		'url'         => array(			'type'        => 'string',			'title'       => __( 'Site Address (URL)' ),			'description' => __( 'The public URL where visitors access the site. May differ from the WordPress installation URL.' ),		),		'wpurl'       => array(			'type'        => 'string',			'title'       => __( 'WordPress Address (URL)' ),			'description' => __( 'The URL where WordPress core files are served. May differ from the public site URL.' ),		),		'admin_email' => array(			'type'        => 'string',			'title'       => __( 'Administration Email Address' ),			'description' => __( 'The site administrator email address.' ),		),		'charset'     => array(			'type'        => 'string',			'title'       => __( 'Site Charset' ),			'description' => __( 'The site character encoding.' ),		),		'language'    => array(			'type'        => 'string',			'title'       => __( 'Site Language' ),			'description' => __( 'The site locale in dash form (e.g. en-US).' ),		),		'version'     => array(			'type'        => 'string',			'title'       => __( 'WordPress Version' ),			'description' => __( 'The WordPress core version running on this site.' ),		),	);	$site_info_fields     = array_keys( $site_info_properties ); 	wp_register_ability(		'core/get-site-info',		array(			'label'               => __( 'Get Site Information' ),			'description'         => __( 'Returns site information configured in WordPress. By default returns all fields, or optionally a filtered subset.' ),			'category'            => $category_site,			'input_schema'        => array(				'type'                 => 'object',				'properties'           => array(					'fields' => array(						'type'        => 'array',						'items'       => array(							'type' => 'string',							'enum' => $site_info_fields,						),						'description' => __( 'Optional: Limit response to specific fields. If omitted, all fields are returned.' ),					),				),				'additionalProperties' => false,				'default'              => array(),			),			'output_schema'       => array(				'type'                 => 'object',				'properties'           => $site_info_properties,				'additionalProperties' => false,			),			'execute_callback'    => static function ( $input = array() ) use ( $site_info_fields ): array {				$input = is_array( $input ) ? $input : array();				$requested_fields = ! empty( $input['fields'] ) ? $input['fields'] : $site_info_fields; 				$result = array();				foreach ( $requested_fields as $field ) {

Changelog

Introduced in 6.9.0. One change between 6.9.7 and 7.1.0.

  1. 6.9.7
  2. 7.0.4
  3. 7.1.0

Signature, return type and hooks compared across 3 parsed releases.

7.0.4
Return type changed from void to none.verified against source
6.9.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/abilities.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.