wp_register_core_abilities()
- Since
- 6.9.0
- Source
wp-includes/abilities.php:42
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
- Scaling
- Constant
- Instructions
- 5
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_user_by().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 504.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below wp_register_core_abilities() - optionnetwork option
get_site_option()one call below wp_register_core_abilities() - querycontent query
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 5 | current_user_can() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 504 | 5 | 11 | |
| 8.5 | 504 | 5 | 11 | |
| 8.4 | 504 | 5 | 11 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 507 | 5 | 11 | |
| 8.2 | 507 | 5 | 11 | |
| 8.1 | 507 | 5 | 11 | 5 fewer instructions than PHP 7.4 |
| 7.4 | 512 | 5 | 11 |
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
- __()Retrieves the translation of $text.
- wp_register_ability()Registers a new ability using the Abilities API. It requires three steps:
- get_locale()Retrieves the current locale.
- get_bloginfo()Retrieves information about the current site.
- current_user_can()Returns whether the current user has the specified capability.
- wp_get_current_user()Retrieves the current user object.
- get_user_locale()Retrieves the locale of a user.
- is_user_logged_in()Determines whether the current visitor is a logged in user.
- wp_get_environment_type()Retrieves the current environment type.
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.
Signature, return type and hooks compared across 3 parsed releases.
void to none.verified against sourceAbout 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.