Title: WP_Ability::__construct
Published: February 24, 2026
Last modified: August 20, 2026

---

# WP_Ability::__construct( string $name,  $args )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Constructor.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#description)󠁿

Do not use this constructor directly. Instead, use the `wp_register_ability()` function.

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#see-also)󠁿

 * [wp_register_ability()](https://developer.wordpress.org/reference/functions/wp_register_ability/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#parameters)󠁿

 `$name`stringrequired

The name of the ability, with its namespace.

mixed> $args { An associative array of arguments for the ability.
 @type string 
$label The human-readable label for the ability. @type string $description A detailed
description of what the ability does. @type string $category The ability category
slug this ability belongs to. @type callable $execute_callback A callback function
to execute when the ability is invoked. Receives optional mixed input and returns
mixed result or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/).@
type callable $permission_callback A callback function to check permissions before
execution. Receives optional mixed input and returns bool or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/).@
type array<string, mixed> $input_schema Optional. JSON Schema definition for the
ability’s input. @type array<string, mixed> $output_schema Optional. JSON Schema
definition for the ability’s output. @type array<string, mixed> $meta { Optional.
Additional metadata for the ability. @type array<string, `bool|null`> $annotations{
Optional. Semantic annotations describing the ability’s behavioral characteristics.
These annotations are hints for tooling and documentation. @type `bool|null` $readonly
Optional. If true, the ability does not modify its environment. @type `bool|null`
$destructive Optional. If true, the ability may perform destructive updates to its
environment. If false, the ability performs only additive updates. @type `bool|null`
$idempotent Optional. If true, calling the ability repeatedly with the same arguments
will have no additional effect on its environment. } @type bool $public Optional.
Whether the ability is meant to be available to clients such as the REST API, MCP,
or AI agents. Seeds the default for per-channel flags like `$show_in_rest`. Defaults
to false. @type bool $show_in_rest Optional. Whether to expose this ability in the
REST API. Default is the value of `$public` when set, false otherwise. } }

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#source)󠁿

    ```php
    public function __construct( string $name, array $args ) {
    	$this->name = $name;

    	$properties = $this->prepare_properties( $args );

    	foreach ( $properties as $property_name => $property_value ) {
    		if ( ! property_exists( $this, $property_name ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				sprintf(
    					/* translators: %s: Property name. */
    					__( 'Property "%1$s" is not a valid property for ability "%2$s". Please check the %3$s class for allowed properties.' ),
    					'<code>' . esc_html( $property_name ) . '</code>',
    					'<code>' . esc_html( $this->name ) . '</code>',
    					'<code>' . __CLASS__ . '</code>'
    				),
    				'6.9.0'
    			);
    			continue;
    		}

    		$this->$property_name = $property_value;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/abilities-api/class-wp-ability.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/abilities-api/class-wp-ability.php#L180)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/abilities-api/class-wp-ability.php#L180-L203)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Ability::prepare_properties()](https://developer.wordpress.org/reference/classes/wp_ability/prepare_properties/)`wp-includes/abilities-api/class-wp-ability.php` |

Prepares and validates the properties used to instantiate the ability.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_ability/__construct/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.9.0](https://developer.wordpress.org/reference/since/6.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_ability%2F__construct%2F)
before being able to contribute a note or feedback.